diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/ast/untyped/UntypedArgsNode.java | 18 | ||||
| -rw-r--r-- | src/main/java/org/shedlang/compiler/ast/untyped/UntypedCallNode.java | 34 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedArgsNode.java b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedArgsNode.java index 735f31ec..fb3df52e 100644 --- a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedArgsNode.java +++ b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedArgsNode.java @@ -1,6 +1,9 @@ package org.shedlang.compiler.ast.untyped; +import org.pcollections.PVector; import org.shedlang.compiler.sources.Source; +import org.shedlang.compiler.sources.Sources; +import org.shedlang.compiler.util.P; import java.util.List; @@ -9,4 +12,19 @@ public record UntypedArgsNode( List<UntypedNamedArgNode> named, Source source ) implements UntypedNode { + public static Builder builder() { + return new Builder( + P.vector(), + P.vector() + ); + } + + public record Builder( + PVector<UntypedExpressionNode> positional, + PVector<UntypedNamedArgNode> named + ) { + public UntypedArgsNode build() { + return new UntypedArgsNode(positional, named, Sources.NULL); + } + } } diff --git a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedCallNode.java b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedCallNode.java index 1f62d842..f9fe01a4 100644 --- a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedCallNode.java +++ b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedCallNode.java @@ -1,6 +1,7 @@ package org.shedlang.compiler.ast.untyped; import org.shedlang.compiler.sources.Source; +import org.shedlang.compiler.sources.Sources; public record UntypedCallNode( UntypedExpressionNode receiver, @@ -8,4 +9,37 @@ public record UntypedCallNode( boolean hasEffects, Source source ) implements UntypedExpressionNode { + public static Builder builder() { + return new Builder( + new UntypedReferenceNode("f", Sources.NULL), + UntypedArgsNode.builder(), + false + ); + } + + public record Builder( + UntypedExpressionNode receiver, + UntypedArgsNode.Builder args, + boolean hasEffects + ) { + public UntypedCallNode build() { + return new UntypedCallNode(receiver, args.build(), hasEffects, Sources.NULL); + } + + public Builder withReceiver(UntypedReferenceNode receiver) { + return new Builder( + receiver, + this.args, + this.hasEffects + ); + } + + public Builder withHasEffects(boolean hasEffects) { + return new Builder( + this.receiver, + this.args, + hasEffects + ); + } + } } |
