diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-20 23:54:50 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-20 23:54:59 +0100 |
| commit | e1a05af93d777252cd59012f1ee7e9b47191b5ea (patch) | |
| tree | 91039bf3b0060e7cb7e53fe89554b72f8c02ce05 /src/main/java | |
| parent | a1c86fe89a5e2b049f81745b0666887766826dd6 (diff) | |
Remove function-pointer-get instruction
Diffstat (limited to 'src/main/java')
4 files changed, 3 insertions, 32 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java index 2374ed2c..1a191134 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java @@ -3,6 +3,7 @@ package org.shedlang.compiler.patio; import org.shedlang.compiler.ast.typed.FreeVariable; import org.shedlang.compiler.ast.typed.FreeVariables; import org.shedlang.compiler.patio.ast.instructions.*; +import org.shedlang.compiler.patio.ast.operands.PatioFunctionPtr; import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; import org.shedlang.compiler.patio.ast.types.PatioDataLayout; import org.shedlang.compiler.patio.ast.types.PatioStruct; @@ -111,24 +112,11 @@ class PatioCodeGenClosures { context = context.addInstruction(new PatioAlloc(closurePointer, layout, source)); - var functionPointerResult = context.allocateLocal( - PatioCodeGenLocalSpace.CLOSURE_FUNCTION_POINTER, - PatioTypes.FUNCTION_POINTER - ); - var functionPointer = functionPointerResult.value(); - context = functionPointerResult.context(); - - context = context.addInstruction(new PatioFunctionPointerGet( - functionPointer, - fullName, - source - )); - context = context.addInstruction(new PatioMemoryStore( closurePointer, layout, FUNCTION_POINTER_OFFSET, - functionPointer, + new PatioFunctionPtr(fullName), source )); 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 523ac805..867b3663 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -192,13 +192,6 @@ public class PatioSerializer { treeNamed("value", operandToTree(memoryStore.value())) ); - case PatioFunctionPointerGet functionPointerGet -> - treeList( - treeIdentifier("function-pointer-get"), - operandToTree(functionPointerGet.target()), - treeString(functionPointerGet.name()) - ); - case PatioReturn return_ -> treeList( treeIdentifier("return"), diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java deleted file mode 100644 index 694b8da6..00000000 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.shedlang.compiler.patio.ast.instructions; - -import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; -import org.shedlang.compiler.sources.Source; - -/** - * Store a pointer to the function with the given name in the target local. - */ -public record PatioFunctionPointerGet(PatioLocalRef target, String name, Source source) implements PatioInstruction { -} 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 339f6d5f..eb9e5ea5 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 PatioAlloc, PatioCallPointer, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIf, PatioIntAdd, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioReturn { +public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrToInt, PatioIf, PatioIntAdd, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioReturn { Source source(); } |
