aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-02 19:47:35 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-02 19:47:35 +0000
commit07d62885c5150fe6eadfa9372a190dd73fd754cc (patch)
tree17959fa67c7ab5d375f3966003358afc0715b210 /src/test/java
parent0ad5be30c1d301942f8cec567d0719fd9ff18f3f (diff)
Rename stack IR to Shid
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenCallTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineEffectTests.java4
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java70
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineStructTests.java12
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenDiscardTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenFieldLoadTests.java14
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenIfTests.java36
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntEqualsTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntNotEqualTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java8
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalStoreTests.java8
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopBreakTests.java4
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopContinueTests.java4
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopTests.java8
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceFieldStoreTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceImportTests.java4
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java20
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java10
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushIntTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java10
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushUnitTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenReturnTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenSwitchTests.java20
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenTryTests.java8
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleCreateTests.java10
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarLoadTests.java8
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarStoreTests.java16
-rw-r--r--src/test/java/org/shedlang/compiler/shid/InstructionSerializerTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java)110
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenAssignTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerAssignTests.java)22
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenBlockReturnTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerBlockReturnTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenBoolLiteralTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerBoolLiteralTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenCallTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerCallTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenEffectDefinitionTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerEffectDefinitionTests.java)14
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenExpressionStatementTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerExpressionStatementTests.java)12
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenFieldAccessTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerFieldAccessTests.java)26
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionDefinitionTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java)20
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionExpressionTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionExpressionTests.java)20
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionReturnTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionReturnTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenIfTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerIfTests.java)14
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntAddTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerIntAddTests.java)12
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntEqualsTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerIntEqualsTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntLiteralTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerIntLiteralTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntNotEqualTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerIntNotEqualTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntSubTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerIntSubTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenNamespaceTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java)44
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenReferenceTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerReferenceTests.java)16
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenResumeTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerResumeTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenStringAddTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerStringAddTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenStringLiteralTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerStringLiteralTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenStructDefinitionTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerStructDefinitionTests.java)14
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenSumTypeDefinitionTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerSumTypeDefinitionTests.java)12
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenTryTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerTryTests.java)20
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenTupleTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerTupleTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenUnitLiteralTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerUnitLiteralTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenValTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java)18
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenVarTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerVarTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenWhenTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerWhenTests.java)10
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidCodeGenWhileTests.java (renamed from src/test/java/org/shedlang/compiler/stackir/StackCompilerWhileTests.java)14
-rw-r--r--src/test/java/org/shedlang/compiler/shid/instructions/InstructionMatchers.java229
-rw-r--r--src/test/java/org/shedlang/compiler/shid/instructions/Shid.java193
-rw-r--r--src/test/java/org/shedlang/compiler/stackir/instructions/InstructionMatchers.java229
-rw-r--r--src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java193
67 files changed, 867 insertions, 867 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenCallTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenCallTests.java
index a802351e..a4ed029f 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenCallTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenCallTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -16,7 +16,7 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenCallTests {
@Test
public void canCallFunctionWithNoArgs(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.call(0, List.of());
+ var instruction = Shid.call(0, List.of());
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("other"))
.temporaryPush(new PatioLocalRef("receiver"));
@@ -28,7 +28,7 @@ public class PatioCodeGenCallTests {
@Test
public void canCallFunctionWithArgs(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.call(2, List.of("b", "a"));
+ var instruction = Shid.call(2, List.of("b", "a"));
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("other"))
.temporaryPush(new PatioLocalRef("receiver"))
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineEffectTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineEffectTests.java
index a6135d0a..7137affe 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineEffectTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineEffectTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -17,7 +17,7 @@ public class PatioCodeGenDefineEffectTests {
@Test
public void canGenerateCodeForDefineEffect(Snapshotter snapshotter) throws IOException {
var effect = Effects.userDefined(NamespaceName.of("Example", "Project"), "State");
- var instruction = Instructions.defineEffect(effect);
+ var instruction = Shid.defineEffect(effect);
var typeInfos = TypeInfos.EMPTY
.addUserDefinedEffectInfo(
effect,
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java
index 696876b9..b5b9d0b5 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java
@@ -6,8 +6,8 @@ import org.shedlang.compiler.ast.typed.FreeVariables;
import org.shedlang.compiler.patio.ast.types.PatioTypes;
import org.shedlang.compiler.patio.instructions.Patio;
import org.shedlang.compiler.sources.Sources;
-import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.ShidDefineFunction;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -20,14 +20,14 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenDefineFunctionTests {
@Test
public void canDefineMinimalFunction(Snapshotter snapshotter) throws IOException {
- var instruction = new DefineFunctionInstruction(
+ var instruction = new ShidDefineFunction(
"f",
List.of(),
List.of(),
FreeVariables.empty(),
List.of(
- Instructions.pushUnit(),
- Instructions.return_()
+ Shid.pushUnit(),
+ Shid.return_()
),
Sources.NULL
);
@@ -40,20 +40,20 @@ public class PatioCodeGenDefineFunctionTests {
@Test
public void immutableFreeVariablesAreStoredInAndLoadedFromEnvironment(Snapshotter snapshotter) throws IOException {
- var instruction = new DefineFunctionInstruction(
+ var instruction = new ShidDefineFunction(
"f",
List.of(),
List.of(),
FreeVariables.builder().plus("a", Sources.NULL).plus("b", Sources.NULL).build(),
List.of(
- Instructions.localLoad("a"),
- Instructions.return_()
+ Shid.localLoad("a"),
+ Shid.return_()
),
Sources.NULL
);
var context = PatioCodeGenContext.EMPTY
- .defineStackIrParam("a")
- .defineStackIrParam("b");
+ .defineShidParam("a")
+ .defineShidParam("b");
var result = PatioCodeGen.generateInstruction(instruction, context);
@@ -62,20 +62,20 @@ public class PatioCodeGenDefineFunctionTests {
@Test
public void canCaptureFreeVariablesThatAreSetAfterDefinition(Snapshotter snapshotter) throws IOException {
- var instruction = new DefineFunctionInstruction(
+ var instruction = new ShidDefineFunction(
"f",
List.of(),
List.of(),
FreeVariables.builder().plus("a", Sources.NULL).plus("b", Sources.NULL).build(),
List.of(
- Instructions.localLoad("a"),
- Instructions.return_()
+ Shid.localLoad("a"),
+ Shid.return_()
),
Sources.NULL
);
var context = PatioCodeGenContext.EMPTY
- .declareStackIrVal("a", PatioCodeGenTypes.VALUE_TYPE).context()
- .declareStackIrVal("b", PatioCodeGenTypes.VALUE_TYPE).context();
+ .declareShidVal("a", PatioCodeGenTypes.VALUE_TYPE).context()
+ .declareShidVal("b", PatioCodeGenTypes.VALUE_TYPE).context();
context = PatioCodeGen.generateInstruction(instruction, context);
@@ -84,16 +84,16 @@ public class PatioCodeGenDefineFunctionTests {
// into the closure upon closure creation (i.e. too soon) versus after
// the free variable is set.
context = context.addInstruction(Patio.localStore(Patio.localRef("a"), Patio.int_(42)));
- context = context.initStackIrLocal("a");
+ context = context.initShidLocal("a");
context = context.addInstruction(Patio.localStore(Patio.localRef("b"), Patio.int_(47)));
- context = context.initStackIrLocal("b");
+ context = context.initShidLocal("b");
snapshotter.assertSnapshot(serialize(context));
}
@Test
public void pointersToFreeMutableVariablesAreStoredInAndLoadedFromEnvironment(Snapshotter snapshotter) throws IOException {
- var instruction = new DefineFunctionInstruction(
+ var instruction = new ShidDefineFunction(
"f",
List.of(),
List.of(),
@@ -102,16 +102,16 @@ public class PatioCodeGenDefineFunctionTests {
.plus("b", Sources.NULL)
.build(),
List.of(
- Instructions.localLoad("a"),
- Instructions.return_()
+ Shid.localLoad("a"),
+ Shid.return_()
),
Sources.NULL
);
var context = PatioCodeGenContext.EMPTY
- .declareStackIrVal("a", PatioTypes.DATA_POINTER).context()
- .initStackIrLocal("a")
- .declareStackIrVal("b", PatioTypes.DATA_POINTER).context()
- .initStackIrLocal("b");
+ .declareShidVal("a", PatioTypes.DATA_POINTER).context()
+ .initShidLocal("a")
+ .declareShidVal("b", PatioTypes.DATA_POINTER).context()
+ .initShidLocal("b");
var result = PatioCodeGen.generateInstruction(instruction, context);
@@ -120,25 +120,25 @@ public class PatioCodeGenDefineFunctionTests {
@Test
public void positionalAndNamedParamsAreDefined(Snapshotter snapshotter) throws IOException {
- var instruction = new DefineFunctionInstruction(
+ var instruction = new ShidDefineFunction(
"f",
- List.of(Instructions.param("param1"), Instructions.param("param2")),
+ List.of(Shid.param("param1"), Shid.param("param2")),
// Define named params in non-lexical order
- List.of(Instructions.param("paramB"), Instructions.param("paramC"), Instructions.param("paramA")),
+ List.of(Shid.param("paramB"), Shid.param("paramC"), Shid.param("paramA")),
FreeVariables.builder().plus("a", Sources.NULL).plus("b", Sources.NULL).build(),
List.of(
- Instructions.localLoad("a"),
- Instructions.localLoad("param1"),
- Instructions.intAdd(),
- Instructions.localLoad("paramA"),
- Instructions.intAdd(),
- Instructions.return_()
+ Shid.localLoad("a"),
+ Shid.localLoad("param1"),
+ Shid.intAdd(),
+ Shid.localLoad("paramA"),
+ Shid.intAdd(),
+ Shid.return_()
),
Sources.NULL
);
var context = PatioCodeGenContext.EMPTY
- .defineStackIrParam("a")
- .defineStackIrParam("b");
+ .defineShidParam("a")
+ .defineShidParam("b");
var result = PatioCodeGen.generateInstruction(instruction, context);
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineStructTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineStructTests.java
index d79a33fd..450dcba2 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineStructTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineStructTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -22,11 +22,11 @@ public class PatioCodeGenDefineStructTests {
@Test
public void canGenerateCodeForDefineStruct(Snapshotter snapshotter) throws IOException {
var structType = Types.struct(NamespaceName.of("Example", "Project"), "User");
- var instruction = Instructions.defineStruct(
+ var instruction = Shid.defineStruct(
structType,
List.of(
- Instructions.defineStructField("name"),
- Instructions.defineStructField("isActive")
+ Shid.defineStructField("name"),
+ Shid.defineStructField("isActive")
)
);
var typeInfos = TypeInfos.EMPTY
@@ -51,8 +51,8 @@ public class PatioCodeGenDefineStructTests {
// will suffice for now
var structType1 = Types.struct(NamespaceName.of("Example", "Project"), "User");
var structType2 = Types.struct(NamespaceName.of("Example", "Project"), "Id");
- var instruction1 = Instructions.defineStruct(structType1, List.of());
- var instruction2 = Instructions.defineStruct(structType1, List.of());
+ var instruction1 = Shid.defineStruct(structType1, List.of());
+ var instruction2 = Shid.defineStruct(structType1, List.of());
var typeInfos = TypeInfos.EMPTY
.addStructTypeInfo(structType1, StructTypeInfo.builder().build())
.addStructTypeInfo(structType2, StructTypeInfo.builder().build());
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDiscardTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDiscardTests.java
index da7e55de..ff66e6bb 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDiscardTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDiscardTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,12 +15,12 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenDiscardTests {
@Test
public void discardInstructionPopsFromTemporaryStack(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.discard();
+ var shid = Shid.discard();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenFieldLoadTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenFieldLoadTests.java
index 1b313b84..24ec9c18 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenFieldLoadTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenFieldLoadTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeCheckerContext;
@@ -20,7 +20,7 @@ public class PatioCodeGenFieldLoadTests {
@Test
public void canGenerateCodeForNamespaceFieldLoad(Snapshotter snapshotter) throws IOException {
var namespaceName = new NamespaceName(List.of("Example", "Project"));
- var stackIrInstruction = Instructions.fieldLoad(namespaceName, "y");
+ var shidInstruction = Shid.fieldLoad(namespaceName, "y");
var typeInfos = TypeCheckerContext.EMPTY
.addNamespaceTypeInfo(
namespaceName,
@@ -35,7 +35,7 @@ public class PatioCodeGenFieldLoadTests {
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIrInstruction, context);
+ var result = PatioCodeGen.generateInstruction(shidInstruction, context);
snapshotter.assertSnapshot(serialize(result));
}
@@ -44,7 +44,7 @@ public class PatioCodeGenFieldLoadTests {
public void canGenerateCodeForStructFieldLoad(Snapshotter snapshotter) throws IOException {
var namespaceName = NamespaceName.of("Example", "Project");
var structType = Types.struct(namespaceName, "User");
- var stackIrInstruction = Instructions.fieldLoad(structType, "id");
+ var shidInstruction = Shid.fieldLoad(structType, "id");
var typeInfos = TypeInfos.EMPTY
.addStructTypeInfo(
structType,
@@ -58,7 +58,7 @@ public class PatioCodeGenFieldLoadTests {
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIrInstruction, context);
+ var result = PatioCodeGen.generateInstruction(shidInstruction, context);
snapshotter.assertSnapshot(serialize(result));
}
@@ -67,7 +67,7 @@ public class PatioCodeGenFieldLoadTests {
public void canGenerateCodeForUserDefinedEffectFieldLoad(Snapshotter snapshotter) throws IOException {
var namespaceName = NamespaceName.of("Example", "Project");
var effect = Effects.userDefined(namespaceName, "State");
- var stackIrInstruction = Instructions.fieldLoad(effect, "fence");
+ var shidInstruction = Shid.fieldLoad(effect, "fence");
var typeInfos = TypeInfos.EMPTY
.addUserDefinedEffectInfo(
effect,
@@ -81,7 +81,7 @@ public class PatioCodeGenFieldLoadTests {
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIrInstruction, context);
+ var result = PatioCodeGen.generateInstruction(shidInstruction, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIfTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIfTests.java
index c06f0c5e..34edd733 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIfTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIfTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -16,15 +16,15 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenIfTests {
@Test
public void canGenerateCodeForIfWithNoResults(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.if_(
+ var instruction = Shid.if_(
0,
List.of(
- Instructions.pushInt(1),
- Instructions.discard()
+ Shid.pushInt(1),
+ Shid.discard()
),
List.of(
- Instructions.pushInt(101),
- Instructions.discard()
+ Shid.pushInt(101),
+ Shid.discard()
)
);
var context = PatioCodeGenContext.EMPTY
@@ -38,17 +38,17 @@ public class PatioCodeGenIfTests {
@Test
public void canGenerateCodeForIfWithSingleResult(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.if_(
+ var instruction = Shid.if_(
1,
List.of(
- Instructions.pushInt(1),
- Instructions.pushInt(2),
- Instructions.intAdd()
+ Shid.pushInt(1),
+ Shid.pushInt(2),
+ Shid.intAdd()
),
List.of(
- Instructions.pushInt(101),
- Instructions.pushInt(102),
- Instructions.intAdd()
+ Shid.pushInt(101),
+ Shid.pushInt(102),
+ Shid.intAdd()
)
);
var context = PatioCodeGenContext.EMPTY
@@ -62,15 +62,15 @@ public class PatioCodeGenIfTests {
@Test
public void canGenerateCodeForIfWithMultipleResults(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.if_(
+ var instruction = Shid.if_(
2,
List.of(
- Instructions.pushInt(1),
- Instructions.pushInt(2)
+ Shid.pushInt(1),
+ Shid.pushInt(2)
),
List.of(
- Instructions.pushInt(101),
- Instructions.pushInt(102)
+ Shid.pushInt(101),
+ Shid.pushInt(102)
)
);
var context = PatioCodeGenContext.EMPTY
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java
index 12016446..53158d0d 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,13 +15,13 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenIntAddTests {
@Test
public void canGenerateCodeForIntAdd(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.intAdd();
+ var shid = Shid.intAdd();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
.temporaryPush(new PatioLocalRef("c"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntEqualsTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntEqualsTests.java
index cc1eaf2d..8b9fe35f 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntEqualsTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntEqualsTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,13 +15,13 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenIntEqualsTests {
@Test
public void canGenerateCodeForIntEquals(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.intEquals();
+ var shid = Shid.intEquals();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
.temporaryPush(new PatioLocalRef("c"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntNotEqualTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntNotEqualTests.java
index 253781d3..5715f0d4 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntNotEqualTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntNotEqualTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,13 +15,13 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenIntNotEqualTests {
@Test
public void canGenerateCodeForIntNotEqual(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.intNotEqual();
+ var shid = Shid.intNotEqual();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
.temporaryPush(new PatioLocalRef("c"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java
index 9c0ccae9..e2036764 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,13 +15,13 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenIntSubTests {
@Test
public void canGenerateCodeForIntSub(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.intSub();
+ var shid = Shid.intSub();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
.temporaryPush(new PatioLocalRef("c"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java
index 7e6b5705..f452583b 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,11 +14,11 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenLocalLoadTests {
@Test
public void localLoadPushesLocalOntoStack(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.localLoad("x");
+ var shid = Shid.localLoad("x");
var context = PatioCodeGenContext.EMPTY
- .defineStackIrParam("x");
+ .defineShidParam("x");
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalStoreTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalStoreTests.java
index dd37b35f..00b50c44 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalStoreTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalStoreTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,13 +15,13 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenLocalStoreTests {
@Test
public void localStorePopsTemporaryIntoLocal(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.localStore("x");
+ var shid = Shid.localStore("x");
var context = PatioCodeGenContext.EMPTY
- .declareStackIrVal("x", PatioCodeGenTypes.VALUE_TYPE).context()
+ .declareShidVal("x", PatioCodeGenTypes.VALUE_TYPE).context()
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopBreakTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopBreakTests.java
index 76a3799c..16ab525d 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopBreakTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopBreakTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,7 +14,7 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenLoopBreakTests {
@Test
public void canGenerateCodeForLoopBreak(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.loopBreak();
+ var instruction = Shid.loopBreak();
var context = PatioCodeGenContext.EMPTY;
var result = PatioCodeGen.generateInstruction(instruction, context);
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopContinueTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopContinueTests.java
index 281f6dcd..0e9372fc 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopContinueTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopContinueTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,7 +14,7 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenLoopContinueTests {
@Test
public void canGenerateCodeForLoopContinue(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.loopContinue();
+ var instruction = Shid.loopContinue();
var context = PatioCodeGenContext.EMPTY;
var result = PatioCodeGen.generateInstruction(instruction, context);
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopTests.java
index ff74a17b..6a9648db 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLoopTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,10 +15,10 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenLoopTests {
@Test
public void canGenerateCodeForLoop(Snapshotter snapshotter) throws IOException {
- var instruction = Instructions.loop(
+ var instruction = Shid.loop(
List.of(
- Instructions.pushInt(1),
- Instructions.discard()
+ Shid.pushInt(1),
+ Shid.discard()
)
);
var context = PatioCodeGenContext.EMPTY;
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceFieldStoreTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceFieldStoreTests.java
index c905d0ce..254249e0 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceFieldStoreTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceFieldStoreTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeCheckerContext;
@@ -21,7 +21,7 @@ public class PatioCodeGenNamespaceFieldStoreTests {
@Test
public void canGenerateCodeForNamespaceFieldStore(Snapshotter snapshotter) throws IOException {
var namespaceName = new NamespaceName(List.of("Example", "Project"));
- var stackIrInstruction = Instructions.namespaceFieldStore(namespaceName, "y");
+ var shidInstruction = Shid.namespaceFieldStore(namespaceName, "y");
var typeInfo = TypeCheckerContext.EMPTY
.addNamespaceTypeInfo(
namespaceName,
@@ -36,7 +36,7 @@ public class PatioCodeGenNamespaceFieldStoreTests {
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIrInstruction, context);
+ var result = PatioCodeGen.generateInstruction(shidInstruction, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceImportTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceImportTests.java
index 705e90dc..f86388cb 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceImportTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceImportTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.types.NamespaceName;
@@ -17,7 +17,7 @@ public class PatioCodeGenNamespaceImportTests {
@Test
public void canGenerateCodeForNamespaceImport(Snapshotter snapshotter) throws IOException {
var namespaceName = new NamespaceName(List.of("Example", "Project"));
- var instruction = Instructions.namespaceImport(namespaceName);
+ var instruction = Shid.namespaceImport(namespaceName);
var context = PatioCodeGenContext.EMPTY;
var result = PatioCodeGen.generateInstruction(instruction, context);
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java
index 2a3154ef..852eda6f 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java
@@ -4,10 +4,10 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.ast.typed.FreeVariables;
import org.shedlang.compiler.sources.Sources;
-import org.shedlang.compiler.stackir.StackIrNamespace;
-import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
-import org.shedlang.compiler.stackir.instructions.Instruction;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.ShidNamespace;
+import org.shedlang.compiler.shid.instructions.ShidDefineFunction;
+import org.shedlang.compiler.shid.instructions.ShidInstruction;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -24,18 +24,18 @@ import static org.shedlang.compiler.patio.PatioTesting.serializeCompilationUnit;
public class PatioCodeGenNamespaceTests {
@Test
public void canDefineNamespace(Snapshotter snapshotter) throws IOException {
- var instruction = new DefineFunctionInstruction(
+ var instruction = new ShidDefineFunction(
"f",
List.of(),
List.of(),
FreeVariables.empty(),
List.of(
- Instructions.pushUnit(),
- Instructions.return_()
+ Shid.pushUnit(),
+ Shid.return_()
),
Sources.NULL
);
- var instructions = List.<Instruction>of(instruction);
+ var instructions = List.<ShidInstruction>of(instruction);
var namespaceName = NamespaceName.of("An","Example");
var typeInfos = TypeInfos.EMPTY
.addNamespaceTypeInfo(
@@ -46,9 +46,9 @@ public class PatioCodeGenNamespaceTests {
.build()
);
var context = PatioCodeGenContext.forTypeInfos(typeInfos);
- var stackIrNamespace = new StackIrNamespace(namespaceName, instructions);
+ var shidNamespace = new ShidNamespace(namespaceName, instructions);
- var result = PatioCodeGen.generateNamespace(stackIrNamespace, context);
+ var result = PatioCodeGen.generateNamespace(shidNamespace, context);
snapshotter.assertSnapshot(serializeCompilationUnit(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java
index 8045decf..4b3c869c 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,20 +14,20 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenPushBoolTests {
@Test
public void pushBoolFalseInstructionGeneratesIntGetZeroInstruction(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.pushBool(false);
+ var shid = Shid.pushBool(false);
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
@Test
public void pushBoolTrueInstructionGeneratesIntGetOneInstruction(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.pushBool(true);
+ var shid = Shid.pushBool(true);
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushIntTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushIntTests.java
index b1790fda..0996f981 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushIntTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushIntTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,10 +14,10 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenPushIntTests {
@Test
public void pushIntInstructionGeneratesIntGetInstruction(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.pushInt(42);
+ var shid = Shid.pushInt(42);
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java
index 28989deb..3a878afe 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,10 +14,10 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenPushStringTests {
@Test
public void pushStringIsCompiledToDataAndIndexToData(Snapshotter snapshotter) throws IOException {
- var stackIrInstruction = Instructions.pushString("hello");
+ var shidInstruction = Shid.pushString("hello");
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(stackIrInstruction, context);
+ var result = PatioCodeGen.generateInstruction(shidInstruction, context);
snapshotter.assertSnapshot(serialize(result));
}
@@ -26,8 +26,8 @@ public class PatioCodeGenPushStringTests {
public void canHaveMultipleStrings(Snapshotter snapshotter) throws IOException {
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(Instructions.pushString("hello"), context);
- result = PatioCodeGen.generateInstruction(Instructions.pushString("world"), result);
+ var result = PatioCodeGen.generateInstruction(Shid.pushString("hello"), context);
+ result = PatioCodeGen.generateInstruction(Shid.pushString("world"), result);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushUnitTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushUnitTests.java
index 3aec3619..d1aa4bd8 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushUnitTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushUnitTests.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -14,10 +14,10 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenPushUnitTests {
@Test
public void pushUnitInstructionGeneratesIntGetInstruction(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.pushUnit();
+ var shid = Shid.pushUnit();
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java
index 5f23b926..57d16015 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,12 +15,12 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenResumeTests {
@Test
public void resumeInstructionGeneratesResumeInstruction(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.resume();
+ var shid = Shid.resume();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenReturnTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenReturnTests.java
index 760f23e8..9a7166c5 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenReturnTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenReturnTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,12 +15,12 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenReturnTests {
@Test
public void returnInstructionGeneratesReturnInstruction(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.return_();
+ var shid = Shid.return_();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java
index 0ff8dade..8eb09cb7 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,13 +15,13 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenStringAddTests {
@Test
public void canGenerateCodeForStringAdd(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.stringAdd();
+ var shid = Shid.stringAdd();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
.temporaryPush(new PatioLocalRef("c"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenSwitchTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenSwitchTests.java
index 979743e3..58463cb4 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenSwitchTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenSwitchTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -23,22 +23,22 @@ public class PatioCodeGenSwitchTests {
var namespaceName = NamespaceName.of("Example", "Project");
var structType1 = Types.struct(namespaceName, "A");
var structType2 = Types.struct(namespaceName, "B");
- var instruction = Instructions.switch_(
+ var instruction = Shid.switch_(
List.of(
- Instructions.switchCase(
+ Shid.switchCase(
structType1,
List.of(
- Instructions.pushInt(1),
- Instructions.pushInt(2),
- Instructions.intAdd()
+ Shid.pushInt(1),
+ Shid.pushInt(2),
+ Shid.intAdd()
)
),
- Instructions.switchCase(
+ Shid.switchCase(
structType2,
List.of(
- Instructions.pushInt(101),
- Instructions.pushInt(102),
- Instructions.intAdd()
+ Shid.pushInt(101),
+ Shid.pushInt(102),
+ Shid.intAdd()
)
)
)
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTryTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTryTests.java
index 1a9535d1..f534534c 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTryTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTryTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
import org.shedlang.compiler.typechecker.TypeCheckerContext;
@@ -20,11 +20,11 @@ public class PatioCodeGenTryTests {
public void canGenerateCodeForTry(Snapshotter snapshotter) throws IOException {
var namespaceName = new NamespaceName(List.of("Example", "Project"));
var effect = Effects.userDefined(namespaceName, "State");
- var stackIrInstruction = Instructions.try_(
+ var shidInstruction = Shid.try_(
effect,
List.of("a", "c", "b"),
List.of(
- Instructions.pushInt(42)
+ Shid.pushInt(42)
)
);
var typeInfos = TypeCheckerContext.EMPTY
@@ -43,7 +43,7 @@ public class PatioCodeGenTryTests {
.temporaryPush(new PatioLocalRef("handlerC"))
.temporaryPush(new PatioLocalRef("handlerB"));
- var result = PatioCodeGen.generateInstruction(stackIrInstruction, context);
+ var result = PatioCodeGen.generateInstruction(shidInstruction, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleCreateTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleCreateTests.java
index e489fb37..d5cb6ef1 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleCreateTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleCreateTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,24 +15,24 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenTupleCreateTests {
@Test
public void canGenerateCodeForTupleCreate(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.tupleCreate(3);
+ var shid = Shid.tupleCreate(3);
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
.temporaryPush(new PatioLocalRef("c"))
.temporaryPush(new PatioLocalRef("d"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
@Test
public void zeroElementTupleIsCreatedWithoutAlloc(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.tupleCreate(0);
+ var shid = Shid.tupleCreate(0);
var context = PatioCodeGenContext.EMPTY;
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java
index fc1cf272..41a037b0 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,12 +15,12 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenTupleGetTests {
@Test
public void canGenerateCodeForTupleGet(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.tupleGet(2, 3);
+ var shid = Shid.tupleGet(2, 3);
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarLoadTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarLoadTests.java
index 4cff0dd4..3eae5cf9 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarLoadTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarLoadTests.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.patio;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.types.PatioTypes;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -15,11 +15,11 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenVarLoadTests {
@Test
public void canGenerateCodeForVarLoad(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.varLoad("x");
+ var shid = Shid.varLoad("x");
var context = PatioCodeGenContext.EMPTY
- .declareStackIrVal("x", PatioTypes.DATA_POINTER).context();
+ .declareShidVal("x", PatioTypes.DATA_POINTER).context();
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarStoreTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarStoreTests.java
index 66038785..4f9d4430 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarStoreTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenVarStoreTests.java
@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
import org.shedlang.compiler.patio.ast.types.PatioTypes;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;
@@ -16,27 +16,27 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
public class PatioCodeGenVarStoreTests {
@Test
public void canGenerateCodeForVarStore(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.varStore("x");
+ var shid = Shid.varStore("x");
var context = PatioCodeGenContext.EMPTY
- .declareStackIrVal("x", PatioTypes.DATA_POINTER).context()
+ .declareShidVal("x", PatioTypes.DATA_POINTER).context()
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
+ var result = PatioCodeGen.generateInstruction(shid, context);
snapshotter.assertSnapshot(serialize(result));
}
@Test
public void canStoreIntoVarMultipleTimes(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.varStore("x");
+ var shid = Shid.varStore("x");
var context = PatioCodeGenContext.EMPTY
- .declareStackIrVal("x", PatioTypes.DATA_POINTER).context()
+ .declareShidVal("x", PatioTypes.DATA_POINTER).context()
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"));
- var result = PatioCodeGen.generateInstruction(stackIr, context);
- result = PatioCodeGen.generateInstruction(stackIr, result);
+ var result = PatioCodeGen.generateInstruction(shid, context);
+ result = PatioCodeGen.generateInstruction(shid, result);
snapshotter.assertSnapshot(serialize(result));
}
diff --git a/src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java b/src/test/java/org/shedlang/compiler/shid/InstructionSerializerTests.java
index c36977cf..9f6bdcf1 100644
--- a/src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/InstructionSerializerTests.java
@@ -1,9 +1,9 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
-import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
-import org.shedlang.compiler.stackir.instructions.Instruction;
-import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.shid.instructions.ShidDefineFunction;
+import org.shedlang.compiler.shid.instructions.ShidInstruction;
+import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.types.Effects;
import org.shedlang.compiler.types.NamespaceName;
import org.shedlang.compiler.types.Types;
@@ -16,7 +16,7 @@ import static org.zwobble.precisely.Matchers.equalTo;
public class InstructionSerializerTests {
@Test
public void canSerializeCall() {
- var instruction = Instructions.call(1, List.of("x", "y"));
+ var instruction = Shid.call(1, List.of("x", "y"));
var string = serialize(instruction);
@@ -25,7 +25,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeDefineEffect() {
- var instruction = Instructions.defineEffect(
+ var instruction = Shid.defineEffect(
Effects.userDefined(NamespaceName.of("Example", "Project"), "State")
);
@@ -38,7 +38,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeDefineFunction() {
- var instruction = DefineFunctionInstruction.builder()
+ var instruction = ShidDefineFunction.builder()
.withName("f")
.addPositionalParam("p1")
.addPositionalParam("p2")
@@ -46,8 +46,8 @@ public class InstructionSerializerTests {
.addNamedParam("n2")
.addFreeVariable("fv1")
.addFreeVariable("fv2")
- .addBodyInstruction(Instructions.pushBool(true))
- .addBodyInstruction(Instructions.pushBool(false))
+ .addBodyInstruction(Shid.pushBool(true))
+ .addBodyInstruction(Shid.pushBool(false))
.build();
var string = serialize(instruction);
@@ -68,11 +68,11 @@ public class InstructionSerializerTests {
@Test
public void canSerializeDefineStruct() {
- var instruction = Instructions.defineStruct(
+ var instruction = Shid.defineStruct(
Types.struct(NamespaceName.of("Example", "Project"), "User"),
List.of(
- Instructions.defineStructField("name"),
- Instructions.defineStructField("id")
+ Shid.defineStructField("name"),
+ Shid.defineStructField("id")
)
);
@@ -88,7 +88,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeDiscard() {
- var instruction = Instructions.discard();
+ var instruction = Shid.discard();
var string = serialize(instruction);
@@ -97,7 +97,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeDuplicate() {
- var instruction = Instructions.duplicate();
+ var instruction = Shid.duplicate();
var string = serialize(instruction);
@@ -106,7 +106,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeNamespaceFieldLoad() {
- var instruction = Instructions.fieldLoad(
+ var instruction = Shid.fieldLoad(
new NamespaceName(List.of("Example", "Lib")),
"x"
);
@@ -118,7 +118,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeStructFieldLoad() {
- var instruction = Instructions.fieldLoad(
+ var instruction = Shid.fieldLoad(
Types.struct(NamespaceName.of("Example", "Project"), "User"),
"name"
);
@@ -130,7 +130,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeUserDefinedEffectFieldLoad() {
- var instruction = Instructions.fieldLoad(
+ var instruction = Shid.fieldLoad(
Effects.userDefined(NamespaceName.of("Example", "Project"), "State"),
"read"
);
@@ -142,15 +142,15 @@ public class InstructionSerializerTests {
@Test
public void canSerializeIf() {
- var instruction = Instructions.if_(
+ var instruction = Shid.if_(
1,
List.of(
- Instructions.pushUnit()
+ Shid.pushUnit()
),
List.of(
- Instructions.localLoad("x"),
- Instructions.discard(),
- Instructions.pushBool(true)
+ Shid.localLoad("x"),
+ Shid.discard(),
+ Shid.pushBool(true)
)
);
@@ -173,7 +173,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeIntAdd() {
- var instruction = Instructions.intAdd();
+ var instruction = Shid.intAdd();
var string = serialize(instruction);
@@ -182,7 +182,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeIntEquals() {
- var instruction = Instructions.intEquals();
+ var instruction = Shid.intEquals();
var string = serialize(instruction);
@@ -191,7 +191,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeIntNotEqual() {
- var instruction = Instructions.intNotEqual();
+ var instruction = Shid.intNotEqual();
var string = serialize(instruction);
@@ -200,7 +200,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeIntSub() {
- var instruction = Instructions.intSub();
+ var instruction = Shid.intSub();
var string = serialize(instruction);
@@ -209,7 +209,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeLocalLoad() {
- var instruction = Instructions.localLoad("x");
+ var instruction = Shid.localLoad("x");
var string = serialize(instruction);
@@ -218,7 +218,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeLocalStore() {
- var instruction = Instructions.localStore("x");
+ var instruction = Shid.localStore("x");
var string = serialize(instruction);
@@ -227,10 +227,10 @@ public class InstructionSerializerTests {
@Test
public void canSerializeLoop() {
- var instruction = Instructions.loop(
+ var instruction = Shid.loop(
List.of(
- Instructions.localLoad("x"),
- Instructions.discard()
+ Shid.localLoad("x"),
+ Shid.discard()
)
);
@@ -248,7 +248,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeLoopBreak() {
- var instruction = Instructions.loopBreak();
+ var instruction = Shid.loopBreak();
var string = serialize(instruction);
@@ -257,7 +257,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeLoopContinue() {
- var instruction = Instructions.loopContinue();
+ var instruction = Shid.loopContinue();
var string = serialize(instruction);
@@ -266,7 +266,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeNamespaceFieldStore() {
- var instruction = Instructions.namespaceFieldStore(
+ var instruction = Shid.namespaceFieldStore(
new NamespaceName(List.of("Example", "Lib")),
"x"
);
@@ -278,7 +278,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeNamespaceImport() {
- var instruction = Instructions.namespaceImport(
+ var instruction = Shid.namespaceImport(
new NamespaceName(List.of("Example", "Lib"))
);
@@ -289,7 +289,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializePushBool() {
- var instruction = Instructions.pushBool(true);
+ var instruction = Shid.pushBool(true);
var string = serialize(instruction);
@@ -298,7 +298,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializePushInt() {
- var instruction = Instructions.pushInt(42);
+ var instruction = Shid.pushInt(42);
var string = serialize(instruction);
@@ -307,7 +307,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializePushString() {
- var instruction = Instructions.pushString("hello");
+ var instruction = Shid.pushString("hello");
var string = serialize(instruction);
@@ -316,7 +316,7 @@ public class InstructionSerializerTests {
@Test
public void specialCharactersInStringAreEscaped() {
- var instruction = Instructions.pushString("\b\t\n\f\r\"\\");
+ var instruction = Shid.pushString("\b\t\n\f\r\"\\");
var string = serialize(instruction);
@@ -325,7 +325,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializePushUnit() {
- var instruction = Instructions.pushUnit();
+ var instruction = Shid.pushUnit();
var string = serialize(instruction);
@@ -334,7 +334,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeResume() {
- var instruction = Instructions.resume();
+ var instruction = Shid.resume();
var string = serialize(instruction);
@@ -343,7 +343,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeReturn() {
- var instruction = Instructions.return_();
+ var instruction = Shid.return_();
var string = serialize(instruction);
@@ -352,7 +352,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeStringAdd() {
- var instruction = Instructions.stringAdd();
+ var instruction = Shid.stringAdd();
var string = serialize(instruction);
@@ -361,17 +361,17 @@ public class InstructionSerializerTests {
@Test
public void canSerializeSwitch() {
- var instruction = Instructions.switch_(List.of(
- Instructions.switchCase(
+ var instruction = Shid.switch_(List.of(
+ Shid.switchCase(
Types.struct(NamespaceName.of("Example", "Project"), "A"),
List.of(
- Instructions.return_()
+ Shid.return_()
)
),
- Instructions.switchCase(
+ Shid.switchCase(
Types.struct(NamespaceName.of("Example", "Project"), "B"),
List.of(
- Instructions.discard()
+ Shid.discard()
)
)
));
@@ -401,11 +401,11 @@ public class InstructionSerializerTests {
@Test
public void canSerializeTry() {
var effect = Effects.userDefined(NamespaceName.of("Example", "Project"), "State");
- var instruction = Instructions.try_(
+ var instruction = Shid.try_(
effect,
List.of("read", "write"),
List.of(
- Instructions.pushUnit()
+ Shid.pushUnit()
)
);
@@ -427,7 +427,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeTupleCreate() {
- var instruction = Instructions.tupleCreate(2);
+ var instruction = Shid.tupleCreate(2);
var string = serialize(instruction);
@@ -436,7 +436,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeTupleGet() {
- var instruction = Instructions.tupleGet(2, 3);
+ var instruction = Shid.tupleGet(2, 3);
var string = serialize(instruction);
@@ -445,7 +445,7 @@ public class InstructionSerializerTests {
@Test
public void canSerializeVarLoad() {
- var instruction = Instructions.varLoad("x");
+ var instruction = Shid.varLoad("x");
var string = serialize(instruction);
@@ -454,14 +454,14 @@ public class InstructionSerializerTests {
@Test
public void canSerializeVarStore() {
- var instruction = Instructions.varStore("x");
+ var instruction = Shid.varStore("x");
var string = serialize(instruction);
assertThat(string, equalTo("(var-store \"x\")"));
}
- private String serialize(Instruction instruction) {
+ private String serialize(ShidInstruction instruction) {
var builder = new StringBuilder();
InstructionSerializer.serializeInstruction(instruction, builder);
return builder.toString();
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerAssignTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenAssignTests.java
index 431556a0..65e30e5a 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerAssignTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenAssignTests.java
@@ -1,25 +1,25 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerAssignTests {
+public class ShidCodeGenAssignTests {
@Test
public void targetIgnoreIsCompiledToDiscard() {
var node = Typed.assign(
Typed.targetIgnore(),
Typed.reference("x")
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("x__0"),
@@ -33,10 +33,10 @@ public class StackCompilerAssignTests {
Typed.targetReassign("x"),
Typed.stringLiteral("hello")
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
@@ -54,13 +54,13 @@ public class StackCompilerAssignTests {
)),
Typed.reference("x")
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x")
.addShedVal("a")
.addShedVal("b")
.addShedVal("c");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("x__0"),
@@ -81,10 +81,10 @@ public class StackCompilerAssignTests {
Typed.targetTuple(List.of()),
Typed.reference("x")
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("x__0"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerBlockReturnTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenBlockReturnTests.java
index df738405..082560b7 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerBlockReturnTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenBlockReturnTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushStringInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushStringInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerBlockReturnTests {
+public class ShidCodeGenBlockReturnTests {
@Test
public void expressionIsEvaluated() {
var node = Typed.blockReturn(Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello")
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerBoolLiteralTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenBoolLiteralTests.java
index ac96c48e..965f9b3c 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerBoolLiteralTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenBoolLiteralTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushBoolInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushBoolInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerBoolLiteralTests {
+public class ShidCodeGenBoolLiteralTests {
@Test
public void boolLiteralIsCompiledToPushBoolInstruction() {
var node = Typed.boolLiteral(true);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushBoolInstruction(true)
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerCallTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenCallTests.java
index 2cf25bb1..5d14cc31 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerCallTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenCallTests.java
@@ -1,15 +1,15 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerCallTests {
+public class ShidCodeGenCallTests {
@Test
public void callIsCompiledToInstructionsForOperandThenCall() {
var node = Typed.call(
@@ -24,10 +24,10 @@ public class StackCompilerCallTests {
Typed.namedArg("x1", Typed.stringLiteral("n1"))
)
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("f");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("f__0"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerEffectDefinitionTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenEffectDefinitionTests.java
index 051c03e4..4777f5a7 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerEffectDefinitionTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenEffectDefinitionTests.java
@@ -1,28 +1,28 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import org.shedlang.compiler.stackir.instructions.DefineEffectInstruction;
+import org.shedlang.compiler.shid.instructions.ShidDefineEffect;
import org.shedlang.compiler.types.Effects;
import org.shedlang.compiler.types.NamespaceName;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isLocalStoreInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isLocalStoreInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
-public class StackCompilerEffectDefinitionTests {
+public class ShidCodeGenEffectDefinitionTests {
@Test
public void effectDefinitionIsCompiledToDefineEffectInstruction() {
var effect = Effects.userDefined(NamespaceName.of("Example", "Project"), "State");
var node = Typed.effectDefinition(effect);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("State");
- var result = StackCompiler.compileNamespaceStatement(node, context);
+ var result = ShidCodeGen.compileNamespaceStatement(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineEffectInstruction.class,
+ ShidDefineEffect.class,
has("effect", x -> x.effect(), equalTo(effect))
),
isLocalStoreInstruction("State__0")
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerExpressionStatementTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenExpressionStatementTests.java
index f644408b..05a47d39 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerExpressionStatementTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenExpressionStatementTests.java
@@ -1,20 +1,20 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isDiscardInstruction;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushStringInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isDiscardInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushStringInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerExpressionStatementTests {
+public class ShidCodeGenExpressionStatementTests {
@Test
public void expressionIsEvaluatedAndTheResultDiscarded() {
var node = Typed.expressionStatement(Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFieldAccessTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFieldAccessTests.java
index 4c0821a6..0e869445 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFieldAccessTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFieldAccessTests.java
@@ -1,18 +1,18 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import org.shedlang.compiler.stackir.instructions.FieldLoadInstruction;
+import org.shedlang.compiler.shid.instructions.ShidFieldLoad;
import org.shedlang.compiler.types.Effects;
import org.shedlang.compiler.types.NamespaceName;
import org.shedlang.compiler.types.Types;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isFieldLoadInstruction;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isLocalLoadInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isFieldLoadInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isLocalLoadInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerFieldAccessTests {
+public class ShidCodeGenFieldAccessTests {
@Test
public void namespaceFieldAccessIsCompiledToFieldLoad() {
var namespaceType = Types.namespace(NamespaceName.of("Example", "Project"));
@@ -21,15 +21,15 @@ public class StackCompilerFieldAccessTests {
"name",
Types.STRING
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("Project");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("Project__0"),
isFieldLoadInstruction(
- new FieldLoadInstruction.Receiver.Namespace(namespaceType.namespaceName()),
+ new ShidFieldLoad.Receiver.Namespace(namespaceType.namespaceName()),
"name"
)
));
@@ -43,10 +43,10 @@ public class StackCompilerFieldAccessTests {
"name",
Types.STRING
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("user");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("user__0"),
@@ -62,15 +62,15 @@ public class StackCompilerFieldAccessTests {
"read",
Types.STRING
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("State");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("State__0"),
isFieldLoadInstruction(
- new FieldLoadInstruction.Receiver.Effect(effect),
+ new ShidFieldLoad.Receiver.Effect(effect),
"read"
)
));
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionDefinitionTests.java
index d28a3eb5..0f6a3835 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionDefinitionTests.java
@@ -1,16 +1,16 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import org.shedlang.compiler.ast.typed.TypedFunctionDefinitionNode;
-import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
+import org.shedlang.compiler.shid.instructions.ShidDefineFunction;
import org.shedlang.compiler.types.Types;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
-public class StackCompilerFunctionDefinitionTests {
+public class ShidCodeGenFunctionDefinitionTests {
@Test
public void functionIsCompiledToDefineFunctionInstruction() {
var node = TypedFunctionDefinitionNode.builder()
@@ -20,15 +20,15 @@ public class StackCompilerFunctionDefinitionTests {
.addFreeVariable("z")
.addStatement(Typed.expressionStatement(Typed.stringLiteral("hello")))
.build();
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("f")
.addShedVal("z");
- var result = StackCompiler.compileNamespaceStatement(node, context);
+ var result = ShidCodeGen.compileNamespaceStatement(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("name", x -> x.name(), equalTo("f")),
has("positionalParams", x -> x.positionalParams(), isSequence(
isDefineFunctionInstructionParam("x__0")
@@ -56,14 +56,14 @@ public class StackCompilerFunctionDefinitionTests {
.withName("f")
.addStatement(Typed.blockReturn(Typed.stringLiteral("hello")))
.build();
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("f");
- var result = StackCompiler.compileNamespaceStatement(node, context);
+ var result = ShidCodeGen.compileNamespaceStatement(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("body", x -> x.body(), isSequence(
isPushStringInstruction("hello"),
isReturnInstruction()
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionExpressionTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionExpressionTests.java
index d14356f7..c5f78340 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionExpressionTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionExpressionTests.java
@@ -1,16 +1,16 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import org.shedlang.compiler.ast.typed.TypedFunctionExpressionNode;
-import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
+import org.shedlang.compiler.shid.instructions.ShidDefineFunction;
import org.shedlang.compiler.types.Types;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
-public class StackCompilerFunctionExpressionTests {
+public class ShidCodeGenFunctionExpressionTests {
@Test
public void functionIsCompiledToDefineFunctionInstruction() {
var node = TypedFunctionExpressionNode.builder()
@@ -19,15 +19,15 @@ public class StackCompilerFunctionExpressionTests {
.addFreeVariable("z")
.addStatement(Typed.expressionStatement(Typed.stringLiteral("hello")))
.build();
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("f")
.addShedVal("z");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("name", x -> x.name(), equalTo("anonymous")),
has("positionalParams", x -> x.positionalParams(), isSequence(
isDefineFunctionInstructionParam("x__0")
@@ -53,14 +53,14 @@ public class StackCompilerFunctionExpressionTests {
var node = TypedFunctionExpressionNode.builder()
.addStatement(Typed.blockReturn(Typed.stringLiteral("hello")))
.build();
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("f");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("body", x -> x.body(), isSequence(
isPushStringInstruction("hello"),
isReturnInstruction()
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionReturnTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionReturnTests.java
index 8bd5c64d..d6a63c1f 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionReturnTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenFunctionReturnTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerFunctionReturnTests {
+public class ShidCodeGenFunctionReturnTests {
@Test
public void expressionIsEvaluatedAndReturned() {
var node = Typed.functionReturn(Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIfTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIfTests.java
index dca0be02..f1f81e95 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIfTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIfTests.java
@@ -1,4 +1,4 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
@@ -6,11 +6,11 @@ import org.shedlang.compiler.types.Types;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerIfTests {
+public class ShidCodeGenIfTests {
@Test
public void ifWithSingleConditionalBranchIsCompiledToSingleIfInstruction() {
var node = Typed.if_(
@@ -27,10 +27,10 @@ public class StackCompilerIfTests {
)),
Types.INT
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("c");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("c__0"),
@@ -68,11 +68,11 @@ public class StackCompilerIfTests {
)),
Types.INT
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("c")
.addShedVal("d");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("c__0"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntAddTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntAddTests.java
index 4724b867..4ff0e6eb 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntAddTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntAddTests.java
@@ -1,23 +1,23 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isIntAddInstruction;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushIntInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isIntAddInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushIntInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerIntAddTests {
+public class ShidCodeGenIntAddTests {
@Test
public void intAddIsCompiledToIntAddInstruction() {
var node = Typed.intAdd(
Typed.intLiteral(42),
Typed.intLiteral(47)
);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushIntInstruction(42),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntEqualsTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntEqualsTests.java
index 61eb93f9..464e73f4 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntEqualsTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntEqualsTests.java
@@ -1,22 +1,22 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerIntEqualsTests {
+public class ShidCodeGenIntEqualsTests {
@Test
public void intEqualsIsCompiledToIntEqualsInstruction() {
var node = Typed.intEquals(
Typed.intLiteral(42),
Typed.intLiteral(47)
);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushIntInstruction(42),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntLiteralTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntLiteralTests.java
index 402c6dac..ed95e765 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntLiteralTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntLiteralTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushIntInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushIntInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerIntLiteralTests {
+public class ShidCodeGenIntLiteralTests {
@Test
public void intLiteralIsCompiledToPushIntInstruction() {
var node = Typed.intLiteral(42);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushIntInstruction(42)
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntNotEqualTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntNotEqualTests.java
index 8364bc81..9c55f222 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntNotEqualTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntNotEqualTests.java
@@ -1,22 +1,22 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerIntNotEqualTests {
+public class ShidCodeGenIntNotEqualTests {
@Test
public void intNotEqualsIsCompiledToIntNotEqualInstruction() {
var node = Typed.intNotEqual(
Typed.intLiteral(42),
Typed.intLiteral(47)
);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushIntInstruction(42),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntSubTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntSubTests.java
index 110be63a..df3e9791 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerIntSubTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenIntSubTests.java
@@ -1,22 +1,22 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerIntSubTests {
+public class ShidCodeGenIntSubTests {
@Test
public void intSubIsCompiledToIntSubInstruction() {
var node = Typed.intSub(
Typed.intLiteral(42),
Typed.intLiteral(47)
);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushIntInstruction(42),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenNamespaceTests.java
index 322bf49f..f56ba972 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenNamespaceTests.java
@@ -1,18 +1,18 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.*;
-import org.shedlang.compiler.stackir.instructions.*;
+import org.shedlang.compiler.shid.instructions.*;
import org.shedlang.compiler.types.NamespaceName;
import org.shedlang.compiler.types.Types;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
-public class StackCompilerNamespaceTests {
+public class ShidCodeGenNamespaceTests {
@Test
public void bodyOfNamespaceIsCompiledWithNamesBeingExported() {
var namespaceName = new NamespaceName(List.of("Example"));
@@ -31,16 +31,16 @@ public class StackCompilerNamespaceTests {
List.of("f")
);
- var stackIrNamespace = StackCompiler.compileNamespace(node);
+ var shidNamespace = ShidCodeGen.compileNamespace(node);
- assertThat(stackIrNamespace.instructions(), isSequence(
+ assertThat(shidNamespace.instructions(), isSequence(
// TODO: test the builtin loading properly
- instanceOf(NamespaceImportInstruction.class),
- instanceOf(FieldLoadInstruction.class),
- instanceOf(LocalStoreInstruction.class),
+ instanceOf(ShidNamespaceImport.class),
+ instanceOf(ShidFieldLoad.class),
+ instanceOf(ShidLocalStore.class),
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("name", x -> x.name(), equalTo("f"))
),
isLocalStoreInstruction("f__0"),
@@ -58,13 +58,13 @@ public class StackCompilerNamespaceTests {
.addBoundVariable(BoundVariable.immutable("B"))
.build();
- var stackIrNamespace = StackCompiler.compileNamespace(node);
+ var shidNamespace = ShidCodeGen.compileNamespace(node);
- assertThat(stackIrNamespace.instructions(), isSequence(
+ assertThat(shidNamespace.instructions(), isSequence(
// TODO: test the builtin loading properly
- instanceOf(NamespaceImportInstruction.class),
- instanceOf(FieldLoadInstruction.class),
- instanceOf(LocalStoreInstruction.class),
+ instanceOf(ShidNamespaceImport.class),
+ instanceOf(ShidFieldLoad.class),
+ instanceOf(ShidLocalStore.class),
isNamespaceImportInstruction(NamespaceName.of("A")),
isLocalStoreInstruction("A__0"),
@@ -91,21 +91,21 @@ public class StackCompilerNamespaceTests {
List.of("f", "None")
);
- var stackIrNamespace = StackCompiler.compileNamespace(node);
+ var shidNamespace = ShidCodeGen.compileNamespace(node);
- assertThat(stackIrNamespace.instructions(), isSequence(
+ assertThat(shidNamespace.instructions(), isSequence(
// TODO: test the builtin loading properly
- instanceOf(NamespaceImportInstruction.class),
- instanceOf(FieldLoadInstruction.class),
- instanceOf(LocalStoreInstruction.class),
+ instanceOf(ShidNamespaceImport.class),
+ instanceOf(ShidFieldLoad.class),
+ instanceOf(ShidLocalStore.class),
instanceOf(
- DefineStructInstruction.class,
+ ShidDefineStruct.class,
has("type", x -> x.type(), equalTo(structType))
),
isLocalStoreInstruction("None__0"),
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("name", x -> x.name(), equalTo("f"))
),
isLocalStoreInstruction("f__0"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerReferenceTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenReferenceTests.java
index 038351c4..2a30266b 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerReferenceTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenReferenceTests.java
@@ -1,21 +1,21 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.BoundVariable;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerReferenceTests {
+public class ShidCodeGenReferenceTests {
@Test
public void referenceIsCompiledToLocalLoad() {
var node = Typed.reference("x");
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVariable(BoundVariable.immutable("x"));
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("x__0")
@@ -25,14 +25,14 @@ public class StackCompilerReferenceTests {
@Test
public void whenLocalIsVarThenReferenceIsCompiledToVarLoad() {
var node = Typed.reference("x");
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVariable(BoundVariable.mutable("x"));
- context = StackCompiler.compileFunctionStatement(
+ context = ShidCodeGen.compileFunctionStatement(
Typed.var("x", Typed.intLiteral(0)),
context
);
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushIntInstruction(0),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerResumeTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenResumeTests.java
index 8ee1f909..6992783d 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerResumeTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenResumeTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerResumeTests {
+public class ShidCodeGenResumeTests {
@Test
public void expressionIsEvaluatedAndReturned() {
var node = Typed.resume(Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerStringAddTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenStringAddTests.java
index 42557970..56b2750e 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerStringAddTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenStringAddTests.java
@@ -1,22 +1,22 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerStringAddTests {
+public class ShidCodeGenStringAddTests {
@Test
public void stringAddIsCompiledToStringAddInstruction() {
var node = Typed.stringAdd(
Typed.stringLiteral("a"),
Typed.stringLiteral("b")
);
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("a"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerStringLiteralTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenStringLiteralTests.java
index 44133713..b308c300 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerStringLiteralTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenStringLiteralTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushStringInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushStringInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerStringLiteralTests {
+public class ShidCodeGenStringLiteralTests {
@Test
public void stringLiteralIsCompiledToPushStringInstruction() {
var node = Typed.stringLiteral("hello");
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello")
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerStructDefinitionTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenStructDefinitionTests.java
index 6dc845bd..4e989e9b 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerStructDefinitionTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenStructDefinitionTests.java
@@ -1,17 +1,17 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import org.shedlang.compiler.ast.typed.TypedStructDefinitionNode;
-import org.shedlang.compiler.stackir.instructions.DefineStructInstruction;
+import org.shedlang.compiler.shid.instructions.ShidDefineStruct;
import org.shedlang.compiler.types.NamespaceName;
import org.shedlang.compiler.types.Types;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isLocalStoreInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isLocalStoreInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
-public class StackCompilerStructDefinitionTests {
+public class ShidCodeGenStructDefinitionTests {
@Test
public void structDefinitionIsCompiledToDefineStructInstruction() {
var structType = Types.struct(NamespaceName.of("Example", "Project"), "User");
@@ -20,14 +20,14 @@ public class StackCompilerStructDefinitionTests {
.addField(Typed.structFieldDefinition("name", Typed.typeLevelReference("String", Types.STRING)))
.addField(Typed.structFieldDefinition("isActive", Typed.typeLevelReference("Bool", Types.BOOL)))
.build();
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("User");
- var result = StackCompiler.compileNamespaceStatement(node, context);
+ var result = ShidCodeGen.compileNamespaceStatement(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineStructInstruction.class,
+ ShidDefineStruct.class,
has("type", x -> x.type(), equalTo(structType)),
has("fields", x -> x.fields(), isSequence(
has("name", x -> x.name(), equalTo("name")),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerSumTypeDefinitionTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenSumTypeDefinitionTests.java
index 849e2df7..74521d29 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerSumTypeDefinitionTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenSumTypeDefinitionTests.java
@@ -1,26 +1,26 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import org.shedlang.compiler.types.NamespaceName;
import org.shedlang.compiler.types.Types;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isLocalStoreInstruction;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushUnitInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isLocalStoreInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushUnitInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerSumTypeDefinitionTests {
+public class ShidCodeGenSumTypeDefinitionTests {
@Test
public void sumTypeDefinitionIsCompiledToUnit() {
// TODO: this is a bit of a hack, we probably want to be able to have
// sum types in some potential backends (e.g. the JVM)
var sumType = Types.sum(NamespaceName.of("Example", "Project"), "Option");
var node = Typed.sumTypeDefinition(sumType);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("Option");
- var result = StackCompiler.compileNamespaceStatement(node, context);
+ var result = ShidCodeGen.compileNamespaceStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushUnitInstruction(),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerTryTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenTryTests.java
index f4e87f8f..daff19b0 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerTryTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenTryTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import org.shedlang.compiler.ast.typed.TypedTryHandlerMethodNode;
import org.shedlang.compiler.ast.typed.TypedTryNode;
-import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
-import org.shedlang.compiler.stackir.instructions.TryInstruction;
+import org.shedlang.compiler.shid.instructions.ShidDefineFunction;
+import org.shedlang.compiler.shid.instructions.ShidTry;
import org.shedlang.compiler.types.Effects;
import org.shedlang.compiler.types.NamespaceName;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushIntInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushIntInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
-public class StackCompilerTryTests {
+public class ShidCodeGenTryTests {
@Test
public void tryNodeIsCompiledToTryInstruction() {
var effect = Effects.userDefined(NamespaceName.of("Example"), "State");
@@ -33,22 +33,22 @@ public class StackCompilerTryTests {
.build()
)
.build();
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("c");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("name", x -> x.name(), equalTo("read"))
),
instanceOf(
- DefineFunctionInstruction.class,
+ ShidDefineFunction.class,
has("name", x -> x.name(), equalTo("write"))
),
instanceOf(
- TryInstruction.class,
+ ShidTry.class,
has("handledEffect", x -> x.handledEffect(), equalTo(effect)),
has("handlerMethodNames", x -> x.handlerMethodNames(), isSequence(
equalTo("read"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerTupleTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenTupleTests.java
index f05e9257..c3194182 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerTupleTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenTupleTests.java
@@ -1,15 +1,15 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerTupleTests {
+public class ShidCodeGenTupleTests {
@Test
public void stringAddIsCompiledToStringAddInstruction() {
var node = Typed.tuple(List.of(
@@ -17,9 +17,9 @@ public class StackCompilerTupleTests {
Typed.boolLiteral(true),
Typed.intLiteral(4)
));
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("a"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerUnitLiteralTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenUnitLiteralTests.java
index 024b9561..27b7ed6c 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerUnitLiteralTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenUnitLiteralTests.java
@@ -1,19 +1,19 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.isPushUnitInstruction;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.isPushUnitInstruction;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerUnitLiteralTests {
+public class ShidCodeGenUnitLiteralTests {
@Test
public void unitLiteralIsCompiledToPushUnitInstruction() {
var node = Typed.unitLiteral();
- var context = StackCompiler.Context.EMPTY;
+ var context = ShidCodeGen.Context.EMPTY;
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isPushUnitInstruction()
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenValTests.java
index 2e6194ca..5007e1e8 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenValTests.java
@@ -1,4 +1,4 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.BoundVariable;
@@ -7,18 +7,18 @@ import org.shedlang.compiler.types.Types;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerValTests {
+public class ShidCodeGenValTests {
@Test
public void whenValIsFunctionStatementThenExpressionIsEvaluatedAndStoredAsLocal() {
var node = Typed.val("x", Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
@@ -29,10 +29,10 @@ public class StackCompilerValTests {
@Test
public void whenValIsNamespaceStatementThenExpressionIsEvaluatedAndStoredAsLocal() {
var node = Typed.val("x", Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileNamespaceStatement(node, context);
+ var result = ShidCodeGen.compileNamespaceStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
@@ -69,11 +69,11 @@ public class StackCompilerValTests {
)),
Typed.expressionStatement(Typed.reference("x"))
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
for (var node : nodes) {
- context = StackCompiler.compileFunctionStatement(node, context);
+ context = ShidCodeGen.compileFunctionStatement(node, context);
}
assertThat(context.instructions(), isSequence(
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerVarTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenVarTests.java
index 7df00442..a1e264ad 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerVarTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenVarTests.java
@@ -1,20 +1,20 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerVarTests {
+public class ShidCodeGenVarTests {
@Test
public void expressionIsEvaluatedAndStoredAsVar() {
var node = Typed.var("x", Typed.stringLiteral("hello"));
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isPushStringInstruction("hello"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerWhenTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenWhenTests.java
index d19eb525..f3e2880c 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerWhenTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenWhenTests.java
@@ -1,4 +1,4 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
@@ -7,11 +7,11 @@ import org.shedlang.compiler.types.Types;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerWhenTests {
+public class ShidCodeGenWhenTests {
private final static NamespaceName NAMESPACE_NAME = NamespaceName.of("Example", "Project");
@Test
@@ -34,10 +34,10 @@ public class StackCompilerWhenTests {
),
Types.STRING
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
- var result = StackCompiler.compileExpression(node, context);
+ var result = ShidCodeGen.compileExpression(node, context);
assertThat(result.instructions(), isSequence(
isLocalLoadInstruction("x__0"),
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerWhileTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenWhileTests.java
index 006c0b4c..1ab5240a 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerWhileTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenWhileTests.java
@@ -1,15 +1,15 @@
-package org.shedlang.compiler.stackir;
+package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import java.util.List;
-import static org.shedlang.compiler.stackir.instructions.InstructionMatchers.*;
+import static org.shedlang.compiler.shid.instructions.InstructionMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
-public class StackCompilerWhileTests {
+public class ShidCodeGenWhileTests {
@Test
public void whileIsCompiledToLoop() {
var node = Typed.while_(
@@ -18,10 +18,10 @@ public class StackCompilerWhileTests {
Typed.expressionStatement(Typed.intLiteral(42))
))
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("c");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isLoopInstruction(
@@ -51,10 +51,10 @@ public class StackCompilerWhileTests {
Typed.blockReturn(Typed.intLiteral(42))
))
);
- var context = StackCompiler.Context.EMPTY
+ var context = ShidCodeGen.Context.EMPTY
.addShedVal("c");
- var result = StackCompiler.compileFunctionStatement(node, context);
+ var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isLoopInstruction(
diff --git a/src/test/java/org/shedlang/compiler/shid/instructions/InstructionMatchers.java b/src/test/java/org/shedlang/compiler/shid/instructions/InstructionMatchers.java
new file mode 100644
index 00000000..c7c89825
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/shid/instructions/InstructionMatchers.java
@@ -0,0 +1,229 @@
+package org.shedlang.compiler.shid.instructions;
+
+import org.shedlang.compiler.types.NamespaceName;
+import org.shedlang.compiler.types.StructType;
+import org.zwobble.precisely.Matcher;
+
+import java.math.BigInteger;
+import java.util.List;
+
+import static org.zwobble.precisely.Matchers.*;
+
+public class InstructionMatchers {
+ private InstructionMatchers() {
+ }
+
+ public static Matcher<ShidInstruction> isCallInstruction(
+ int positionalArgCount,
+ List<String> namedArgNames
+ ) {
+ return instanceOf(
+ ShidCall.class,
+ has("positionalArgCount", x -> x.positionalArgCount(), equalTo(positionalArgCount)),
+ has("namedArgNames", x -> x.namedArgNames(), equalTo(namedArgNames))
+ );
+ }
+
+ public static Matcher<ShidDefineFunction.Param> isDefineFunctionInstructionParam(String name) {
+ return has("name", x -> x.name(), equalTo(name));
+ }
+
+ public static Matcher<ShidInstruction> isDiscardInstruction() {
+ return instanceOf(
+ ShidDiscard.class
+ );
+ }
+
+ public static Matcher<ShidInstruction> isDuplicateInstruction() {
+ return instanceOf(ShidDuplicate.class);
+ }
+
+ public static Matcher<ShidInstruction> isFieldLoadInstruction(
+ ShidFieldLoad.Receiver receiver,
+ String fieldName
+ ) {
+ return instanceOf(
+ ShidFieldLoad.class,
+ has("receiver", x -> x.receiver(), equalTo(receiver)),
+ has("fieldName", x -> x.fieldName(), equalTo(fieldName))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isFieldLoadInstruction(
+ StructType receiverType,
+ String fieldName
+ ) {
+ return isFieldLoadInstruction(
+ new ShidFieldLoad.Receiver.Struct(receiverType),
+ fieldName
+ );
+ }
+
+ public static Matcher<ShidInstruction> isIfInstruction(
+ Matcher<Iterable<? extends ShidInstruction>> trueBody,
+ Matcher<Iterable<? extends ShidInstruction>> falseBody
+ ) {
+ return instanceOf(
+ ShidIf.class,
+ has("trueBody", x -> x.trueBody(), trueBody),
+ has("falseBody", x -> x.falseBody(), falseBody)
+ );
+ }
+
+ public static Matcher<ShidInstruction> isIntAddInstruction() {
+ return instanceOf(ShidIntAdd.class);
+ }
+
+ public static Matcher<ShidInstruction> isIntEqualsInstruction() {
+ return instanceOf(ShidIntEquals.class);
+ }
+
+ public static Matcher<ShidInstruction> isIntNotEqualInstruction() {
+ return instanceOf(ShidIntNotEqual.class);
+ }
+
+ public static Matcher<ShidInstruction> isIntSubInstruction() {
+ return instanceOf(ShidIntSub.class);
+ }
+
+ public static Matcher<ShidInstruction> isLocalLoadInstruction(String name) {
+ return instanceOf(
+ ShidLocalLoad.class,
+ has("name", x -> x.name(), equalTo(name))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isLocalStoreInstruction(String name) {
+ return instanceOf(
+ ShidLocalStore.class,
+ has("name", x -> x.name(), equalTo(name))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isLoopInstruction(
+ Matcher<Iterable<? extends ShidInstruction>> body
+ ) {
+ return instanceOf(
+ ShidLoop.class,
+ has("body", x -> x.body(), body)
+ );
+ }
+
+ public static Matcher<ShidInstruction> isLoopBreakInstruction() {
+ return instanceOf(ShidLoopBreak.class);
+ }
+
+ public static Matcher<ShidInstruction> isLoopContinueInstruction() {
+ return instanceOf(ShidLoopContinue.class);
+ }
+
+ public static Matcher<ShidInstruction> isNamespaceFieldStoreInstruction(
+ NamespaceName namespaceName,
+ String fieldName
+ ) {
+ return instanceOf(
+ ShidNamespaceFieldStore.class,
+ has("namespaceName", x -> x.namespaceName(), equalTo(namespaceName)),
+ has("fieldName", x -> x.fieldName(), equalTo(fieldName))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isNamespaceImportInstruction(
+ NamespaceName namespaceName
+ ) {
+ return instanceOf(
+ ShidNamespaceImport.class,
+ has("namespaceName", x -> x.namespaceName(), equalTo(namespaceName))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isPushBoolInstruction(boolean value) {
+ return instanceOf(
+ ShidPushBool.class,
+ has("value", x -> x.value(), equalTo(value))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isPushIntInstruction(int value) {
+ return instanceOf(
+ ShidPushInt.class,
+ has("value", x -> x.value(), equalTo(BigInteger.valueOf(value)))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isPushStringInstruction(String value) {
+ return instanceOf(
+ ShidPushString.class,
+ has("value", x -> x.value(), equalTo(value))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isPushUnitInstruction() {
+ return instanceOf(
+ ShidPushUnit.class
+ );
+ }
+
+ public static Matcher<ShidInstruction> isResumeInstruction() {
+ return instanceOf(
+ ShidResume.class
+ );
+ }
+
+ public static Matcher<ShidInstruction> isReturnInstruction() {
+ return instanceOf(
+ ShidReturn.class
+ );
+ }
+
+ public static Matcher<ShidInstruction> isStringAddInstruction() {
+ return instanceOf(ShidStringAdd.class);
+ }
+
+ public static Matcher<ShidInstruction> isSwitchInstruction(
+ Matcher<Iterable<? extends ShidSwitch.Case>> cases
+ ) {
+ return instanceOf(
+ ShidSwitch.class,
+ has("cases", x -> x.cases(), cases)
+ );
+ }
+
+ public static Matcher<ShidSwitch.Case> isSwitchInstructionCase(
+ StructType caseType,
+ Matcher<Iterable<? extends ShidInstruction>> body
+ ) {
+ return allOf(
+ has("caseType", x -> x.caseType(), equalTo(caseType)),
+ has("body", x -> x.body(), body)
+ );
+ }
+
+ public static Matcher<ShidInstruction> isTupleCreateInstruction(int elementCount) {
+ return instanceOf(
+ ShidTupleCreate.class,
+ has("elementCount", x -> x.elementCount(), equalTo(elementCount))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isTupleGetInstruction(int elementIndex) {
+ return instanceOf(
+ ShidTupleGet.class,
+ has("elementIndex", x -> x.elementIndex(), equalTo(elementIndex))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isVarLoadInstruction(String name) {
+ return instanceOf(
+ ShidVarLoad.class,
+ has("name", x -> x.name(), equalTo(name))
+ );
+ }
+
+ public static Matcher<ShidInstruction> isVarStoreInstruction(String name) {
+ return instanceOf(
+ ShidVarStore.class,
+ has("name", x -> x.name(), equalTo(name))
+ );
+ }
+}
diff --git a/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java b/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java
new file mode 100644
index 00000000..cd8e41fd
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java
@@ -0,0 +1,193 @@
+package org.shedlang.compiler.shid.instructions;
+
+import org.shedlang.compiler.sources.Sources;
+import org.shedlang.compiler.types.NamespaceName;
+import org.shedlang.compiler.types.StructType;
+import org.shedlang.compiler.types.UserDefinedEffect;
+
+import java.math.BigInteger;
+import java.util.List;
+
+public class Shid {
+ private Shid() {
+ }
+
+ public static ShidInstruction call(int positionalArgCount, List<String> namedArgNames) {
+ return new ShidCall(positionalArgCount, namedArgNames, Sources.NULL);
+ }
+
+ public static ShidInstruction defineEffect(UserDefinedEffect effect) {
+ return new ShidDefineEffect(effect, Sources.NULL);
+ }
+
+ public static ShidInstruction defineStruct(
+ StructType type,
+ List<ShidDefineStruct.Field> fields
+ ) {
+ return new ShidDefineStruct(
+ type,
+ fields,
+ Sources.NULL
+ );
+ }
+
+ public static ShidDefineStruct.Field defineStructField(String name) {
+ return new ShidDefineStruct.Field(name, Sources.NULL);
+ }
+
+ public static ShidInstruction discard() {
+ return new ShidDiscard(Sources.NULL);
+ }
+
+ public static ShidInstruction duplicate() {
+ return new ShidDuplicate(Sources.NULL);
+ }
+
+ public static ShidInstruction fieldLoad(NamespaceName namespaceName, String fieldName) {
+ return new ShidFieldLoad(
+ new ShidFieldLoad.Receiver.Namespace(namespaceName),
+ fieldName,
+ Sources.NULL
+ );
+ }
+
+ public static ShidInstruction fieldLoad(StructType type, String fieldName) {
+ return new ShidFieldLoad(
+ new ShidFieldLoad.Receiver.Struct(type),
+ fieldName,
+ Sources.NULL
+ );
+ }
+
+ public static ShidInstruction fieldLoad(UserDefinedEffect effect, String fieldName) {
+ return new ShidFieldLoad(
+ new ShidFieldLoad.Receiver.Effect(effect),
+ fieldName,
+ Sources.NULL
+ );
+ }
+
+ public static ShidInstruction if_(
+ int resultCount,
+ List<ShidInstruction> trueBody,
+ List<ShidInstruction> falseBody
+ ) {
+ return new ShidIf(resultCount, trueBody, falseBody, Sources.NULL);
+ }
+
+ public static ShidInstruction intAdd() {
+ return new ShidIntAdd(Sources.NULL);
+ }
+
+ public static ShidInstruction intEquals() {
+ return new ShidIntEquals(Sources.NULL);
+ }
+
+ public static ShidInstruction intNotEqual() {
+ return new ShidIntNotEqual(Sources.NULL);
+ }
+
+ public static ShidInstruction intSub() {
+ return new ShidIntSub(Sources.NULL);
+ }
+
+ public static ShidInstruction localLoad(String name) {
+ return new ShidLocalLoad(name, Sources.NULL);
+ }
+
+ public static ShidInstruction localStore(String name) {
+ return new ShidLocalStore(name, Sources.NULL);
+ }
+
+ public static ShidInstruction loop(List<ShidInstruction> body) {
+ return new ShidLoop(body, Sources.NULL);
+ }
+
+ public static ShidInstruction loopBreak() {
+ return new ShidLoopBreak(Sources.NULL);
+ }
+
+ public static ShidInstruction loopContinue() {
+ return new ShidLoopContinue(Sources.NULL);
+ }
+
+ public static ShidInstruction namespaceFieldStore(NamespaceName namespaceName, String fieldName) {
+ return new ShidNamespaceFieldStore(namespaceName, fieldName, Sources.NULL);
+ }
+
+ public static ShidInstruction namespaceImport(NamespaceName namespaceName) {
+ return new ShidNamespaceImport(namespaceName, Sources.NULL);
+ }
+
+ public static ShidDefineFunction.Param param(String name) {
+ return new ShidDefineFunction.Param(name, Sources.NULL);
+ }
+
+ public static ShidInstruction pushBool(boolean value) {
+ return new ShidPushBool(value, Sources.NULL);
+ }
+
+ public static ShidInstruction pushInt(int value) {
+ return new ShidPushInt(BigInteger.valueOf(value), Sources.NULL);
+ }
+
+ public static ShidInstruction pushString(String value) {
+ return new ShidPushString(value, Sources.NULL);
+ }
+
+ public static ShidInstruction pushUnit() {
+ return new ShidPushUnit(Sources.NULL);
+ }
+
+ public static ShidInstruction resume() {
+ return new ShidResume(Sources.NULL);
+ }
+
+ public static ShidInstruction return_() {
+ return new ShidReturn(Sources.NULL);
+ }
+
+ public static ShidInstruction stringAdd() {
+ return new ShidStringAdd(Sources.NULL);
+ }
+
+ public static ShidInstruction switch_(List<ShidSwitch.Case> cases) {
+ return new ShidSwitch(cases, Sources.NULL);
+ }
+
+ public static ShidSwitch.Case switchCase(
+ StructType type,
+ List<ShidInstruction> body
+ ) {
+ return new ShidSwitch.Case(type, body, Sources.NULL);
+ }
+
+ public static ShidInstruction try_(
+ UserDefinedEffect handledEffect,
+ List<String> handlerMethodNames,
+ List<ShidInstruction> body
+ ) {
+ return new ShidTry(
+ handledEffect,
+ handlerMethodNames,
+ body,
+ Sources.NULL
+ );
+ }
+
+ public static ShidInstruction tupleCreate(int elementCount) {
+ return new ShidTupleCreate(elementCount, Sources.NULL);
+ }
+
+ public static ShidInstruction tupleGet(int elementIndex, int elementCount) {
+ return new ShidTupleGet(elementIndex, elementCount, Sources.NULL);
+ }
+
+ public static ShidInstruction varLoad(String name) {
+ return new ShidVarLoad(name, Sources.NULL);
+ }
+
+ public static ShidInstruction varStore(String name) {
+ return new ShidVarStore(name, Sources.NULL);
+ }
+}
diff --git a/src/test/java/org/shedlang/compiler/stackir/instructions/InstructionMatchers.java b/src/test/java/org/shedlang/compiler/stackir/instructions/InstructionMatchers.java
deleted file mode 100644
index 34c94f0e..00000000
--- a/src/test/java/org/shedlang/compiler/stackir/instructions/InstructionMatchers.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package org.shedlang.compiler.stackir.instructions;
-
-import org.shedlang.compiler.types.NamespaceName;
-import org.shedlang.compiler.types.StructType;
-import org.zwobble.precisely.Matcher;
-
-import java.math.BigInteger;
-import java.util.List;
-
-import static org.zwobble.precisely.Matchers.*;
-
-public class InstructionMatchers {
- private InstructionMatchers() {
- }
-
- public static Matcher<Instruction> isCallInstruction(
- int positionalArgCount,
- List<String> namedArgNames
- ) {
- return instanceOf(
- CallInstruction.class,
- has("positionalArgCount", x -> x.positionalArgCount(), equalTo(positionalArgCount)),
- has("namedArgNames", x -> x.namedArgNames(), equalTo(namedArgNames))
- );
- }
-
- public static Matcher<DefineFunctionInstruction.Param> isDefineFunctionInstructionParam(String name) {
- return has("name", x -> x.name(), equalTo(name));
- }
-
- public static Matcher<Instruction> isDiscardInstruction() {
- return instanceOf(
- DiscardInstruction.class
- );
- }
-
- public static Matcher<Instruction> isDuplicateInstruction() {
- return instanceOf(DuplicateInstruction.class);
- }
-
- public static Matcher<Instruction> isFieldLoadInstruction(
- FieldLoadInstruction.Receiver receiver,
- String fieldName
- ) {
- return instanceOf(
- FieldLoadInstruction.class,
- has("receiver", x -> x.receiver(), equalTo(receiver)),
- has("fieldName", x -> x.fieldName(), equalTo(fieldName))
- );
- }
-
- public static Matcher<Instruction> isFieldLoadInstruction(
- StructType receiverType,
- String fieldName
- ) {
- return isFieldLoadInstruction(
- new FieldLoadInstruction.Receiver.Struct(receiverType),
- fieldName
- );
- }
-
- public static Matcher<Instruction> isIfInstruction(
- Matcher<Iterable<? extends Instruction>> trueBody,
- Matcher<Iterable<? extends Instruction>> falseBody
- ) {
- return instanceOf(
- IfInstruction.class,
- has("trueBody", x -> x.trueBody(), trueBody),
- has("falseBody", x -> x.falseBody(), falseBody)
- );
- }
-
- public static Matcher<Instruction> isIntAddInstruction() {
- return instanceOf(IntAddInstruction.class);
- }
-
- public static Matcher<Instruction> isIntEqualsInstruction() {
- return instanceOf(IntEqualsInstruction.class);
- }
-
- public static Matcher<Instruction> isIntNotEqualInstruction() {
- return instanceOf(IntNotEqualInstruction.class);
- }
-
- public static Matcher<Instruction> isIntSubInstruction() {
- return instanceOf(IntSubInstruction.class);
- }
-
- public static Matcher<Instruction> isLocalLoadInstruction(String name) {
- return instanceOf(
- LocalLoadInstruction.class,
- has("name", x -> x.name(), equalTo(name))
- );
- }
-
- public static Matcher<Instruction> isLocalStoreInstruction(String name) {
- return instanceOf(
- LocalStoreInstruction.class,
- has("name", x -> x.name(), equalTo(name))
- );
- }
-
- public static Matcher<Instruction> isLoopInstruction(
- Matcher<Iterable<? extends Instruction>> body
- ) {
- return instanceOf(
- LoopInstruction.class,
- has("body", x -> x.body(), body)
- );
- }
-
- public static Matcher<Instruction> isLoopBreakInstruction() {
- return instanceOf(LoopBreakInstruction.class);
- }
-
- public static Matcher<Instruction> isLoopContinueInstruction() {
- return instanceOf(LoopContinueInstruction.class);
- }
-
- public static Matcher<Instruction> isNamespaceFieldStoreInstruction(
- NamespaceName namespaceName,
- String fieldName
- ) {
- return instanceOf(
- NamespaceFieldStoreInstruction.class,
- has("namespaceName", x -> x.namespaceName(), equalTo(namespaceName)),
- has("fieldName", x -> x.fieldName(), equalTo(fieldName))
- );
- }
-
- public static Matcher<Instruction> isNamespaceImportInstruction(
- NamespaceName namespaceName
- ) {
- return instanceOf(
- NamespaceImportInstruction.class,
- has("namespaceName", x -> x.namespaceName(), equalTo(namespaceName))
- );
- }
-
- public static Matcher<Instruction> isPushBoolInstruction(boolean value) {
- return instanceOf(
- PushBoolInstruction.class,
- has("value", x -> x.value(), equalTo(value))
- );
- }
-
- public static Matcher<Instruction> isPushIntInstruction(int value) {
- return instanceOf(
- PushIntInstruction.class,
- has("value", x -> x.value(), equalTo(BigInteger.valueOf(value)))
- );
- }
-
- public static Matcher<Instruction> isPushStringInstruction(String value) {
- return instanceOf(
- PushStringInstruction.class,
- has("value", x -> x.value(), equalTo(value))
- );
- }
-
- public static Matcher<Instruction> isPushUnitInstruction() {
- return instanceOf(
- PushUnitInstruction.class
- );
- }
-
- public static Matcher<Instruction> isResumeInstruction() {
- return instanceOf(
- ResumeInstruction.class
- );
- }
-
- public static Matcher<Instruction> isReturnInstruction() {
- return instanceOf(
- ReturnInstruction.class
- );
- }
-
- public static Matcher<Instruction> isStringAddInstruction() {
- return instanceOf(StringAddInstruction.class);
- }
-
- public static Matcher<Instruction> isSwitchInstruction(
- Matcher<Iterable<? extends SwitchInstruction.Case>> cases
- ) {
- return instanceOf(
- SwitchInstruction.class,
- has("cases", x -> x.cases(), cases)
- );
- }
-
- public static Matcher<SwitchInstruction.Case> isSwitchInstructionCase(
- StructType caseType,
- Matcher<Iterable<? extends Instruction>> body
- ) {
- return allOf(
- has("caseType", x -> x.caseType(), equalTo(caseType)),
- has("body", x -> x.body(), body)
- );
- }
-
- public static Matcher<Instruction> isTupleCreateInstruction(int elementCount) {
- return instanceOf(
- TupleCreateInstruction.class,
- has("elementCount", x -> x.elementCount(), equalTo(elementCount))
- );
- }
-
- public static Matcher<Instruction> isTupleGetInstruction(int elementIndex) {
- return instanceOf(
- TupleGetInstruction.class,
- has("elementIndex", x -> x.elementIndex(), equalTo(elementIndex))
- );
- }
-
- public static Matcher<Instruction> isVarLoadInstruction(String name) {
- return instanceOf(
- VarLoadInstruction.class,
- has("name", x -> x.name(), equalTo(name))
- );
- }
-
- public static Matcher<Instruction> isVarStoreInstruction(String name) {
- return instanceOf(
- VarStoreInstruction.class,
- has("name", x -> x.name(), equalTo(name))
- );
- }
-}
diff --git a/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java b/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java
deleted file mode 100644
index ce6ebf37..00000000
--- a/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package org.shedlang.compiler.stackir.instructions;
-
-import org.shedlang.compiler.sources.Sources;
-import org.shedlang.compiler.types.NamespaceName;
-import org.shedlang.compiler.types.StructType;
-import org.shedlang.compiler.types.UserDefinedEffect;
-
-import java.math.BigInteger;
-import java.util.List;
-
-public class Instructions {
- private Instructions() {
- }
-
- public static Instruction call(int positionalArgCount, List<String> namedArgNames) {
- return new CallInstruction(positionalArgCount, namedArgNames, Sources.NULL);
- }
-
- public static Instruction defineEffect(UserDefinedEffect effect) {
- return new DefineEffectInstruction(effect, Sources.NULL);
- }
-
- public static Instruction defineStruct(
- StructType type,
- List<DefineStructInstruction.Field> fields
- ) {
- return new DefineStructInstruction(
- type,
- fields,
- Sources.NULL
- );
- }
-
- public static DefineStructInstruction.Field defineStructField(String name) {
- return new DefineStructInstruction.Field(name, Sources.NULL);
- }
-
- public static Instruction discard() {
- return new DiscardInstruction(Sources.NULL);
- }
-
- public static Instruction duplicate() {
- return new DuplicateInstruction(Sources.NULL);
- }
-
- public static Instruction fieldLoad(NamespaceName namespaceName, String fieldName) {
- return new FieldLoadInstruction(
- new FieldLoadInstruction.Receiver.Namespace(namespaceName),
- fieldName,
- Sources.NULL
- );
- }
-
- public static Instruction fieldLoad(StructType type, String fieldName) {
- return new FieldLoadInstruction(
- new FieldLoadInstruction.Receiver.Struct(type),
- fieldName,
- Sources.NULL
- );
- }
-
- public static Instruction fieldLoad(UserDefinedEffect effect, String fieldName) {
- return new FieldLoadInstruction(
- new FieldLoadInstruction.Receiver.Effect(effect),
- fieldName,
- Sources.NULL
- );
- }
-
- public static Instruction if_(
- int resultCount,
- List<Instruction> trueBody,
- List<Instruction> falseBody
- ) {
- return new IfInstruction(resultCount, trueBody, falseBody, Sources.NULL);
- }
-
- public static Instruction intAdd() {
- return new IntAddInstruction(Sources.NULL);
- }
-
- public static Instruction intEquals() {
- return new IntEqualsInstruction(Sources.NULL);
- }
-
- public static Instruction intNotEqual() {
- return new IntNotEqualInstruction(Sources.NULL);
- }
-
- public static Instruction intSub() {
- return new IntSubInstruction(Sources.NULL);
- }
-
- public static Instruction localLoad(String name) {
- return new LocalLoadInstruction(name, Sources.NULL);
- }
-
- public static Instruction localStore(String name) {
- return new LocalStoreInstruction(name, Sources.NULL);
- }
-
- public static Instruction loop(List<Instruction> body) {
- return new LoopInstruction(body, Sources.NULL);
- }
-
- public static Instruction loopBreak() {
- return new LoopBreakInstruction(Sources.NULL);
- }
-
- public static Instruction loopContinue() {
- return new LoopContinueInstruction(Sources.NULL);
- }
-
- public static Instruction namespaceFieldStore(NamespaceName namespaceName, String fieldName) {
- return new NamespaceFieldStoreInstruction(namespaceName, fieldName, Sources.NULL);
- }
-
- public static Instruction namespaceImport(NamespaceName namespaceName) {
- return new NamespaceImportInstruction(namespaceName, Sources.NULL);
- }
-
- public static DefineFunctionInstruction.Param param(String name) {
- return new DefineFunctionInstruction.Param(name, Sources.NULL);
- }
-
- public static Instruction pushBool(boolean value) {
- return new PushBoolInstruction(value, Sources.NULL);
- }
-
- public static Instruction pushInt(int value) {
- return new PushIntInstruction(BigInteger.valueOf(value), Sources.NULL);
- }
-
- public static Instruction pushString(String value) {
- return new PushStringInstruction(value, Sources.NULL);
- }
-
- public static Instruction pushUnit() {
- return new PushUnitInstruction(Sources.NULL);
- }
-
- public static Instruction resume() {
- return new ResumeInstruction(Sources.NULL);
- }
-
- public static Instruction return_() {
- return new ReturnInstruction(Sources.NULL);
- }
-
- public static Instruction stringAdd() {
- return new StringAddInstruction(Sources.NULL);
- }
-
- public static Instruction switch_(List<SwitchInstruction.Case> cases) {
- return new SwitchInstruction(cases, Sources.NULL);
- }
-
- public static SwitchInstruction.Case switchCase(
- StructType type,
- List<Instruction> body
- ) {
- return new SwitchInstruction.Case(type, body, Sources.NULL);
- }
-
- public static Instruction try_(
- UserDefinedEffect handledEffect,
- List<String> handlerMethodNames,
- List<Instruction> body
- ) {
- return new TryInstruction(
- handledEffect,
- handlerMethodNames,
- body,
- Sources.NULL
- );
- }
-
- public static Instruction tupleCreate(int elementCount) {
- return new TupleCreateInstruction(elementCount, Sources.NULL);
- }
-
- public static Instruction tupleGet(int elementIndex, int elementCount) {
- return new TupleGetInstruction(elementIndex, elementCount, Sources.NULL);
- }
-
- public static Instruction varLoad(String name) {
- return new VarLoadInstruction(name, Sources.NULL);
- }
-
- public static Instruction varStore(String name) {
- return new VarStoreInstruction(name, Sources.NULL);
- }
-}