Compare commits

..

No commits in common. '2bcabcc66892ab302cbfae09e86de8c596c742b3' and 'c706f527ac3c01a4f98b8cea45ec7a9d70292b3c' have entirely different histories.

  1. 42
      src/rustint/core.clj
  2. 70
      test/rustint/core_test.clj

@ -2097,33 +2097,10 @@
; [; (fn main ( ) { println! ( "{}" , TRES ) }) [use std :: io ; const TRES : i64 = 3] :sin-errores [[0] [[io [lib ()] 0] [TRES [const i64] 3]]] 0 [[CAL 0] HLT] []] ; [; (fn main ( ) { println! ( "{}" , TRES ) }) [use std :: io ; const TRES : i64 = 3] :sin-errores [[0] [[io [lib ()] 0] [TRES [const i64] 3]]] 0 [[CAL 0] HLT] []]
; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn maxnil [a1 a2]
(cond
(and (nil? a1) (nil? a2)) nil
(nil? a1) a2
(nil? a2) a1
:else (max a1 a2)
)
)
(defn last_const_idx [seq]
(reduce maxnil (map-indexed (fn [idx itm] (if itm idx nil)) (map #(= 'const %1) seq)))
)
(defn cargar-const-en-tabla [amb] (defn cargar-const-en-tabla [amb]
(cond (cond
(not= (get amb 3) :sin-errores) amb (not= (get amb 4) :sin-errores) amb
:else (let [ :else nil
syp (get amb 2),
ctx (get amb 4),
idx_const (last_const_idx syp),
const_name (get syp (+ 1 idx_const)),
const_type (get syp (+ 3 idx_const)),
const_value (get syp (+ 5 idx_const)),
]
(assoc-in amb [4 1 (count (get ctx 1))] [const_name ['const const_type] const_value])
)
) )
) )
@ -2139,17 +2116,10 @@
; [{ (let x : i64 = 10 ; println! ( "{}" , x ) }) [fn main ( )] :sin-errores [[0 1] [[main [fn [() ()]] 2]]] 0 [[CAL 2] HLT] []] ; [{ (let x : i64 = 10 ; println! ( "{}" , x ) }) [fn main ( )] :sin-errores [[0 1] [[main [fn [() ()]] 2]]] 0 [[CAL 2] HLT] []]
; ^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^ ; ^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn inicializar-contexto-local [amb] ; TODO
(cond ; (defn inicializar-contexto-local
(not= (get amb 3) :sin-errores) amb ;
:else (let [ ;)
ctx (get amb 4),
]
(assoc-in amb [4 0 (count (get ctx 0))] (count (get ctx 1)))
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; RESTAURAR-CONTEXTO-ANTERIOR: Recibe un ambiente y, si su estado no es :sin-errores, lo devuelve intacto. ; RESTAURAR-CONTEXTO-ANTERIOR: Recibe un ambiente y, si su estado no es :sin-errores, lo devuelve intacto.

@ -645,10 +645,7 @@
(list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}")) (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}"))
['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3] ['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3]
:sin-errores :sin-errores
[[0] [ [[0] [['io ['lib '()] 0]]]
['io ['lib '()] 0]
]
]
0 0
[['CAL 0] 'HLT] [['CAL 0] 'HLT]
[] []
@ -659,11 +656,7 @@
(list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}")) (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}"))
['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3] ['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3]
:sin-errores :sin-errores
[[0] [ [[0] [['io ['lib '()] 0] ['TRES ['const 'i64] 3]]]
['io ['lib '()] 0]
['TRES ['const 'i64] 3]
]
]
0 0
[['CAL 0] 'HLT] [['CAL 0] 'HLT]
[] []
@ -672,62 +665,3 @@
) )
) )
) )
(deftest test-inicializar-contexto-local-01
(testing "Test 01 inicializar-contexto-local"
(is (=
(inicializar-contexto-local
[
(symbol "{")
(list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}"))
['fn 'main (symbol "(") (symbol ")")]
8
[[0] [['main ['fn [() ()]] 2]]]
0
[['CAL 2] 'HLT]
[]
]
)
[
(symbol "{")
(list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}"))
['fn 'main (symbol "(") (symbol ")")]
8
[[0] [['main ['fn [() ()]] 2]]]
0
[['CAL 2] 'HLT]
[]
]
))
)
)
(deftest test-inicializar-contexto-local-02
(testing "Test 02 inicializar-contexto-local"
(is (=
(inicializar-contexto-local
[
(symbol "{")
(list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}"))
['fn 'main (symbol "(") (symbol ")")]
:sin-errores
[[0] [['main ['fn [() ()]] 2]]]
0
[['CAL 2] 'HLT]
[]
]
)
[
(symbol "{")
(list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}"))
['fn 'main (symbol "(") (symbol ")")]
:sin-errores
[[0 1] [['main ['fn [() ()]] 2]]]
0
[['CAL 2] 'HLT]
[]
]
)
)
)
)

Loading…
Cancel
Save