| summaryrefslogtreecommitdiff | 
diff options
| -rw-r--r-- | data/unit-testing/access.fate | 6 | ||||
| -rw-r--r-- | data/unit-testing/access_pointer.fate | 94 | ||||
| -rw-r--r-- | data/unit-testing/field_access.fate | 10 | ||||
| -rw-r--r-- | data/unit-testing/map.fate | 4 | ||||
| -rw-r--r-- | data/unit-testing/merge.fate | 301 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java | 20 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java | 20 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 | 6 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/parser/FateParser.g4 | 72 | ||||
| -rw-r--r-- | src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java | 219 | ||||
| -rw-r--r-- | src/core/src/tonkadur/wyrd/v1/compiler/util/IndexedMergeLambda.java | 123 | 
11 files changed, 501 insertions, 374 deletions
| diff --git a/data/unit-testing/access.fate b/data/unit-testing/access.fate index 7c1976f..fe92293 100644 --- a/data/unit-testing/access.fate +++ b/data/unit-testing/access.fate @@ -9,13 +9,13 @@  (global int i)  (for (set i 0) (=< i 10) (set i (+ i 1)) -   (assert (= (access li i) (var i)) +   (assert (= (access i li) (var i))        [FAILED] ACCESS assert failed on (var i) for li.     ) -   (assert (= (access li_ptr i) (var i)) +   (assert (= (access i li_ptr) (var i))        [FAILED] ACCESS assert failed on (var i) with for li_ptr.     ) -   (assert (= (access (range 0 10 1) i) (var i)) +   (assert (= (access i (range 0 10 1)) (var i))        [FAILED] ACCESS assert failed on (var i) with for range.     )  ) diff --git a/data/unit-testing/access_pointer.fate b/data/unit-testing/access_pointer.fate index e9218e9..c98c31a 100644 --- a/data/unit-testing/access_pointer.fate +++ b/data/unit-testing/access_pointer.fate @@ -13,10 +13,10 @@  (global int i)  (for (set i 0) (=< i 10) (set i (+ i 1)) -   (assert (= (at (access_ptr li i)) (var i)) +   (assert (= (at (access_ptr i li)) (var i))        [FAILED] ACCESS POINTER assert failed on (var i) for li.     ) -   (assert (= (at (access_ptr li_ptr i)) (var i)) +   (assert (= (at (access_ptr i li_ptr)) (var i))        [FAILED] ACCESS POINTER assert failed on (var i) with for li_ptr.     )  ) @@ -27,29 +27,73 @@     (add! (range 0 i 1) lili)  ) -(assert (= (at (access_ptr (at (access_ptr lili 10)) 0)) 0) [FAILED] (var test_name) lili.10.0 was (at (access_ptr (at (access_ptr lili 10)) 0)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 9)) 1)) 1) [FAILED] (var test_name) lili.9.1 was (at (access_ptr (at (access_ptr lili 9)) 1)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 8)) 2)) 2) [FAILED] (var test_name) lili.8.2 was (at (access_ptr (at (access_ptr lili 8)) 2)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 7)) 3)) 3) [FAILED] (var test_name) lili.7.3 was (at (access_ptr (at (access_ptr lili 7)) 3)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 6)) 4)) 4) [FAILED] (var test_name) lili.6.4 was (at (access_ptr (at (access_ptr lili 6)) 4)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 5)) 5)) 5) [FAILED] (var test_name) lili.5.5 was (at (access_ptr (at (access_ptr lili 5)) 5)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 4)) 3)) 3) [FAILED] (var test_name) lili.4.3 was (at (access_ptr (at (access_ptr lili 4)) 3)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 3)) 2)) 2) [FAILED] (var test_name) lili.3.2 was (at (access_ptr (at (access_ptr lili 3)) 2)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 2)) 1)) 1) [FAILED] (var test_name) lili.2.1 was (at (access_ptr (at (access_ptr lili 2)) 1)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 1)) 0)) 0) [FAILED] (var test_name) lili.1.0 was (at (access_ptr (at (access_ptr lili 1)) 0)) for part A.) -(assert (= (at (access_ptr (at (access_ptr lili 0)) 0)) 0) [FAILED] (var test_name) lili.0.0 was (at (access_ptr (at (access_ptr lili 0)) 0)) for part A.) - -(assert (= (at (access_ptr lili.10 0)) 0) [FAILED] (var test_name) lili.10.0 was (at (access_ptr lili.10 0)) for part B.) -(assert (= (at (access_ptr lili.9 1)) 1) [FAILED] (var test_name) lili.9.1 was (at (access_ptr lili.9 1)) for part B.) -(assert (= (at (access_ptr lili.8 2)) 2) [FAILED] (var test_name) lili.8.2 was (at (access_ptr lili.8 2)) for part B.) -(assert (= (at (access_ptr lili.7 3)) 3) [FAILED] (var test_name) lili.7.3 was (at (access_ptr lili.7 3)) for part B.) -(assert (= (at (access_ptr lili.6 4)) 4) [FAILED] (var test_name) lili.6.4 was (at (access_ptr lili.6 4)) for part B.) -(assert (= (at (access_ptr lili.5 5)) 5) [FAILED] (var test_name) lili.5.5 was (at (access_ptr lili.5 5)) for part B.) -(assert (= (at (access_ptr lili.4 3)) 3) [FAILED] (var test_name) lili.4.3 was (at (access_ptr lili.4 3)) for part B.) -(assert (= (at (access_ptr lili.3 2)) 2) [FAILED] (var test_name) lili.3.2 was (at (access_ptr lili.3 2)) for part B.) -(assert (= (at (access_ptr lili.2 1)) 1) [FAILED] (var test_name) lili.2.1 was (at (access_ptr lili.2 1)) for part B.) -(assert (= (at (access_ptr lili.1 0)) 0) [FAILED] (var test_name) lili.1.0 was (at (access_ptr lili.1 0)) for part B.) -(assert (= (at (access_ptr lili.0 0)) 0) [FAILED] (var test_name) lili.0.0 was (at (access_ptr lili.0 0)) for part B.) +(assert +   (= (at (access_ptr 0 (at (access_ptr 10 lili)))) 0) +   [FAILED] (var test_name) lili.10.0 was +   (at (access_ptr 0 (at (access_ptr 10 lili)))) for part A. +) +(assert +   (= (at (access_ptr 1 (at (access_ptr 9 lili)))) 1) +   [FAILED] (var test_name) lili.9.1 was +   (at (access_ptr 1 (at (access_ptr 9 lili)))) for part A. +) +(assert +   (= (at (access_ptr 2 (at (access_ptr 8 lili)))) 2) +   [FAILED] (var test_name) lili.8.2 was +   (at (access_ptr 2 (at (access_ptr 8 lili)))) for part A. +) +(assert +   (= (at (access_ptr 3 (at (access_ptr 7 lili)))) 3) +   [FAILED] (var test_name) lili.7.3 was +   (at (access_ptr 3 (at (access_ptr 7 lili)))) for part A. +) +(assert +   (= (at (access_ptr 4 (at (access_ptr 6 lili)))) 4) +   [FAILED] (var test_name) lili.6.4 was +   (at (access_ptr 4 (at (access_ptr 6 lili)))) for part A. +) +(assert +   (= (at (access_ptr 5 (at (access_ptr 5 lili)))) 5) +   [FAILED] (var test_name) lili.5.5 was +   (at (access_ptr 5 (at (access_ptr 5 lili)))) for part A. +) +(assert +   (= (at (access_ptr 3 (at (access_ptr 4 lili)))) 3) +   [FAILED] (var test_name) lili.4.3 was +   (at (access_ptr 3 (at (access_ptr 4 lili)))) for part A. +) +(assert +   (= (at (access_ptr 2 (at (access_ptr 3 lili)))) 2) +   [FAILED] (var test_name) lili.3.2 was +   (at (access_ptr 2 (at (access_ptr 3 lili)))) for part A. +) +(assert +   (= (at (access_ptr 1 (at (access_ptr 2 lili)))) 1) +   [FAILED] (var test_name) lili.2.1 was +   (at (access_ptr 1 (at (access_ptr 2 lili)))) for part A. +) +(assert +   (= (at (access_ptr 0 (at (access_ptr 1 lili)))) 0) +   [FAILED] (var test_name) lili.1.0 was +   (at (access_ptr 0 (at (access_ptr 1 lili)))) for part A. +) +(assert +   (= (at (access_ptr 0 (at (access_ptr 0 lili)))) 0) +   [FAILED] (var test_name) lili.0.0 was +   (at (access_ptr 0 (at (access_ptr 0 lili)))) for part A. +) + +(assert (= (at (access_ptr 0 lili.10)) 0) [FAILED] (var test_name) lili.10.0 was (at (access_ptr 0 lili.10)) for part B.) +(assert (= (at (access_ptr 1 lili.9)) 1) [FAILED] (var test_name) lili.9.1 was (at (access_ptr 1 lili.9)) for part B.) +(assert (= (at (access_ptr 2 lili.8)) 2) [FAILED] (var test_name) lili.8.2 was (at (access_ptr 2 lili.8)) for part B.) +(assert (= (at (access_ptr 3 lili.7)) 3) [FAILED] (var test_name) lili.7.3 was (at (access_ptr 3 lili.7)) for part B.) +(assert (= (at (access_ptr 4 lili.6)) 4) [FAILED] (var test_name) lili.6.4 was (at (access_ptr 4 lili.6)) for part B.) +(assert (= (at (access_ptr 5 lili.5)) 5) [FAILED] (var test_name) lili.5.5 was (at (access_ptr 5 lili.5)) for part B.) +(assert (= (at (access_ptr 3 lili.4)) 3) [FAILED] (var test_name) lili.4.3 was (at (access_ptr 3 lili.4)) for part B.) +(assert (= (at (access_ptr 2 lili.3)) 2) [FAILED] (var test_name) lili.3.2 was (at (access_ptr 2 lili.3)) for part B.) +(assert (= (at (access_ptr 1 lili.2)) 1) [FAILED] (var test_name) lili.2.1 was (at (access_ptr 1 lili.2)) for part B.) +(assert (= (at (access_ptr 0 lili.1)) 0) [FAILED] (var test_name) lili.1.0 was (at (access_ptr 0 lili.1)) for part B.) +(assert (= (at (access_ptr 0 lili.0)) 0) [FAILED] (var test_name) lili.0.0 was (at (access_ptr 0 lili.0)) for part B.)  [COMPLETED] ACCESS POINTER diff --git a/data/unit-testing/field_access.fate b/data/unit-testing/field_access.fate index dbc2c18..715e706 100644 --- a/data/unit-testing/field_access.fate +++ b/data/unit-testing/field_access.fate @@ -68,7 +68,7 @@  )  (assert -   (= (get_field ts0_0 i) (var ts0_0.i) (get_field ts0_1 k) (var ts0_1.k) 42) +   (= (get_field i ts0_0) (var ts0_0.i) (get_field k ts0_1) (var ts0_1.k) 42)     [FAILED] (var test_name) Test 0.     (newline)     ts0_0.i = (var ts0_0.i) @@ -77,7 +77,7 @@  )  (assert -   (= (get_field ts0_1 i) (var ts0_1.i) (get_field ts0_0 k) (var ts0_0.k) 420) +   (= (get_field i ts0_1) (var ts0_1.i) (get_field k ts0_0) (var ts0_0.k) 420)     [FAILED] (var test_name) Test 1.     (newline)     ts0_0.k = (var ts0_0.k) @@ -87,9 +87,9 @@  (assert     (= -      (field ts0_1 i) -      (get_field (set_fields ts1_0 (i 420)) i) -      (get_field (field (field ts2_0 ts1) ts0) i) +      (field i ts0_1) +      (get_field i (set_fields ts1_0 (i 420))) +      (get_field i (field ts0 (field ts1 ts2_0)))        420     )     [FAILED] (var test_name) Test 2. diff --git a/data/unit-testing/map.fate b/data/unit-testing/map.fate index bf8517f..bea1ada 100644 --- a/data/unit-testing/map.fate +++ b/data/unit-testing/map.fate @@ -136,11 +136,11 @@  (for (set i 0) (=< i 10) (set i (+ i 1))     (assert        (= -         (access li1 i) (access li0 i) (access li2 i) (access li3 i) +         (access i li1) (access i li0) (access i li2) (access i li3)           (+ (* i (+ 10 i)) 1000)        )        [FAILED] (var test_name) Indexed map at (var i): -      (access li1 i), (access li0 i), (access li2 i), (access li3 i) +      (access i li1), (access i li0), (access i li2), (access i li3)     )  ) diff --git a/data/unit-testing/merge.fate b/data/unit-testing/merge.fate index 88bc732..ba40724 100644 --- a/data/unit-testing/merge.fate +++ b/data/unit-testing/merge.fate @@ -26,10 +26,10 @@              (int a)              (int b)           ) -         (- a b) +         (- b a)        ) -      (range 10 40 1)        (range 0 60 2) +      (range 10 40 1)     )  ) @@ -40,10 +40,10 @@              (int a)              (int b)           ) -         (- a b) +         (- b a)        ) -      (range 10 70 1)        (range 0 60 2) +      (range 10 70 1)     )  ) @@ -54,10 +54,10 @@              (int a)              (int b)           ) -         (- a b) +         (- b a)        ) -      (range 10 40 1)        (range 0 80 2) +      (range 10 40 1)     )  ) @@ -71,10 +71,10 @@           (int a)           (int b)        ) -      (- a b) +      (- b a)     ) -   li1     (range 0 60 2) +   li1  )  (merge! @@ -83,10 +83,10 @@           (int a)           (int b)        ) -      (- a b) +      (- b a)     ) -   li1oa     (range 0 60 2) +   li1oa  )  (merge! @@ -95,10 +95,10 @@           (int a)           (int b)        ) -      (- a b) +      (- b a)     ) -   li1ob     (range 0 160 2) +   li1ob  )  (assert @@ -110,21 +110,21 @@     (assert        (=           (- (+ 10 i) (* 2 i)) -         (access li0 i) -         (access li0oa i) -         (access li0ob i) -         (access li1 i) -         (access li1oa i) -         (access li1ob i) +         (access i li0) +         (access i li0oa) +         (access i li0ob) +         (access i li1) +         (access i li1oa) +         (access i li1ob)        )        [FAILED] (var test_name) Basic test 0, index (var i), values:        Expected: (- (+ 10 i) (* 2 i)); -      li0: (access li0 i); -      li0oa: (access li0oa i); -      li0ob: (access li0ob i); -      li1: (access li1 i); -      li1oa: (access li1oa i); -      li1ob: (access li1ob i) +      li0: (access i li0); +      li0oa: (access i li0oa); +      li0ob: (access i li0ob); +      li1: (access i li1); +      li1oa: (access i li1oa); +      li1ob: (access i li1ob)     )  ) @@ -145,10 +145,10 @@              (int a)              (int b)           ) -         (- a b) +         (- b a)        ) -      (range 10 40 1)        (range 0 60 2) +      (range 10 40 1)     )  ) @@ -159,10 +159,10 @@              (int a)              (int b)           ) -         (- a b) +         (- b a)        ) -      (range 10 70 1)        (range 0 60 2) +      (range 10 70 1)     )  ) @@ -173,10 +173,10 @@              (int a)              (int b)           ) -         (- a b) +         (- b a)        ) -      (range 10 40 1)        (range 0 80 2) +      (range 10 40 1)     )  ) @@ -190,10 +190,10 @@           (int a)           (int b)        ) -      (- a b) +      (- b a)     ) -   si1     (range 0 60 2) +   si1  )  (merge! @@ -202,10 +202,10 @@           (int a)           (int b)        ) -      (- a b) +      (- b a)     ) -   si1oa     (range 0 60 2) +   si1oa  )  (merge! @@ -214,10 +214,10 @@           (int a)           (int b)        ) -      (- a b) +      (- b a)     ) -   si1ob     (range 0 80 2) +   si1ob  )  (assert @@ -238,21 +238,21 @@     (assert        (=           (- (+ 10 j) (* 2 j)) -         (access si0 i) -         (access si0oa i) -         (access si0ob i) -         (access si1 i) -         (access si1oa i) -         (access si1ob i) +         (access i si0) +         (access i si0oa) +         (access i si0ob) +         (access i si1) +         (access i si1oa) +         (access i si1ob)        )        [FAILED] (var test_name) Basic test 1, index (var i), values:        Expected: (- (+ 10 j) (* 2 j)); -      si0: (access si0 i); -      si0oa: (access si0oa i); -      si0ob: (access si0ob i); -      si1: (access si1 i); -      si1oa: (access si1oa i); -      si1ob: (access si1ob i); +      si0: (access i si0); +      si0oa: (access i si0oa); +      si0ob: (access i si0ob); +      si1: (access i si1); +      si1oa: (access i si1oa); +      si1ob: (access i si1ob);     )  ) @@ -274,10 +274,10 @@              (int b)              (int mod)           ) -         (* (- a b) mod) +         (* (- b a) mod)        ) -      (range 10 40 1)        (range 0 60 2) +      (range 10 40 1)        -1     )  ) @@ -290,10 +290,10 @@              (int b)              (int mod)           ) -         (* (- a b) mod) +         (* (- b a) mod)        ) -      (range 10 80 1)        (range 0 60 2) +      (range 10 80 1)        -1     )  ) @@ -306,10 +306,10 @@              (int b)              (int mod)           ) -         (* (- a b) mod) +         (* (- b a) mod)        ) -      (range 10 40 1)        (range 0 80 2) +      (range 10 40 1)        -1     )  ) @@ -325,10 +325,10 @@           (int b)           (int mod)        ) -      (* (- a b) mod) +      (* (- b a) mod)     ) -   si3     (range 0 60 2) +   si3     -1  ) @@ -339,10 +339,10 @@           (int b)           (int mod)        ) -      (* (- a b) mod) +      (* (- b a) mod)     ) -   si3oa     (range 0 60 2) +   si3oa     -1  ) @@ -353,10 +353,10 @@           (int b)           (int mod)        ) -      (* (- a b) mod) +      (* (- b a) mod)     ) -   si3ob     (range 0 90 2) +   si3ob     -1  ) @@ -372,21 +372,21 @@     (assert        (=           (* (- (+ 10 i) (* 2 i)) -1) -         (access si2 i) -         (access si2oa i) -         (access si2ob i) -         (access si3 i) -         (access si3oa i) -         (access si3ob i) +         (access i si2) +         (access i si2oa) +         (access i si2ob) +         (access i si3) +         (access i si3oa) +         (access i si3ob)        )        [FAILED] (var test_name) Basic test 2, index (var i), values:        Expected: (* (- (+ 10 i) (* 2 i)) -1); -      si2: (access si2 i); -      si2oa: (access si2oa i); -      si2ob: (access si2ob i); -      si3: (access si3 i); -      si3oa: (access si3oa i); -      si3ob: (access si3ob i) +      si2: (access i si2); +      si2oa: (access i si2oa); +      si2ob: (access i si2ob); +      si3: (access i si3); +      si3oa: (access i si3oa); +      si3ob: (access i si3ob)     )  ) @@ -408,10 +408,10 @@              (int a)              (int b)           ) -         (* (- a b) i) +         (* (- b a) i)        ) -      (range 10 40 1)        (range 0 60 2) +      (range 10 40 1)     )  ) @@ -423,10 +423,10 @@              (int a)              (int b)           ) -         (* (- a b) i) +         (* (- b a) i)        ) -      (range 10 70 1)        (range 0 60 2) +      (range 10 70 1)     )  ) @@ -438,10 +438,10 @@              (int a)              (int b)           ) -         (* (- a b) i) +         (* (- b a) i)        ) -      (range 10 40 1)        (range 0 80 2) +      (range 10 40 1)     )  ) @@ -456,10 +456,10 @@           (int a)           (int b)        ) -      (* (- a b) i) +      (* (- b a) i)     ) -   ili1     (range 0 60 2) +   ili1  )  (indexed_merge! @@ -469,10 +469,10 @@           (int a)           (int b)        ) -      (* (- a b) i) +      (* (- b a) i)     ) -   ili1oa     (range 0 60 2) +   ili1oa  )  (indexed_merge! @@ -482,10 +482,10 @@           (int a)           (int b)        ) -      (* (- a b) i) +      (* (- b a) i)     ) -   ili1ob     (range 0 160 2) +   ili1ob  )  (assert @@ -497,21 +497,21 @@     (assert        (=           (* (- (+ 10 i) (* 2 i)) i) -         (access ili0 i) -         (access ili0oa i) -         (access ili0ob i) -         (access ili1 i) -         (access ili1oa i) -         (access ili1ob i) +         (access i ili0) +         (access i ili0oa) +         (access i ili0ob) +         (access i ili1) +         (access i ili1oa) +         (access i ili1ob)        )        [FAILED] (var test_name) Indexed test 0, index (var i), values:        Expected: (* (- (+ 10 i) (* 2 i)) i); -      ili0: (access ili0 i); -      ili0oa: (access ili0oa i); -      ili0ob: (access ili0ob i); -      ili1: (access ili1 i); -      ili1oa: (access ili1oa i); -      ili1ob: (access ili1ob i) +      ili0: (access i ili0); +      ili0oa: (access i ili0oa); +      ili0ob: (access i ili0ob); +      ili1: (access i ili1); +      ili1oa: (access i ili1oa); +      ili1ob: (access i ili1ob)     )  ) @@ -541,10 +541,10 @@ For reference, the values found in the sets are:              (int a)              (int b)           ) -         (* (- a b) (+ i 1)) +         (* (- b a) (+ i 1))        ) -      (range 10 40 1)        (range 0 60 2) +      (range 10 40 1)     )  ) @@ -556,10 +556,10 @@ For reference, the values found in the sets are:              (int a)              (int b)           ) -         (* (- a b) (+ i 1)) +         (* (- b a) (+ i 1))        ) -      (range 10 70 1)        (range 0 60 2) +      (range 10 70 1)     )  ) @@ -571,10 +571,10 @@ For reference, the values found in the sets are:              (int a)              (int b)           ) -         (* (- a b) (+ i 1)) +         (* (- b a) (+ i 1))        ) -      (range 10 40 1)        (range 0 80 2) +      (range 10 40 1)     )  ) @@ -589,10 +589,10 @@ For reference, the values found in the sets are:           (int a)           (int b)        ) -      (* (- a b) (+ i 1)) +      (* (- b a) (+ i 1))     ) -   isi1     (range 0 60 2) +   isi1  )  (indexed_merge! @@ -602,10 +602,10 @@ For reference, the values found in the sets are:           (int a)           (int b)        ) -      (* (- a b) (+ i 1)) +      (* (- b a) (+ i 1))     ) -   isi1oa     (range 0 60 2) +   isi1oa  )  (indexed_merge! @@ -615,10 +615,10 @@ For reference, the values found in the sets are:           (int a)           (int b)        ) -      (* (- a b) (+ i 1)) +      (* (- b a) (+ i 1))     ) -   isi1ob     (range 0 80 2) +   isi1ob  )  (assert @@ -629,22 +629,22 @@ For reference, the values found in the sets are:  (for (set i (- (size oracle_set) 1)) (>= i 0) (set i (- i 1))     (assert        (= -         (access oracle_set i) -         (access isi0 i) -         (access isi0oa i) -         (access isi0ob i) -         (access isi1 i) -         (access isi1oa i) -         (access isi1ob i) +         (access i oracle_set) +         (access i isi0) +         (access i isi0oa) +         (access i isi0ob) +         (access i isi1) +         (access i isi1oa) +         (access i isi1ob)        )        [FAILED] (var test_name) Indexed test 1, index (var i), values: -      Expected: (access oracle_set i); -      isi0: (access isi0 i); -      isi0oa: (access isi0oa i); -      isi0ob: (access isi0ob i); -      isi1: (access isi1 i); -      isi1oa: (access isi1oa i); -      isi1ob: (access isi1ob i); +      Expected: (access i oracle_set); +      isi0: (access i isi0); +      isi0oa: (access i isi0oa); +      isi0ob: (access i isi0ob); +      isi1: (access i isi1); +      isi1oa: (access i isi1oa); +      isi1ob: (access i isi1ob);     )  ) @@ -678,10 +678,10 @@ For reference, the values found in the sets are:              (int b)              (int mod)           ) -         (* (* (- a b) mod) (+ i 1)) +         (* (* (- b a) mod) (+ i 1))        ) -      (range 10 40 1)        (range 0 60 2) +      (range 10 40 1)        -1     )  ) @@ -695,10 +695,10 @@ For reference, the values found in the sets are:              (int b)              (int mod)           ) -         (* (* (- a b) mod) (+ i 1)) +         (* (* (- b a) mod) (+ i 1))        ) -      (range 10 80 1)        (range 0 60 2) +      (range 10 80 1)        -1     )  ) @@ -712,10 +712,10 @@ For reference, the values found in the sets are:              (int b)              (int mod)           ) -         (* (- a b) mod (+ i 1)) +         (* (- b a) mod (+ i 1))        ) -      (range 10 40 1)        (range 0 80 2) +      (range 10 40 1)        -1     )  ) @@ -732,10 +732,10 @@ For reference, the values found in the sets are:           (int b)           (int mod)        ) -      (* (- a b) mod (+ i 1)) +      (* (- b a) mod (+ i 1))     ) -   isi3     (range 0 60 2) +   isi3     -1  ) @@ -747,10 +747,10 @@ For reference, the values found in the sets are:           (int b)           (int mod)        ) -      (* (- a b) mod (+ i 1)) +      (* (- b a) mod (+ i 1))     ) -   isi3oa     (range 0 60 2) +   isi3oa     -1  ) @@ -762,10 +762,10 @@ For reference, the values found in the sets are:           (int b)           (int mod)        ) -      (* (- a b) mod (+ i 1)) +      (* (- b a) mod (+ i 1))     ) -   isi3ob     (range 0 90 2) +   isi3ob     -1  ) @@ -777,29 +777,30 @@ For reference, the values found in the sets are:  (for (set i (- (size oracle_set) 1)) (>= i 0) (set i (- i 1))     (assert        (= -         (access oracle_set i) -         (access isi2 i) -         (access isi2oa i) -         (access isi2ob i) -         (access isi3 i) -         (access isi3oa i) -         (access isi3ob i) +         (access i oracle_set) +         (access i isi2) +         (access i isi2oa) +         (access i isi2ob) +         (access i isi3) +         (access i isi3oa) +         (access i isi3ob)        )        [FAILED] (var test_name) Indexed test 2, index (var i), values: -      Expected: (access oracle_set i); -      isi2: (access isi2 i); -      isi2oa: (access isi2oa i); -      isi2ob: (access isi2ob i); -      isi3: (access isi3 i); -      isi3oa: (access isi3oa i); -      isi3ob: (access isi3ob i) +      Expected: (access i oracle_set); +      isi2: (access i isi2); +      isi2oa: (access i isi2oa); +      isi2ob: (access i isi2ob); +      isi3: (access i isi3); +      isi3oa: (access i isi3oa); +      isi3ob: (access i isi3ob)     )  )  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; DEFAULT_VALUES TEST 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; SAFE TEST 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TODO + +(assert (false) [FAILED] TODO: safe merge tests.)  [COMPLETED] (var test_name) diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java index 96cfefc..060438c 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java @@ -35,10 +35,10 @@ public class IndexedMerge extends Instruction     (        final Origin origin,        final Computation lambda_function, -      final Reference collection, -      final Computation default_a,        final Computation collection_in_b,        final Computation default_b, +      final Reference collection, +      final Computation default_a,        final List<Computation> extra_params     )     { @@ -60,10 +60,10 @@ public class IndexedMerge extends Instruction     (        final Origin origin,        final Computation lambda_function, -      final Reference collection, -      final Computation default_a,        final Computation collection_in_b,        final Computation default_b, +      final Reference collection, +      final Computation default_a,        final List<Computation> extra_params     )     throws Throwable @@ -123,10 +123,10 @@ public class IndexedMerge extends Instruction           (              origin,              lambda_function, -            collection, -            default_a,              collection_in_b,              default_b, +            collection, +            default_a,              extra_params           );     } @@ -144,22 +144,22 @@ public class IndexedMerge extends Instruction        return lambda_function;     } -   public Computation get_default_a () +   public Computation get_main_default ()     {        return default_a;     } -   public Computation get_collection_in_b () +   public Computation get_secondary_collection ()     {        return collection_in_b;     } -   public Computation get_default_b () +   public Computation get_secondary_default ()     {        return default_b;     } -   public Reference get_collection () +   public Reference get_main_collection ()     {        return collection;     } diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java index f2396a9..9a40f2f 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java @@ -35,10 +35,10 @@ public class Merge extends Instruction     (        final Origin origin,        final Computation lambda_function, -      final Reference collection, -      final Computation default_a,        final Computation collection_in_b,        final Computation default_b, +      final Reference collection, +      final Computation default_a,        final List<Computation> extra_params     )     { @@ -60,10 +60,10 @@ public class Merge extends Instruction     (        final Origin origin,        final Computation lambda_function, -      final Reference collection, -      final Computation default_a,        final Computation collection_in_b,        final Computation default_b, +      final Reference collection, +      final Computation default_a,        final List<Computation> extra_params     )     throws Throwable @@ -117,10 +117,10 @@ public class Merge extends Instruction           (              origin,              lambda_function, -            collection, -            default_a,              collection_in_b,              default_b, +            collection, +            default_a,              extra_params           );     } @@ -138,22 +138,22 @@ public class Merge extends Instruction        return lambda_function;     } -   public Computation get_default_a () +   public Computation get_main_default ()     {        return default_a;     } -   public Computation get_collection_in_b () +   public Computation get_secondary_collection ()     {        return collection_in_b;     } -   public Computation get_default_b () +   public Computation get_secondary_default ()     {        return default_b;     } -   public Reference get_collection () +   public Reference get_main_collection ()     {        return collection;     } diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 index 10bb692..b7b64dd 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 @@ -8,6 +8,7 @@ lexer grammar FateLexer;  fragment SEP: [ \t\r\n]+;  fragment US: '_'?; +  WS: SEP;  L_PAREN: '('; @@ -162,6 +163,9 @@ VISIT_KW: L_PAREN ('call'|'visit')(US(('seq'('uence'?))|('proc'('edure'?))))? SE  CONTINUE_AS_KW: L_PAREN (('continue'US('as'|'to'|'with'))|('jump'(US'to')?)|('go'US'to')|'exec')(US(('seq'('uence'?))|('proc'('edure'?))))? SEP+;  WHILE_KW: L_PAREN 'while' SEP+; -WORD: (~([ \t\r\n()])|'\\)'|'\\(')+; +WORD: ((~([ \t\r\n()]))|'(lp)'|'(rp)')+ +   { +      setText(getText().replaceAll("\\(lp\\)", "(").replaceAll("\\(rp\\)", ")")); +   };  COMMENT: WS* ';' .*? '\n' -> channel(HIDDEN); diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 index d16dfb2..16a9472 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 @@ -977,8 +977,8 @@ returns [Instruction result]     | IMP_MERGE_KW           fun=non_text_value WS+ -         value_reference WS+ -         inv1=non_text_value WS* +         inv1=non_text_value WS+ +         value_reference WS*        R_PAREN     {        $result = @@ -990,18 +990,18 @@ returns [Instruction result]                 ($IMP_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            null,              ($inv1.result),              null, +            ($value_reference.result), +            null,              new ArrayList()           );     }     | IMP_MERGE_KW           fun=non_text_value WS+ -         value_reference WS+           inv1=non_text_value WS+ +         value_reference WS+           value_list WS*        R_PAREN     { @@ -1014,18 +1014,18 @@ returns [Instruction result]                 ($IMP_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            null,              ($inv1.result),              null, +            ($value_reference.result), +            null,              ($value_list.result)           );     }     | IMP_INDEXED_MERGE_KW           fun=non_text_value WS+ -         value_reference WS+ -         inv1=non_text_value WS* +         inv1=non_text_value WS+ +         value_reference WS*        R_PAREN     {        $result = @@ -1037,18 +1037,18 @@ returns [Instruction result]                 ($IMP_INDEXED_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            null,              ($inv1.result),              null, +            ($value_reference.result), +            null,              new ArrayList()           );     }     | IMP_INDEXED_MERGE_KW           fun=non_text_value WS+ -         value_reference WS+           inv1=non_text_value WS+ +         value_reference WS+           value_list WS*        R_PAREN     { @@ -1061,20 +1061,20 @@ returns [Instruction result]                 ($IMP_INDEXED_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            null,              ($inv1.result),              null, +            ($value_reference.result), +            null,              ($value_list.result)           );     }     | SAFE_IMP_MERGE_KW        fun=non_text_value WS+ -      def0=value WS+ -      value_reference WS+        def1=value WS+ -      inv1=non_text_value WS* +      inv1=non_text_value WS+ +      def0=value WS+ +      value_reference WS*        R_PAREN     {        $result = @@ -1086,20 +1086,20 @@ returns [Instruction result]                 ($SAFE_IMP_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            ($def0.result),              ($inv1.result),              ($def1.result), +            ($value_reference.result), +            ($def0.result),              new ArrayList()           );     }     | SAFE_IMP_MERGE_KW        fun=non_text_value WS+ -      def0=value WS+ -      value_reference WS+        def1=value WS+        inv1=non_text_value WS+ +      def0=value WS+ +      value_reference WS+        value_list WS*        R_PAREN     { @@ -1112,20 +1112,20 @@ returns [Instruction result]                 ($SAFE_IMP_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            ($def0.result),              ($inv1.result),              ($def1.result), +            ($value_reference.result), +            ($def0.result),              ($value_list.result)           );     }     | SAFE_IMP_INDEXED_MERGE_KW        fun=non_text_value WS+ -      def0=value WS+ -      value_reference WS+        def1=value WS+ -      inv1=non_text_value WS* +      inv1=non_text_value WS+ +      def0=value WS+ +      value_reference WS*        R_PAREN     {        $result = @@ -1137,20 +1137,20 @@ returns [Instruction result]                 ($SAFE_IMP_INDEXED_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            ($def0.result),              ($inv1.result),              ($def1.result), +            ($value_reference.result), +            ($def0.result),              new ArrayList()           );     }     | SAFE_IMP_INDEXED_MERGE_KW        fun=non_text_value WS+ -      def0=value WS+ -      value_reference WS+        def1=value WS+        inv1=non_text_value WS+ +      def0=value WS+ +      value_reference WS+        value_list WS*        R_PAREN     { @@ -1163,10 +1163,10 @@ returns [Instruction result]                 ($SAFE_IMP_INDEXED_MERGE_KW.getCharPositionInLine())              ),              ($fun.result), -            ($value_reference.result), -            ($def0.result),              ($inv1.result),              ($def1.result), +            ($value_reference.result), +            ($def0.result),              ($value_list.result)           );     } @@ -3743,7 +3743,7 @@ returns [Computation result]           );     } -   | ACCESS_KW collection=non_text_value WS+ index=non_text_value WS* R_PAREN +   | ACCESS_KW index=non_text_value WS+ collection=non_text_value WS* R_PAREN     {        $result =           Access.build @@ -3758,7 +3758,7 @@ returns [Computation result]           );     } -   | ACCESS_POINTER_KW value_reference WS+ non_text_value WS* R_PAREN +   | ACCESS_POINTER_KW non_text_value WS+ value_reference WS* R_PAREN     {        $result =           AccessPointer.build @@ -3773,7 +3773,7 @@ returns [Computation result]           );     } -   | FIELD_ACCESS_KW non_text_value WS+ WORD WS* R_PAREN +   | FIELD_ACCESS_KW WORD WS+ non_text_value WS* R_PAREN     {        $result =           FieldAccess.build @@ -5115,7 +5115,7 @@ returns [Reference result]           );     } -   | FIELD_KW value_reference WS+ WORD WS* R_PAREN +   | FIELD_KW WORD WS+ value_reference WS* R_PAREN     {        $result =           FieldReference.build diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java index 19baae7..5986682 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java @@ -749,17 +749,18 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor     throws Throwable     {        final Register holder; -      final ComputationCompiler lambda_cc, default_a_cc, default_b_cc; +      final ComputationCompiler lambda_cc; +      final ComputationCompiler main_default_cc, secondary_default_cc;        final List<Computation> params;        final List<ComputationCompiler> param_cc_list; -      final ComputationCompiler collection_cc, in_collection_b_cc; +      final ComputationCompiler main_collection_cc, secondary_collection_cc;        params = new ArrayList<Computation>();        param_cc_list = new ArrayList<ComputationCompiler>();        lambda_cc = new ComputationCompiler(compiler); -      default_a_cc = new ComputationCompiler(compiler); -      default_b_cc = new ComputationCompiler(compiler); +      main_default_cc = new ComputationCompiler(compiler); +      secondary_default_cc = new ComputationCompiler(compiler);        n.get_lambda_function().get_visited_by(lambda_cc); @@ -768,43 +769,47 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           result.add(lambda_cc.get_init());        } -      collection_cc = new ComputationCompiler(compiler); +      main_collection_cc = new ComputationCompiler(compiler); -      n.get_collection().get_visited_by(collection_cc); +      n.get_main_collection().get_visited_by(main_collection_cc); -      if (collection_cc.has_init()) +      if (main_collection_cc.has_init())        { -         result.add(collection_cc.get_init()); +         result.add(main_collection_cc.get_init());        } -      n.get_default_a().get_visited_by(default_a_cc); +      n.get_main_default().get_visited_by(main_default_cc); -      default_a_cc.generate_address(); +      main_default_cc.generate_address(); -      if (default_a_cc.has_init()) +      if (main_default_cc.has_init())        { -         result.add(default_a_cc.get_init()); +         result.add(main_default_cc.get_init());        } -      n.get_default_b().get_visited_by(default_b_cc); +      n.get_secondary_default().get_visited_by(secondary_default_cc); -      default_b_cc.generate_address(); +      secondary_default_cc.generate_address(); -      if (default_b_cc.has_init()) +      if (secondary_default_cc.has_init())        { -         result.add(default_b_cc.get_init()); +         result.add(secondary_default_cc.get_init());        }        holder =           compiler.registers().reserve           ( -            collection_cc.get_computation().get_type(), +            main_collection_cc.get_computation().get_type(),              result           );        result.add        ( -         new SetValue(holder.get_address(), collection_cc.get_computation()) +         new SetValue +         ( +            holder.get_address(), +            main_collection_cc.get_computation() +         )        );        result.add @@ -813,17 +818,17 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           (              compiler.registers(),              compiler.assembler(), -            collection_cc.get_address() +            main_collection_cc.get_address()           )        ); -      in_collection_b_cc = new ComputationCompiler(compiler); +      secondary_collection_cc = new ComputationCompiler(compiler); -      n.get_collection_in_b().get_visited_by(in_collection_b_cc); +      n.get_secondary_collection().get_visited_by(secondary_collection_cc); -      if (in_collection_b_cc.has_init()) +      if (secondary_collection_cc.has_init())        { -         result.add(in_collection_b_cc.get_init()); +         result.add(secondary_collection_cc.get_init());        }        for @@ -858,23 +863,23 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor              compiler.registers(),              compiler.assembler(),              lambda_cc.get_computation(), -            default_a_cc.get_computation(), +            secondary_default_cc.get_computation(), +            secondary_collection_cc.get_address(), +            main_default_cc.get_computation(),              holder.get_address(), -            default_b_cc.get_computation(), -            in_collection_b_cc.get_address(), -            collection_cc.get_address(), +            main_collection_cc.get_address(),              (                 (tonkadur.fate.v1.lang.type.CollectionType) -               n.get_collection().get_type() +               n.get_main_collection().get_type()              ).is_set(),              params           )        ); -      collection_cc.release_registers(result); -      in_collection_b_cc.release_registers(result); -      default_a_cc.release_registers(result); -      default_b_cc.release_registers(result); +      main_collection_cc.release_registers(result); +      secondary_collection_cc.release_registers(result); +      main_default_cc.release_registers(result); +      secondary_default_cc.release_registers(result);        compiler.registers().release(holder, result);        for (final ComputationCompiler cc: param_cc_list) @@ -892,7 +897,7 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor     {        /* This is one dangerous operation to do in-place, so we don't. */ -      if (n.get_default_a() != null) +      if (n.get_main_default() != null)        {           visit_merge_with_defaults(n);           return; @@ -902,7 +907,7 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor        final ComputationCompiler lambda_cc;        final List<Computation> params;        final List<ComputationCompiler> param_cc_list; -      final ComputationCompiler collection_cc, in_collection_b_cc; +      final ComputationCompiler main_collection_cc, secondary_collection_cc;        params = new ArrayList<Computation>();        param_cc_list = new ArrayList<ComputationCompiler>(); @@ -916,25 +921,29 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           result.add(lambda_cc.get_init());        } -      collection_cc = new ComputationCompiler(compiler); +      main_collection_cc = new ComputationCompiler(compiler); -      n.get_collection().get_visited_by(collection_cc); +      n.get_main_collection().get_visited_by(main_collection_cc); -      if (collection_cc.has_init()) +      if (main_collection_cc.has_init())        { -         result.add(collection_cc.get_init()); +         result.add(main_collection_cc.get_init());        }        holder =           compiler.registers().reserve           ( -            collection_cc.get_computation().get_type(), +            main_collection_cc.get_computation().get_type(),              result           );        result.add        ( -         new SetValue(holder.get_address(), collection_cc.get_computation()) +         new SetValue +         ( +            holder.get_address(), +            main_collection_cc.get_computation() +         )        );        result.add @@ -943,18 +952,17 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           (              compiler.registers(),              compiler.assembler(), -            collection_cc.get_address() +            main_collection_cc.get_address()           )        ); +      secondary_collection_cc = new ComputationCompiler(compiler); -      in_collection_b_cc = new ComputationCompiler(compiler); - -      n.get_collection_in_b().get_visited_by(in_collection_b_cc); +      n.get_secondary_collection().get_visited_by(secondary_collection_cc); -      if (in_collection_b_cc.has_init()) +      if (secondary_collection_cc.has_init())        { -         result.add(in_collection_b_cc.get_init()); +         result.add(secondary_collection_cc.get_init());        }        for @@ -989,19 +997,19 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor              compiler.registers(),              compiler.assembler(),              lambda_cc.get_computation(), +            secondary_collection_cc.get_address(),              holder.get_address(), -            in_collection_b_cc.get_address(), -            collection_cc.get_address(), +            main_collection_cc.get_address(),              (                 (tonkadur.fate.v1.lang.type.CollectionType) -               n.get_collection().get_type() +               n.get_main_collection().get_type()              ).is_set(),              params           )        ); -      collection_cc.release_registers(result); -      in_collection_b_cc.release_registers(result); +      main_collection_cc.release_registers(result); +      secondary_collection_cc.release_registers(result);        compiler.registers().release(holder, result);        for (final ComputationCompiler cc: param_cc_list) @@ -1017,17 +1025,18 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor     throws Throwable     {        final Register holder; -      final ComputationCompiler lambda_cc, default_a_cc, default_b_cc; +      final ComputationCompiler lambda_cc; +      final ComputationCompiler main_default_cc, secondary_default_cc;        final List<Computation> params;        final List<ComputationCompiler> param_cc_list; -      final ComputationCompiler collection_cc, in_collection_b_cc; +      final ComputationCompiler main_collection_cc, secondary_collection_cc;        params = new ArrayList<Computation>();        param_cc_list = new ArrayList<ComputationCompiler>();        lambda_cc = new ComputationCompiler(compiler); -      default_a_cc = new ComputationCompiler(compiler); -      default_b_cc = new ComputationCompiler(compiler); +      main_default_cc = new ComputationCompiler(compiler); +      secondary_default_cc = new ComputationCompiler(compiler);        n.get_lambda_function().get_visited_by(lambda_cc); @@ -1036,43 +1045,47 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           result.add(lambda_cc.get_init());        } -      collection_cc = new ComputationCompiler(compiler); +      main_collection_cc = new ComputationCompiler(compiler); -      n.get_collection().get_visited_by(collection_cc); +      n.get_main_collection().get_visited_by(main_collection_cc); -      if (collection_cc.has_init()) +      if (main_collection_cc.has_init())        { -         result.add(collection_cc.get_init()); +         result.add(main_collection_cc.get_init());        } -      n.get_default_a().get_visited_by(default_a_cc); +      n.get_main_default().get_visited_by(main_default_cc); -      default_a_cc.generate_address(); +      main_default_cc.generate_address(); -      if (default_a_cc.has_init()) +      if (main_default_cc.has_init())        { -         result.add(default_a_cc.get_init()); +         result.add(main_default_cc.get_init());        } -      n.get_default_b().get_visited_by(default_b_cc); +      n.get_secondary_default().get_visited_by(secondary_default_cc); -      default_b_cc.generate_address(); +      secondary_default_cc.generate_address(); -      if (default_b_cc.has_init()) +      if (secondary_default_cc.has_init())        { -         result.add(default_b_cc.get_init()); +         result.add(secondary_default_cc.get_init());        }        holder =           compiler.registers().reserve           ( -            collection_cc.get_computation().get_type(), +            main_collection_cc.get_computation().get_type(),              result           );        result.add        ( -         new SetValue(holder.get_address(), collection_cc.get_computation()) +         new SetValue +         ( +            holder.get_address(), +            main_collection_cc.get_computation() +         )        );        result.add @@ -1081,17 +1094,17 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           (              compiler.registers(),              compiler.assembler(), -            collection_cc.get_address() +            main_collection_cc.get_address()           )        ); -      in_collection_b_cc = new ComputationCompiler(compiler); +      secondary_collection_cc = new ComputationCompiler(compiler); -      n.get_collection_in_b().get_visited_by(in_collection_b_cc); +      n.get_secondary_collection().get_visited_by(secondary_collection_cc); -      if (in_collection_b_cc.has_init()) +      if (secondary_collection_cc.has_init())        { -         result.add(in_collection_b_cc.get_init()); +         result.add(secondary_collection_cc.get_init());        }        for @@ -1126,23 +1139,23 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor              compiler.registers(),              compiler.assembler(),              lambda_cc.get_computation(), -            default_a_cc.get_computation(), +            secondary_default_cc.get_computation(), +            secondary_collection_cc.get_address(), +            main_default_cc.get_computation(),              holder.get_address(), -            default_b_cc.get_computation(), -            in_collection_b_cc.get_address(), -            collection_cc.get_address(), +            main_collection_cc.get_address(),              (                 (tonkadur.fate.v1.lang.type.CollectionType) -               n.get_collection().get_type() +               n.get_main_collection().get_type()              ).is_set(),              params           )        ); -      collection_cc.release_registers(result); -      in_collection_b_cc.release_registers(result); -      default_a_cc.release_registers(result); -      default_b_cc.release_registers(result); +      main_collection_cc.release_registers(result); +      secondary_collection_cc.release_registers(result); +      main_default_cc.release_registers(result); +      secondary_default_cc.release_registers(result);        compiler.registers().release(holder, result);        for (final ComputationCompiler cc: param_cc_list) @@ -1158,7 +1171,7 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor     )     throws Throwable     { -      if (n.get_default_a() != null) +      if (n.get_main_default() != null)        {           visit_indexed_merge_with_defaults(n);           return; @@ -1169,7 +1182,7 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor        final ComputationCompiler lambda_cc;        final List<Computation> params;        final List<ComputationCompiler> param_cc_list; -      final ComputationCompiler collection_cc, in_collection_b_cc; +      final ComputationCompiler main_collection_cc, secondary_collection_cc;        params = new ArrayList<Computation>();        param_cc_list = new ArrayList<ComputationCompiler>(); @@ -1183,25 +1196,29 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           result.add(lambda_cc.get_init());        } -      collection_cc = new ComputationCompiler(compiler); +      main_collection_cc = new ComputationCompiler(compiler); -      n.get_collection().get_visited_by(collection_cc); +      n.get_main_collection().get_visited_by(main_collection_cc); -      if (collection_cc.has_init()) +      if (main_collection_cc.has_init())        { -         result.add(collection_cc.get_init()); +         result.add(main_collection_cc.get_init());        }        holder =           compiler.registers().reserve           ( -            collection_cc.get_computation().get_type(), +            main_collection_cc.get_computation().get_type(),              result           );        result.add        ( -         new SetValue(holder.get_address(), collection_cc.get_computation()) +         new SetValue +         ( +            holder.get_address(), +            main_collection_cc.get_computation() +         )        );        result.add @@ -1210,17 +1227,17 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor           (              compiler.registers(),              compiler.assembler(), -            collection_cc.get_address() +            main_collection_cc.get_address()           )        ); -      in_collection_b_cc = new ComputationCompiler(compiler); +      secondary_collection_cc = new ComputationCompiler(compiler); -      n.get_collection_in_b().get_visited_by(in_collection_b_cc); +      n.get_secondary_collection().get_visited_by(secondary_collection_cc); -      if (in_collection_b_cc.has_init()) +      if (secondary_collection_cc.has_init())        { -         result.add(in_collection_b_cc.get_init()); +         result.add(secondary_collection_cc.get_init());        }        for @@ -1255,19 +1272,19 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor              compiler.registers(),              compiler.assembler(),              lambda_cc.get_computation(), +            secondary_collection_cc.get_address(),              holder.get_address(), -            in_collection_b_cc.get_address(), -            collection_cc.get_address(), +            main_collection_cc.get_address(),              (                 (tonkadur.fate.v1.lang.type.CollectionType) -               n.get_collection().get_type() +               n.get_main_collection().get_type()              ).is_set(),              params           )        ); -      collection_cc.release_registers(result); -      in_collection_b_cc.release_registers(result); +      main_collection_cc.release_registers(result); +      secondary_collection_cc.release_registers(result);        compiler.registers().release(holder, result);        for (final ComputationCompiler cc: param_cc_list) diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/IndexedMergeLambda.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/IndexedMergeLambda.java index e1e4e4f..818fde6 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/util/IndexedMergeLambda.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/IndexedMergeLambda.java @@ -201,17 +201,22 @@ public class IndexedMergeLambda        final List<Computation> extra_params     )     { -      final List<Instruction> result, while_body; -      final Register iterator_a, iterator_b; +      final List<Instruction> result, while_body, oob_a_body, oob_b_body; +      final Register iterator_a, iterator_b, oob_a, oob_b;        final Register collection_a_size, collection_b_size;        final Register storage;        result = new ArrayList<Instruction>();        while_body = new ArrayList<Instruction>(); +      oob_a_body = new ArrayList<Instruction>(); +      oob_b_body = new ArrayList<Instruction>();        iterator_a = registers.reserve(Type.INT, result);        iterator_b = registers.reserve(Type.INT, result); +      oob_a = registers.reserve(Type.BOOL, result); +      oob_b = registers.reserve(Type.BOOL, result); +        collection_a_size = registers.reserve(Type.INT, result);        collection_b_size = registers.reserve(Type.INT, result); @@ -243,16 +248,39 @@ public class IndexedMergeLambda           )        ); -      extra_params.add +      result.add        ( -         0, -         new IfElseComputation +         new SetValue           ( -            Operation.less_than +            oob_a.get_address(), +            Operation.greater_equal_than +            ( +               iterator_a.get_value(), +               collection_a_size.get_value() +            ) +         ) +      ); + +      result.add +      ( +         new SetValue +         ( +            oob_b.get_address(), +            Operation.greater_equal_than              (                 iterator_b.get_value(),                 collection_b_size.get_value() -            ), +            ) +         ) +      ); + +      extra_params.add +      ( +         0, +         new IfElseComputation +         ( +            oob_b.get_value(), +            default_b,              new ValueOf              (                 new RelativeAddress @@ -263,8 +291,7 @@ public class IndexedMergeLambda                       (MapType) collection_in_b.get_target_type()                    ).get_member_type()                 ) -            ), -            default_b +            )           )        ); @@ -275,11 +302,8 @@ public class IndexedMergeLambda           0,           new IfElseComputation           ( -            Operation.less_than -            ( -               iterator_a.get_value(), -               collection_a_size.get_value() -            ), +            oob_a.get_value(), +            default_a,              new ValueOf              (                 new RelativeAddress @@ -290,8 +314,7 @@ public class IndexedMergeLambda                       (MapType) collection_in_a.get_target_type()                    ).get_member_type()                 ) -            ), -            default_a +            )           )        ); @@ -324,7 +347,7 @@ public class IndexedMergeLambda           )        ); -      while_body.add +      oob_a_body.add        (           new SetValue           ( @@ -333,7 +356,20 @@ public class IndexedMergeLambda           )        ); -      while_body.add +      oob_a_body.add +      ( +         new SetValue +         ( +            oob_a.get_address(), +            Operation.greater_equal_than +            ( +               iterator_a.get_value(), +               collection_a_size.get_value() +            ) +         ) +      ); + +      oob_b_body.add        (           new SetValue           ( @@ -342,31 +378,56 @@ public class IndexedMergeLambda           )        ); +      oob_b_body.add +      ( +         new SetValue +         ( +            oob_b.get_address(), +            Operation.greater_equal_than +            ( +               iterator_b.get_value(), +               collection_b_size.get_value() +            ) +         ) +      ); + +      while_body.add +      ( +         If.generate +         ( +            registers, +            assembler, +            Operation.not(oob_a.get_value()), +            assembler.merge(oob_a_body) +         ) +      ); + +      while_body.add +      ( +         If.generate +         ( +            registers, +            assembler, +            Operation.not(oob_b.get_value()), +            assembler.merge(oob_b_body) +         ) +      ); +        result.add        (           While.generate           (              registers,              assembler, -            Operation.or -            ( -               Operation.less_than -               ( -                  iterator_a.get_value(), -                  collection_a_size.get_value() -               ), -               Operation.less_than -               ( -                  iterator_b.get_value(), -                  collection_b_size.get_value() -               ) -            ), +            Operation.not(Operation.and(oob_a.get_value(), oob_b.get_value())),              assembler.merge(while_body)           )        );        registers.release(iterator_a, result);        registers.release(iterator_b, result); +      registers.release(oob_a, result); +      registers.release(oob_b, result);        registers.release(collection_a_size, result);        registers.release(collection_b_size, result);        registers.release(storage, result); | 


