diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-10 11:52:04 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-10 11:52:04 +0100 |
| commit | 2cefa82d059dfd16d224b16f92fd69104beb24a2 (patch) | |
| tree | 17379341465e719747c0d230778b3624cc233dc3 /src/test/java/org/shedlang/compiler/ast | |
| parent | d1d9c3800ab56b3c825f72e3e997b0521cfac9ce (diff) | |
Compile calls to stack instructions
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/typed/Typed.java | 19 | ||||
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java | 40 |
2 files changed, 39 insertions, 20 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/typed/Typed.java b/src/test/java/org/shedlang/compiler/ast/typed/Typed.java index 75f54d36..ed58b4d4 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/Typed.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/Typed.java @@ -5,6 +5,7 @@ import org.shedlang.compiler.types.Type; import org.shedlang.compiler.types.Types; import java.math.BigInteger; +import java.util.List; public class Typed { private Typed() { @@ -14,10 +15,28 @@ public class Typed { return new TypedBoolLiteralNode(value, Sources.NULL); } + public static TypedCallNode call( + TypedExpressionNode receiver, + List<TypedExpressionNode> positionalArgs, + List<TypedNamedArgNode> namedArgs + ) { + return new TypedCallNode( + receiver, + new TypedArgsNode(positionalArgs, namedArgs, Sources.NULL), + false, + Types.UNIT, + Sources.NULL + ); + } + public static TypedIntLiteralNode intLiteral(int value) { return new TypedIntLiteralNode(BigInteger.valueOf(value), Sources.NULL); } + public static TypedNamedArgNode namedArg(String name, TypedExpressionNode expression) { + return new TypedNamedArgNode(name, expression, Sources.NULL); + } + public static TypedStringLiteralNode stringLiteral(String value) { return new TypedStringLiteralNode(value, Sources.NULL); } diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java b/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java index 11e7b38f..5cc0ce85 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java @@ -13,26 +13,6 @@ public class Untyped { return new UntypedBoolLiteralNode(value, Sources.NULL); } - public static UntypedIntLiteralNode intLiteral(int value) { - return new UntypedIntLiteralNode(BigInteger.valueOf(value), Sources.NULL); - } - - public static UntypedIntLiteralNode intLiteral(BigInteger value) { - return new UntypedIntLiteralNode(value, Sources.NULL); - } - - public static UntypedNamedArgNode namedArg(String name, UntypedExpressionNode expression) { - return new UntypedNamedArgNode(name, expression, Sources.NULL); - } - - public static UntypedReferenceNode reference(String name) { - return new UntypedReferenceNode(name, Sources.NULL); - } - - public static UntypedStringLiteralNode stringLiteral(String value) { - return new UntypedStringLiteralNode(value, Sources.NULL); - } - public static UntypedCallNode call( UntypedExpressionNode receiver, List<UntypedExpressionNode> positionalArgs @@ -52,4 +32,24 @@ public class Untyped { Sources.NULL ); } + + public static UntypedIntLiteralNode intLiteral(int value) { + return new UntypedIntLiteralNode(BigInteger.valueOf(value), Sources.NULL); + } + + public static UntypedIntLiteralNode intLiteral(BigInteger value) { + return new UntypedIntLiteralNode(value, Sources.NULL); + } + + public static UntypedNamedArgNode namedArg(String name, UntypedExpressionNode expression) { + return new UntypedNamedArgNode(name, expression, Sources.NULL); + } + + public static UntypedReferenceNode reference(String name) { + return new UntypedReferenceNode(name, Sources.NULL); + } + + public static UntypedStringLiteralNode stringLiteral(String value) { + return new UntypedStringLiteralNode(value, Sources.NULL); + } } |
