| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-09 19:19:36 +0200 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-09 19:19:36 +0200 | 
| commit | dbcc7a573200a57600fa550c75201791903c4535 (patch) | |
| tree | 391ac24f2626c62d2573b538a9c707c99bca89d8 | |
| parent | 37e48fb6ece2a3d6fae7dee9588c191fe040d054 (diff) | |
Found some worrisome issue there.
The (index_of ...) in collections.fate yield changing values.
| -rw-r--r-- | data/tests/collections.fate | 25 | ||||
| -rw-r--r-- | src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java | 36 | 
2 files changed, 50 insertions, 11 deletions
| diff --git a/data/tests/collections.fate b/data/tests/collections.fate index 0c804bd..871b122 100644 --- a/data/tests/collections.fate +++ b/data/tests/collections.fate @@ -139,13 +139,22 @@  (assert (= 18 (size (var int_list_a))) FAILED: size list N) -(assert (= 2 (access int_list_a 0)) FAILED: size list M_BIS (access int_list_a 0)) -(assert (= 5 (access int_list_a 3)) FAILED: size list N_BIS (access int_list_a 3)) -(assert (= 2 (count 10 int_list_a)) FAILED: size list O) -(assert (= 0 (count 99 int_list_a)) FAILED: size list P) -;;(assert (= 0 (index_of 2 int_list_a)) FAILED: size list Q) -;;(assert (= 1 (index_of 3 int_list_a)) FAILED: size list R) -(assert (not (is_member 99 int_list_a)) FAILED: size list S) -(assert (is_member 10 int_list_a) FAILED: size list T) +;;(assert (= 2 (access int_list_a 0)) FAILED: size list M_BIS (access int_list_a 0)) +;;(assert (= 5 (access int_list_a 3)) FAILED: size list N_BIS (access int_list_a 3)) +;;(assert (= 2 (count 10 int_list_a)) FAILED: size list O) +;;(assert (= 0 (count 99 int_list_a)) FAILED: size list P) + +(assert (false) test a) +(index_of 3 int_list_a) +(assert (false) test b) +(index_of 3 int_list_a) +(assert (false) test c) +(index_of 3 int_list_a) + +;;(assert (= 1 (index_of 3 int_list_a)) FAILED: size list Q (index_of 2 int_list_a)) +;;(assert (= 1 (index_of 3 int_list_a)) FAILED: size list R (index_of 3 int_list_a)) +;;(assert (= -1 (index_of 333 int_list_a)) FAILED: size list S) +;;(assert (not (is_member 99 int_list_a)) FAILED: size list T) +;;(assert (is_member 10 int_list_a) FAILED: size list U)  (end) 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 | 


