aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-20 15:20:11 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-20 15:20:11 +0100
commit70882baa0eb2cecf83089ffcdf540976186c5e67 (patch)
tree5c066598cfb618b92d5dab646e9c21378452d185 /src/main/java
parentb3276afec7498c7ec6e100d7367e748fdf0a3923 (diff)
Convert closure value to closure pointer before call
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java2
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java17
2 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
index ffa8a74e..db00aea8 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
@@ -72,7 +72,7 @@ public class PatioCodeGen {
var receiverResult = context.allocateLocal(
PatioCodeGenLocalSpace.RECEIVER,
- PatioCodeGenClosures.CLOSURE_POINTER_TYPE
+ PatioCodeGenTypes.VALUE_TYPE
);
var receiver = receiverResult.value();
context = receiverResult.context();
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
index 9f9487b2..29136b20 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
@@ -157,6 +157,19 @@ class PatioCodeGenClosures {
Source source,
PatioCodeGenContext context
) {
+ var closurePointerResult = context.allocateLocal(
+ PatioCodeGenLocalSpace.CLOSURE_POINTER,
+ CLOSURE_POINTER_TYPE
+ );
+ var closurePointer = closurePointerResult.value();
+ context = closurePointerResult.context();
+
+ context = context.addInstruction(new PatioIntToDataPtr(
+ closurePointer,
+ closure,
+ source
+ ));
+
var functionPointerResult = context.allocateLocal(
PatioCodeGenLocalSpace.CALL_FUNCTION_POINTER,
PatioTypes.FUNCTION_POINTER
@@ -166,7 +179,7 @@ class PatioCodeGenClosures {
context = context.addInstruction(new PatioMemoryLoad(
functionPointer,
- closure,
+ closurePointer,
closureDataLayoutForCall(),
FUNCTION_POINTER_OFFSET,
source
@@ -174,7 +187,7 @@ class PatioCodeGenClosures {
var args = new ArrayList<PatioLocalRef>();
- args.add(closure);
+ args.add(closurePointer);
args.addAll(positionalArgs);