diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-16 12:46:58 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-16 12:46:58 +0000 |
| commit | 811a0571c1f616d3c27fe2fff929ffdc2bbc4f55 (patch) | |
| tree | 8e966b8e67ea37b0c7a9db0000d54f3e2f9115f4 /src/main/java | |
| parent | a22fbc506d196a01d8ecbadba8f9708b6fbb6d4f (diff) | |
Push cast into alloc()
Diffstat (limited to 'src/main/java')
3 files changed, 16 insertions, 28 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java index 9f5bfdaf..e96914fa 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java @@ -3,10 +3,7 @@ package org.shedlang.compiler.patio; import org.pcollections.PVector; import org.shedlang.compiler.ast.typed.FreeVariable; import org.shedlang.compiler.ast.typed.FreeVariables; -import org.shedlang.compiler.patio.ast.instructions.PatioCallPointer; -import org.shedlang.compiler.patio.ast.instructions.PatioIntToDataPtr; -import org.shedlang.compiler.patio.ast.instructions.PatioMemoryLoad; -import org.shedlang.compiler.patio.ast.instructions.PatioMemoryStore; +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.operands.PatioOperand; @@ -82,7 +79,8 @@ class PatioCodeGenClosures { return bodyContext; } - static PatioCodeGenResult<PatioLocalRef> alloc( + static PatioCodeGenContext alloc( + PatioLocalRef target, String name, String functionName, PatioDataLayout layout, @@ -119,7 +117,13 @@ class PatioCodeGenClosures { context ); - return context.toResult(closurePointer); + context = context.addInstruction(new PatioDataPtrToInt( + target, + closurePointer, + source + )); + + return context; } static PatioCodeGenContext storeFreeVariables( diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java index 28e1ec0f..f8df4e1b 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java @@ -436,7 +436,8 @@ public class PatioCodeGenEffects { context = getCurrentEffectHandler(effectHandler, source, context); - var closurePointerResult = PatioCodeGenClosures.alloc( + context = PatioCodeGenClosures.alloc( + target, name, fullName, layout, @@ -452,16 +453,6 @@ public class PatioCodeGenEffects { source, context ); - var closurePointer = closurePointerResult.value(); - context = closurePointerResult.context(); - - - - context = context.addInstruction(new PatioDataPtrToInt( - target, - closurePointer, - source - )); return context; } diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java index ffa58156..bbcd4db5 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java @@ -2,7 +2,6 @@ package org.shedlang.compiler.patio; import org.shedlang.compiler.ast.typed.FreeVariables; import org.shedlang.compiler.patio.ast.PatioVisibility; -import org.shedlang.compiler.patio.ast.instructions.PatioDataPtrToInt; import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; import org.shedlang.compiler.patio.ast.types.PatioDataLayout; import org.shedlang.compiler.patio.ast.types.PatioDataLayouts; @@ -12,7 +11,8 @@ import org.shedlang.compiler.sources.Source; import java.util.List; import java.util.function.Function; -import static org.shedlang.compiler.patio.PatioCodeGenClosures.*; +import static org.shedlang.compiler.patio.PatioCodeGenClosures.defineParams; +import static org.shedlang.compiler.patio.PatioCodeGenClosures.loadFreeVariables; public class PatioCodeGenFunctions { private PatioCodeGenFunctions() { @@ -73,7 +73,8 @@ public class PatioCodeGenFunctions { return bodyContext; }); - var closurePointerResult = PatioCodeGenClosures.alloc( + context = PatioCodeGenClosures.alloc( + target, name, fullName, layout, @@ -82,14 +83,6 @@ public class PatioCodeGenFunctions { source, context ); - var closurePointer = closurePointerResult.value(); - context = closurePointerResult.context(); - - context = context.addInstruction(new PatioDataPtrToInt( - target, - closurePointer, - source - )); return context; } |
