From dbcc7a573200a57600fa550c75201791903c4535 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sun, 9 Aug 2020 19:19:36 +0200 Subject: Found some worrisome issue there. The (index_of ...) in collections.fate yield changing values. --- .../v1/compiler/fate/v1/ComputationCompiler.java | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src') 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 ae89702..2731e78 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 @@ -18,6 +18,7 @@ import tonkadur.wyrd.v1.lang.instruction.SetValue; import tonkadur.wyrd.v1.compiler.util.BinarySearch; import tonkadur.wyrd.v1.compiler.util.IfElse; +import tonkadur.wyrd.v1.compiler.util.If; import tonkadur.wyrd.v1.compiler.util.IterativeSearch; import tonkadur.wyrd.v1.compiler.util.CountOccurrences; @@ -1115,9 +1116,9 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor n.get_collection().get_visited_by(cc); - result_as_computation = new Size(cc.get_ref()); + assimilate(cc); - cc.release_variables(); + result_as_computation = new Size(cc.get_ref()); } @Override @@ -1127,7 +1128,36 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor ) throws Throwable { - /* TODO */ + final ComputationCompiler elem_cc, collection_cc; + final Ref result, result_found; + + result = reserve(Type.INT); + result_found = reserve(Type.BOOLEAN); + + elem_cc = new ComputationCompiler(compiler); + collection_cc = new ComputationCompiler(compiler); + + n.get_element().get_visited_by(elem_cc); + n.get_collection().get_visited_by(collection_cc); + + assimilate(elem_cc); + assimilate(collection_cc); + + init_instructions.add + ( + IterativeSearch.generate + ( + compiler.anonymous_variables(), + compiler.assembler(), + elem_cc.get_computation(), + new Size(collection_cc.get_ref()), + collection_cc.get_ref(), + result_found, + result + ) + ); + + result_as_ref = result; } @Override -- cgit v1.2.3-70-g09d2