From 4da8acf8d927bb1a99ef96b617d9da7680ff37cf Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 16 Dec 2023 12:29:07 +0000 Subject: Store free variables in alloc() --- .../java/org/shedlang/compiler/patio/PatioCodeGenClosures.java | 9 +++++++++ .../java/org/shedlang/compiler/patio/PatioCodeGenEffects.java | 9 +-------- .../java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java | 9 +-------- 3 files changed, 11 insertions(+), 16 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 69434491..923a2fb1 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java @@ -83,6 +83,7 @@ class PatioCodeGenClosures { String name, String functionName, Layout layout, + FreeVariables freeVariables, Source source, PatioCodeGenContext context ) { @@ -104,6 +105,14 @@ class PatioCodeGenClosures { source )); + context = storeFreeVariables( + freeVariables, + closurePointer, + layout, + source, + context + ); + return context.toResult(closurePointer); } diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java index c4a74f09..c0a24507 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java @@ -430,6 +430,7 @@ public class PatioCodeGenEffects { name, fullName, layout, + freeVariables, source, context ); @@ -453,14 +454,6 @@ public class PatioCodeGenEffects { source )); - context = storeFreeVariables( - freeVariables, - closurePointer, - layout, - source, - context - ); - context = context.addInstruction(new PatioDataPtrToInt( target, closurePointer, diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java index 217ac701..cb2b8808 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java @@ -71,6 +71,7 @@ public class PatioCodeGenFunctions { name, fullName, layout, + freeVariables, source, context ); @@ -83,14 +84,6 @@ public class PatioCodeGenFunctions { source )); - context = storeFreeVariables( - freeVariables, - closurePointer, - layout, - source, - context - ); - return context; } } -- cgit v1.2.3