Skip to content

Commit

Permalink
fix sym resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed May 22, 2022
1 parent dcd997d commit 62e399f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions vyper/ir/compile_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def _height_of(witharg):
o.extend(["_sym_subcode_size", begincode, "_mem_deploy_start", "CODECOPY"])

# calculate the len of runtime code
o.extend(["_sym_subcode_size"] + PUSH(padding) + ["ADD"]) # stack: len
o.extend(["_OFST", "_sym_subcode_size", padding]) # stack: len
o.extend(["_mem_deploy_start"]) # stack: len mem_ofst
o.extend(["RETURN"])

Expand Down Expand Up @@ -931,6 +931,11 @@ def assembly_to_evm(assembly, start_pos=0, insert_vyper_signature=False):
runtime_code, runtime_code_start, runtime_code_end = None, None, None
pos = start_pos

bytecode_suffix = b""
if insert_vyper_signature:
# CBOR encoded: {"vyper": [major,minor,patch]}
bytecode_suffix += b"\xa1\x65vyper\x83" + bytes(list(version_tuple))

# go through the code, resolving symbolic locations
# (i.e. JUMPDEST locations) to actual code locations
for i, item in enumerate(assembly):
Expand Down Expand Up @@ -981,6 +986,7 @@ def assembly_to_evm(assembly, start_pos=0, insert_vyper_signature=False):
runtime_code, sub_map = assembly_to_evm(
item, start_pos=pos, insert_vyper_signature=True
)

assert item[0].startswith("_DEPLOY_MEM_OFST_")
ctor_mem_size = int(item[0][len("_DEPLOY_MEM_OFST_") :])

Expand All @@ -994,6 +1000,8 @@ def assembly_to_evm(assembly, start_pos=0, insert_vyper_signature=False):
else:
pos += 1

pos += len(bytecode_suffix)

code_end = pos - start_pos
posmap["_sym_code_end"] = code_end
posmap["_mem_deploy_start"] = runtime_code_start
Expand Down Expand Up @@ -1048,10 +1056,9 @@ def assembly_to_evm(assembly, start_pos=0, insert_vyper_signature=False):
# Should never reach because, assembly is create in _compile_to_assembly.
raise Exception("Weird symbol in assembly: " + str(item)) # pragma: no cover

o += bytecode_suffix

assert len(o) == pos - start_pos, (len(o), pos, start_pos)
line_number_map["breakpoints"] = list(line_number_map["breakpoints"])
line_number_map["pc_breakpoints"] = list(line_number_map["pc_breakpoints"])
if insert_vyper_signature:
# CBOR encoded: {"vyper": [major,minor,patch]}
o += b"\xa1\x65vyper\x83" + bytes(list(version_tuple))
return o, line_number_map

0 comments on commit 62e399f

Please sign in to comment.