diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-15 10:20:04 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-15 10:20:04 +0000 |
| commit | e48644920ff6b5e785be9c03665b781629f5995d (patch) | |
| tree | ce42733fe4202e5cc391919a4e8f7036f001e69d /src/main/java | |
| parent | 7e3d270e09b5e313ba8d4bd518a1ed96fac89758 (diff) | |
Store temporaries as operands
Diffstat (limited to 'src/main/java')
6 files changed, 15 insertions, 13 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java index a6f9c975..ae645a95 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java @@ -778,8 +778,8 @@ public class PatioCodeGen { interface BinaryOperationCodeGen { PatioCodeGenContext generate( PatioLocalRef target, - PatioLocalRef left, - PatioLocalRef right, + PatioOperand left, + PatioOperand right, PatioCodeGenContext context ); } diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java index 5dcd91eb..f2e881e9 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java @@ -182,7 +182,7 @@ public record PatioCodeGenContext( } public record FunctionContext( - PStack<PatioLocalRef> temporaryStack, + PStack<PatioOperand> temporaryStack, PVector<PatioInstruction> instructions, OrderedPMap<String, PatioLocal> localsByName, PMap<String, PatioLocalRef> shidNameToLocal, @@ -199,7 +199,7 @@ public record PatioCodeGenContext( ); @CheckReturnValue - public Result<PatioLocalRef> temporaryPop() { + public Result<PatioOperand> temporaryPop() { return new FunctionContext( this.temporaryStack.minus(0), this.instructions, @@ -211,7 +211,7 @@ public record PatioCodeGenContext( } @CheckReturnValue - public FunctionContext temporaryPush(PatioLocalRef value) { + public FunctionContext temporaryPush(PatioOperand value) { return new FunctionContext( this.temporaryStack.plus(value), this.instructions, @@ -474,7 +474,7 @@ public record PatioCodeGenContext( } @CheckReturnValue - public PatioCodeGenResult<PatioLocalRef> temporaryPop() { + public PatioCodeGenResult<PatioOperand> temporaryPop() { var result = this.functionContext.temporaryPop(); return withFunctionContextResult(result); @@ -489,7 +489,7 @@ public record PatioCodeGenContext( } @CheckReturnValue - public PatioCodeGenContext temporaryPush(PatioLocalRef value) { + public PatioCodeGenContext temporaryPush(PatioOperand value) { var result = this.functionContext.temporaryPush(value); return withFunctionContext(result); diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java index 1a740cdd..17244e25 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java @@ -236,7 +236,7 @@ public class PatioCodeGenEffects { public static PatioCodeGenContext fieldLoad( PatioLocalRef target, - PatioLocalRef receiver, + PatioOperand receiver, UserDefinedEffect effect, String fieldName, Source source, diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java index 8441fe21..8bbf4e8b 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java @@ -167,7 +167,7 @@ public class PatioCodeGenNamespaces { public static PatioCodeGenContext fieldLoad( PatioLocalRef target, - PatioLocalRef receiver, + PatioOperand receiver, NamespaceName namespaceName, String fieldName, Source source, diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java index e0f99d0e..a0d11ca7 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java @@ -6,6 +6,7 @@ import org.shedlang.compiler.patio.ast.PatioLocal; import org.shedlang.compiler.patio.ast.instructions.PatioCall; import org.shedlang.compiler.patio.ast.operands.PatioDataPtr; import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; +import org.shedlang.compiler.patio.ast.operands.PatioOperand; import org.shedlang.compiler.patio.ast.types.PatioDataLayouts; import org.shedlang.compiler.patio.ast.types.PatioDataValue; import org.shedlang.compiler.patio.ast.types.PatioDataValues; @@ -64,8 +65,8 @@ public class PatioCodeGenStrings { public static PatioCodeGenContext add( PatioLocalRef target, - PatioLocalRef left, - PatioLocalRef right, + PatioOperand left, + PatioOperand right, Source source, PatioCodeGenContext context ) { diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java index b0505d69..04aa7be8 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java @@ -4,6 +4,7 @@ import org.shedlang.compiler.ast.typed.FreeVariables; import org.shedlang.compiler.patio.ast.instructions.*; import org.shedlang.compiler.patio.ast.operands.PatioInt; import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; +import org.shedlang.compiler.patio.ast.operands.PatioOperand; import org.shedlang.compiler.patio.ast.types.PatioDataLayout; import org.shedlang.compiler.patio.ast.types.PatioDataLayouts; import org.shedlang.compiler.patio.ast.types.PatioTypes; @@ -97,7 +98,7 @@ public class PatioCodeGenStructs { public static PatioCodeGenContext fieldLoad( PatioLocalRef target, - PatioLocalRef receiver, + PatioOperand receiver, StructType type, String fieldName, Source source, @@ -134,7 +135,7 @@ public class PatioCodeGenStructs { public static PatioCodeGenContext tagLoad( PatioLocalRef target, - PatioLocalRef receiver, + PatioOperand receiver, Source source, PatioCodeGenContext context ) { |
