From 7f05f10981e0483f8a4817a7509b2dd5f27923e9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Jul 2023 14:47:06 +0100 Subject: Store free variables in closure --- .../shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java | 8 ++++++-- .../org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java index ac510295..4f09ff3b 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java @@ -49,7 +49,9 @@ public class PatioCodeGenDefineFunctionTests { ), Sources.NULL ); - var context = PatioCodeGenContext.EMPTY; + var context = PatioCodeGenContext.EMPTY + .addStackIrLocal("a").context() + .addStackIrLocal("b").context(); var result = PatioCodeGen.generateInstruction(instruction, context); @@ -73,7 +75,9 @@ public class PatioCodeGenDefineFunctionTests { ), Sources.NULL ); - var context = PatioCodeGenContext.EMPTY; + var context = PatioCodeGenContext.EMPTY + .addStackIrLocal("a").context() + .addStackIrLocal("b").context(); var result = PatioCodeGen.generateInstruction(instruction, context); diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java index 8ad1ba64..643c6d72 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenLocalLoadTests.java @@ -15,7 +15,8 @@ public class PatioCodeGenLocalLoadTests { @Test public void localLoadPushesLocalOntoStack(Snapshotter snapshotter) throws IOException { var stackIr = Instructions.localLoad("x"); - var context = PatioCodeGenContext.EMPTY; + var context = PatioCodeGenContext.EMPTY + .addStackIrLocal("x").context(); var result = PatioCodeGen.generateInstruction(stackIr, context); -- cgit v1.2.3