diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-15 11:11:59 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-15 11:12:15 +0000 |
| commit | 1dc868ca96048bb9ddbd58b3c74ed965a4e7103a (patch) | |
| tree | b6d91e113a2fd505a3d740762feeecfe248825ff /src/main/java | |
| parent | adeacfc83f2d25d6c056efd0b79e9411f2e5c460 (diff) | |
Mark Patio block as an instruction
Diffstat (limited to 'src/main/java')
5 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/org/shedlang/compiler/backends/llvm/codegen/LlvmPatioCodeGen.java b/src/main/java/org/shedlang/compiler/backends/llvm/codegen/LlvmPatioCodeGen.java index 20c2680a..b388818b 100644 --- a/src/main/java/org/shedlang/compiler/backends/llvm/codegen/LlvmPatioCodeGen.java +++ b/src/main/java/org/shedlang/compiler/backends/llvm/codegen/LlvmPatioCodeGen.java @@ -269,6 +269,9 @@ public class LlvmPatioCodeGen { )); } + case PatioBlock patioBlock -> + throw new UnsupportedOperationException("TODO"); + case PatioBoolToInt patioBoolToInt -> { var targetResult = context.addPatioLocalToLlvmLocal(patioBoolToInt.target()); var target = targetResult.value(); diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGen.java b/src/main/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGen.java index 8d9e4453..90e2261d 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGen.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGen.java @@ -153,6 +153,9 @@ public class WasmPatioCodeGen { yield context; } + case PatioBlock patioBlock -> + throw new UnsupportedOperationException("TODO"); + case PatioBoolToInt patioBoolToInt -> generateOperandToPatioLocal( patioBoolToInt.target(), diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java index fcb9fd52..3e4fb96a 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -154,6 +154,9 @@ public class PatioSerializer { dataLayoutToTree(allocStack.layout()) ); + case PatioBlock block -> + blockToTree(block); + case PatioBoolToInt boolToInt -> treeList( treeIdentifier("bool-to-int"), diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBlock.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBlock.java index 21c2c218..4fd8d2c5 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBlock.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBlock.java @@ -6,11 +6,16 @@ import org.shedlang.compiler.util.Lists; import java.util.List; +/** + * Execute the instructions in the body of the block. The results may be used in + * the parent scope, but any other variables (as distinct from values) are no + * longer in use. + */ public record PatioBlock( List<PatioInstruction> body, List<? extends PatioOperand> results, Source source -) { +) implements PatioInstruction { public PatioBlock addInstruction(PatioInstruction instruction) { return new PatioBlock( Lists.concat(this.body, List.of(instruction)), diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java index b2a0a8ad..202948ea 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java @@ -2,6 +2,6 @@ package org.shedlang.compiler.patio.ast.instructions; import org.shedlang.compiler.sources.Source; -public sealed interface PatioInstruction permits PatioAllocHeap, PatioAllocStack, PatioBoolToInt, PatioCall, PatioCallPointer, PatioDataPtrToInt, PatioIf, PatioIntAdd, PatioIntEquals, PatioIntNotEqual, PatioIntSub, PatioIntToBool, PatioIntToDataPtr, PatioLocalStore, PatioLoop, PatioLoopBreak, PatioLoopContinue, PatioMemoryLoad, PatioMemoryStore, PatioResume, PatioReturn, PatioReturnVoid, PatioSwitch, PatioThrow, PatioTry, PatioUnreachable, PatioVarLoad, PatioVarStore { +public sealed interface PatioInstruction permits PatioAllocHeap, PatioAllocStack, PatioBlock, PatioBoolToInt, PatioCall, PatioCallPointer, PatioDataPtrToInt, PatioIf, PatioIntAdd, PatioIntEquals, PatioIntNotEqual, PatioIntSub, PatioIntToBool, PatioIntToDataPtr, PatioLocalStore, PatioLoop, PatioLoopBreak, PatioLoopContinue, PatioMemoryLoad, PatioMemoryStore, PatioResume, PatioReturn, PatioReturnVoid, PatioSwitch, PatioThrow, PatioTry, PatioUnreachable, PatioVarLoad, PatioVarStore { Source source(); } |
