summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/unit-testing/merge.fate102
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java8
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterContext.java4
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterManager.java5
4 files changed, 69 insertions, 50 deletions
diff --git a/data/unit-testing/merge.fate b/data/unit-testing/merge.fate
index 2d71db8..184a9f3 100644
--- a/data/unit-testing/merge.fate
+++ b/data/unit-testing/merge.fate
@@ -170,49 +170,55 @@
(set! si2
(set:merge
- (lambda
- (
- (int a)
- (int b)
- (int mod)
+ (partial
+ (lambda
+ (
+ (int mod)
+ (int a)
+ (int b)
+ )
+ (* (- b a) mod)
)
- (* (- b a) mod)
+ -1
)
(list:range 0 60 2)
(list:range 10 40 1)
- -1
)
)
(set! si2oa
(set:merge
- (lambda
- (
- (int a)
- (int b)
- (int mod)
+ (partial
+ (lambda
+ (
+ (int mod)
+ (int a)
+ (int b)
+ )
+ (* (- b a) mod)
)
- (* (- b a) mod)
+ -1
)
(list:range 0 60 2)
(list:range 10 80 1)
- -1
)
)
(set! si2ob
(set:merge
- (lambda
- (
- (int a)
- (int b)
- (int mod)
+ (partial
+ (lambda
+ (
+ (int mod)
+ (int a)
+ (int b)
+ )
+ (* (- b a) mod)
)
- (* (- b a) mod)
+ -1
)
(list:range 0 80 2)
(list:range 10 40 1)
- -1
)
)
@@ -417,52 +423,58 @@ For reference, the values found in the sets are:
(set! isi2
(set:indexed_merge
- (lambda
- (
- (int i)
- (int a)
- (int b)
- (int mod)
+ (partial
+ (lambda
+ (
+ (int mod)
+ (int i)
+ (int a)
+ (int b)
+ )
+ (* (* (- b a) mod) (+ i 1))
)
- (* (* (- b a) mod) (+ i 1))
+ -1
)
(list:range 0 60 2)
(list:range 10 40 1)
- -1
)
)
(set! isi2oa
(set:indexed_merge
- (lambda
- (
- (int i)
- (int a)
- (int b)
- (int mod)
+ (partial
+ (lambda
+ (
+ (int mod)
+ (int i)
+ (int a)
+ (int b)
+ )
+ (* (* (- b a) mod) (+ i 1))
)
- (* (* (- b a) mod) (+ i 1))
+ -1
)
(list:range 0 60 2)
(list:range 10 80 1)
- -1
)
)
(set! isi2ob
(set:indexed_merge
- (lambda
- (
- (int i)
- (int a)
- (int b)
- (int mod)
+ (partial
+ (lambda
+ (
+ (int mod)
+ (int i)
+ (int a)
+ (int b)
+ )
+ (* (- b a) mod (+ i 1))
)
- (* (- b a) mod (+ i 1))
+ -1
)
(list:range 0 80 2)
(list:range 10 40 1)
- -1
)
)
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
index 948542c..145a947 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
@@ -959,11 +959,9 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor
name = a.get_car().get_name();
r =
- /* These are free by the unbind below */
- compiler.registers().reserve
+ reserve
(
- TypeCompiler.compile(compiler, a.get_car().get_type()),
- init_instructions
+ TypeCompiler.compile(compiler, a.get_car().get_type())
);
compiler.registers().bind(name, r);
@@ -985,7 +983,7 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor
for (final String name: names)
{
- compiler.registers().unbind(name, init_instructions);
+ compiler.registers().unbind_but_do_not_free(name);
}
}
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterContext.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterContext.java
index e83707b..b8440ae 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterContext.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterContext.java
@@ -151,7 +151,11 @@ class RegisterContext
public void unbind (final String name, final List<Instruction> instr_holder)
{
release(aliased_registers.get(name), instr_holder);
+ unbind_but_do_not_free(name);
+ }
+ public void unbind_but_do_not_free(final String name)
+ {
aliased_registers.remove(name);
if (!hierarchical_aliases.isEmpty())
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterManager.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterManager.java
index 2d12e0a..b241386 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterManager.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/RegisterManager.java
@@ -162,6 +162,11 @@ public class RegisterManager
context.peekFirst().unbind(name, instr_holder);
}
+ public void unbind_but_do_not_free (final String name)
+ {
+ context.peekFirst().unbind_but_do_not_free(name);
+ }
+
public Register get_context_register (final String name)
{
final Register result;