mirror of https://github.com/status-im/nimplay.git
Clean ups.
This commit is contained in:
parent
fdfaa25e8a
commit
df60ceb49a
|
@ -91,25 +91,16 @@ proc generate_defines(keywords: seq[string], global_ctx: GlobalContext): (NimNod
|
|||
var stmts = newStmtList()
|
||||
var tmp_vars = initTable[string, string]()
|
||||
if "msg.sender" in keywords:
|
||||
var tmp_var_name = fmt"msg_sender_tmp_variable_alloc"
|
||||
stmts.add(
|
||||
nnkStmtList.newTree(
|
||||
nnkVarSection.newTree(
|
||||
nnkIdentDefs.newTree(
|
||||
newIdentNode(tmp_var_name),
|
||||
newIdentNode("address"),
|
||||
newEmptyNode()
|
||||
)
|
||||
),
|
||||
nnkCall.newTree(
|
||||
newIdentNode("getCaller"),
|
||||
nnkCommand.newTree(
|
||||
newIdentNode("addr"),
|
||||
newIdentNode(tmp_var_name)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
var
|
||||
tmp_var_name = "msg_sender_tmp_variable_alloc"
|
||||
tmp_var_node = newIdentNode(tmp_var_name)
|
||||
|
||||
var s = quote do:
|
||||
var `tmp_var_node` {.noinit.}: address
|
||||
getCaller(addr `tmp_var_node`)
|
||||
|
||||
stmts.add(s)
|
||||
tmp_vars["msg.sender"] = tmp_var_name
|
||||
|
||||
if "msg.value" in keywords:
|
||||
|
|
|
@ -209,23 +209,18 @@ proc handle_event_defines(event_def: NimNode, global_ctx: var GlobalContext) =
|
|||
|
||||
|
||||
proc get_util_functions(): NimNode =
|
||||
var stmts = newStmtList()
|
||||
|
||||
# template copy_into_ba(to_ba: var untyped, offset: int, from_ba: untyped) =
|
||||
# proc copy_into_ba(to_ba: var auto, offset: int, from_ba: auto) =
|
||||
stmts.add(parseStmt("""
|
||||
quote do:
|
||||
# template copy_into_ba(to_ba: var untyped, offset: int, from_ba: untyped) =
|
||||
# proc copy_into_ba(to_ba: var auto, offset: int, from_ba: auto) =
|
||||
proc copy_into_ba(to_ba: var auto, offset: int, from_ba: auto) =
|
||||
for i, x in from_ba:
|
||||
to_ba[offset + i] = x
|
||||
"""))
|
||||
stmts.add(parseStmt("""
|
||||
|
||||
proc assertNotPayable() =
|
||||
var b {.noinit.}: array[16, byte]
|
||||
getCallValue(addr b)
|
||||
if Uint128.fromBytesBE(b) > 0.stuint(128):
|
||||
revert(nil, 0)
|
||||
"""))
|
||||
stmts # return
|
||||
|
||||
|
||||
proc get_getter_func(var_struct: VariableType): NimNode =
|
||||
|
@ -242,6 +237,8 @@ proc handle_contract_interface(in_stmts: NimNode): NimNode =
|
|||
global_ctx = GlobalContext()
|
||||
|
||||
main_out_stmts.add(get_util_functions())
|
||||
# var util_funcs = get_util_functions()
|
||||
# discard util_funcs
|
||||
|
||||
for child in in_stmts:
|
||||
if child.kind == nnkVarSection:
|
||||
|
|
Loading…
Reference in New Issue