From 811a0571c1f616d3c27fe2fff929ffdc2bbc4f55 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 16 Dec 2023 12:46:58 +0000 Subject: Push cast into alloc() --- .../shedlang/compiler/patio/PatioCodeGenClosures.java | 16 ++++++++++------ .../org/shedlang/compiler/patio/PatioCodeGenEffects.java | 13 ++----------- .../shedlang/compiler/patio/PatioCodeGenFunctions.java | 15 ++++----------- 3 files changed, 16 insertions(+), 28 deletions(-) (limited to 'src/main/java') 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 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; } -- cgit v1.2.3