Skip to content

Commit

Permalink
Merge pull request #160 from Thunno/fix-c
Browse files Browse the repository at this point in the history
Fix Context Mode (c flag)
  • Loading branch information
nayakrujul authored Jul 29, 2023
2 parents accf881 + b7bd211 commit aac10a5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
Binary file modified src/__pycache__/test_run.cpython-39.pyc
Binary file not shown.
Binary file modified src/thunno2/__pycache__/commands.cpython-39.pyc
Binary file not shown.
Binary file modified src/thunno2/__pycache__/flags.cpython-39.pyc
Binary file not shown.
Binary file modified src/thunno2/__pycache__/helpers.cpython-39.pyc
Binary file not shown.
Binary file modified src/thunno2/__pycache__/interpreter.cpython-39.pyc
Binary file not shown.
Binary file modified src/thunno2/__pycache__/version.cpython-39.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions src/thunno2/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def run(flags, code, inputs):
commands.ctx.og_input_list = new_inputs.copy()
commands.ctx.other_il = new_inputs.copy()
print(line, "--> ", end="")
interpreter.run(code, context=0, iteration_index=0)
interpreter.run(code, context=None, iteration_index=0)
process_output_flags(new_flags)
return None

Expand Down Expand Up @@ -210,7 +210,7 @@ def run(flags, code, inputs):
commands.ctx.other_il = new_inputs.copy()
commands.ctx.stack = commands.Stack()
print(line, "--> ", end="")
interpreter.run(code, context=0, iteration_index=0)
interpreter.run(code, context=None, iteration_index=0)
process_output_flags(new_flags, False)
actual_output = next(commands.ctx.stack.rmv(1))
print(actual_output, end="\t")
Expand All @@ -223,5 +223,5 @@ def run(flags, code, inputs):
inputs = process_input_flags(flags, inputs)
commands.ctx.og_input_list = inputs.copy()
commands.ctx.other_il = inputs.copy()
interpreter.run(code, context=0, iteration_index=0)
interpreter.run(code, context=None, iteration_index=0)
process_output_flags(flags)
12 changes: 6 additions & 6 deletions src/thunno2/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,25 +669,25 @@ def run(code, *, context=None, iteration_index=None):
i = 0
while True:
old_stack = Stack(copy.deepcopy(list(ctx.stack).copy()))
run(cond, context=0, iteration_index=i)
run(cond, context=context, iteration_index=i)
z = next(ctx.stack.rmv(1))
ctx.stack = Stack(copy.deepcopy(old_stack))
if not z:
break
run(body, context=0, iteration_index=i)
run(body, context=context, iteration_index=i)
i += 1
elif desc == "forever loop":
i = 0
while True:
run(info, context=0, iteration_index=i)
run(info, context=context, iteration_index=i)
i += 1
elif desc == "if statement":
if_true, if_false = info
a = next(ctx.stack.rmv(1))
if a:
run(if_true, context=0, iteration_index=1)
run(if_true, context=context, iteration_index=1)
else:
run(if_false, context=0, iteration_index=0)
run(if_false, context=context, iteration_index=0)
elif desc == "execute without popping":
if info != Void:
values = info(pop=False)
Expand Down Expand Up @@ -816,7 +816,7 @@ def test(cod, inp=(), stk=(), warn=True):
ctx.other_il = list(inp)
ctx.warnings = warn
tokenised = tokenise(cod)[1]
run(tokenised, context=0, iteration_index=0)
run(tokenised, context=None, iteration_index=0)
print(ctx.stack)
if ctx.implicit_print:
print(ctx.stack[0])

0 comments on commit aac10a5

Please sign in to comment.