Skip to content

Commit

Permalink
这回样例都过了
Browse files Browse the repository at this point in the history
  • Loading branch information
tao1122334 committed Jan 6, 2024
1 parent 5d1d9a4 commit 8c67849
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions phase4/splc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
max_var_num = 500
register_table = [None] * num_registers
stack = ['empty']
queue = Queue()
queue = []
argmap = {}
varmap = {}
fun_save = []
Expand Down Expand Up @@ -175,7 +175,8 @@ def translate(tac: str):

# 传参
for p in argmap[f]:
arg = reg(queue.get())
# arg = reg(queue.get())
arg=reg(queue.pop())
para = reg(p)
from_heap2heap(arg, para, fi_command)

Expand Down Expand Up @@ -233,7 +234,8 @@ def translate(tac: str):
# command.append(f'{n}')
if re.fullmatch(f'ARG {id}', tac): # IF x == y GOTO z
_, n = re.split('ARG | ', tac)
queue.put(n)
# queue.put(n)
queue.append(n)
if re.fullmatch(f'WRITE {id}', tac): # IF x == y GOTO z
_, n = re.split('WRITE | ', tac)
fi_command.append(f'lw $4, {reg(n)}')
Expand Down Expand Up @@ -275,7 +277,7 @@ def translate(tac: str):
else:
with open(sys.argv[1]+'.s','a') as s:
s.write("\n".join(res))
s.write("\n")
s.write("\n\n")

with open(sys.argv[1] + '.s', 'a') as s:
s.write('end:')
Expand Down

0 comments on commit 8c67849

Please sign in to comment.