Slowly trying to add function calls, cases for RETURN and CALL

This commit is contained in:
Krzosa Karol
2022-06-23 09:58:54 +02:00
parent b8bcdab073
commit bcfd586552
2 changed files with 129 additions and 81 deletions

View File

@@ -14,6 +14,10 @@ def should_skip(T, op):
and op != "GT" and op != "LT" and op != "GTE" and op != "LTE":
return True
# This function inserts generated code into the specified file
# it requires a specific comment to be triggered.
# Lossing data would be terrible so we also backup that file
# in case something bad happens
def update_file(filename, comment_name, data_to_write):
begin = f"""//
// *Begin* of {comment_name} generated using code_generating_script.py
@@ -55,13 +59,15 @@ def update_file(filename, comment_name, data_to_write):
if True:
result = ""
enum_members = []
enum_members.append("BC_END_OF_INSTRUCTIONS")
enum_members.append("BC_POP_STACK")
enum_members.append("BC_PUSH_STACK")
enum_members.append("BC_LOAD_CONSTANT")
enum_members.append("BC_STORE_CONSTANT")
enum_members.append("BC_CALL")
enum_members = [
"BC_END_OF_INSTRUCTIONS",
"BC_POP_STACK",
"BC_PUSH_STACK",
"BC_LOAD_CONSTANT",
"BC_STORE_CONSTANT",
"BC_CALL",
"BC_CALL_RETURN",
]
load_store = ["LOAD_FROM_MEMORY", "STORE_TO_MEMORY"]
for op in load_store: