fixing a couple bugs
This commit is contained in:
@@ -189,7 +189,7 @@ class X86_64Generator(Generator):
|
|||||||
elif type(new_value) == str: # we're changing a variable to the value of a register
|
elif type(new_value) == str: # we're changing a variable to the value of a register
|
||||||
#lines.append(f"mov QWORD [rsp + {var_pos}], {new_value}\n\t")
|
#lines.append(f"mov QWORD [rsp + {var_pos}], {new_value}\n\t")
|
||||||
lines.append(f"mov {var_pos}, {new_value}\n\t")
|
lines.append(f"mov {var_pos}, {new_value}\n\t")
|
||||||
scope.table[var_name]["type"] = IntNode
|
#scope.table[var_name]["type"] = IntNode
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -227,7 +227,8 @@ class X86_64Generator(Generator):
|
|||||||
|
|
||||||
elif type(new_value) == str: # we're changing a variable to the value of a register
|
elif type(new_value) == str: # we're changing a variable to the value of a register
|
||||||
lines.append(f"mov QWORD [rsp + {var_pos}], {new_value}\n\t")
|
lines.append(f"mov QWORD [rsp + {var_pos}], {new_value}\n\t")
|
||||||
scope.table[var_name]["type"] = IntNode
|
#scope.table[var_name]["type"] = IntNode
|
||||||
|
|
||||||
if scope.table[var_name]["type"] != old_var_type:
|
if scope.table[var_name]["type"] != old_var_type:
|
||||||
warning(self.code, f"Changing the type of \"{var_name}\" at runtime is considered bad practice.")
|
warning(self.code, f"Changing the type of \"{var_name}\" at runtime is considered bad practice.")
|
||||||
|
|
||||||
@@ -697,6 +698,7 @@ class X86_64Generator(Generator):
|
|||||||
with open(self.output_path + ".asm", "w") as f:
|
with open(self.output_path + ".asm", "w") as f:
|
||||||
f.write("; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~\n\n")
|
f.write("; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~\n\n")
|
||||||
|
|
||||||
|
if len(self.constants) > 0:
|
||||||
f.write("section .data\n")
|
f.write("section .data\n")
|
||||||
for name, const in self.constants.items():
|
for name, const in self.constants.items():
|
||||||
value = const["value"]
|
value = const["value"]
|
||||||
@@ -718,6 +720,7 @@ class X86_64Generator(Generator):
|
|||||||
f.write(f"dq {float(value)}")
|
f.write(f"dq {float(value)}")
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
|
if len(self.buffers) > 0:
|
||||||
f.write("section .bss\n")
|
f.write("section .bss\n")
|
||||||
for buf, size in self.buffers.items():
|
for buf, size in self.buffers.items():
|
||||||
f.write(f"{buf} resb {size}\n")
|
f.write(f"{buf} resb {size}\n")
|
||||||
|
5
out.asm
Normal file
5
out.asm
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~
|
||||||
|
|
||||||
|
section .text
|
||||||
|
global _start
|
||||||
|
_start:
|
Reference in New Issue
Block a user