diff --git a/dasy/parser/parse.py b/dasy/parser/parse.py index 6392252..6e7550d 100644 --- a/dasy/parser/parse.py +++ b/dasy/parser/parse.py @@ -228,6 +228,10 @@ def parse_node( ) case models.Float(node): raise NotImplementedError("Floating point not supported (yet)") + case models.Dict(node): + keys = [parse_node(k) for k in node.keys()] + values = [parse_node(v) for v in node.values()] + ast_node = build_node(vy_nodes.Dict, keys=keys, values=values) case _: raise ValueError(f"No match for node {node}. Unsupported node type.") return add_src_map(SRC, node, ast_node) diff --git a/examples/nonreentrantenforcer.vy b/examples/nonreentrantenforcer.vy new file mode 100644 index 0000000..80f8850 --- /dev/null +++ b/examples/nonreentrantenforcer.vy @@ -0,0 +1,6 @@ +#pragma evm-version cancun + +@nonreentrant("lock") +@external +def func0(): + raw_call(msg.sender, b"", value=0) diff --git a/examples/reference_types.dasy b/examples/reference_types.dasy index 35bb3c7..a9cbf6b 100644 --- a/examples/reference_types.dasy +++ b/examples/reference_types.dasy @@ -1,3 +1,4 @@ +(pragma :evm-version "cancun") (defstruct Person name (string 100) age :uint256) @@ -33,3 +34,6 @@ ;; Person struct is copied into memory (defvar p Person self/person) (set-in p name "Solidity")) + +(defn literalPerson [] Person :external + (Person {:name "Foo" :age 100})) diff --git a/examples/transient_nonreentrant.dasy b/examples/transient_nonreentrant.dasy index 042ecc9..3833ac0 100644 --- a/examples/transient_nonreentrant.dasy +++ b/examples/transient_nonreentrant.dasy @@ -1,4 +1,8 @@ + +;; use `pragma` to specify the EVM version (pragma :evm-version "cancun") +;; this reentrancy lock will use tstore/tload (defn func0 [] [:external (nonreentrant "lock")] (raw_call msg/sender b"" :value 0)) + diff --git a/tests/test_dasy.py b/tests/test_dasy.py index 0ab76b1..a467c25 100644 --- a/tests/test_dasy.py +++ b/tests/test_dasy.py @@ -140,6 +140,7 @@ def test_if_expr(): def test_struct(): c = compile_src( """ + (pragma :evm-version "cancun") (defstruct Person age :uint256) (defvars person (public Person)) @@ -149,10 +150,13 @@ def test_struct(): (def mPers Person self/person) (set-in mPers age 10) mPers) + (defn literalPerson [] Person :external + (Person {:age 100 :name "Foo"})) """ ) assert c.person()[0] == 12 assert c.memoryPerson() == (10,) + # assert c.literalPerson() == (100,"Foo") def test_arrays():