Skip to content

Commit

Permalink
Change: Reduce D0xx usage where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Apr 21, 2024
1 parent 26f271f commit 8f79c21
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nml/actions/action2var.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def __init__(self, action_feature, var_range=0x89):
self.var_list = []
self.var_list_size = 0
self.proc_call_list = []
self.in_store_op = False

def preprocess_binop(self, expr):
"""
Expand Down Expand Up @@ -571,6 +572,9 @@ def parse_binop(self, expr):
if expr.op.act2_num is None:
expr.supported_by_action2(True)

if expr.op == nmlop.STO_TMP:
self.in_store_op = True

if (
isinstance(expr.expr2, (expression.ConstantNumeric, expression.Variable))
or isinstance(expr.expr2, (VarAction2LoadTempVar, VarAction2LoadCallParam))
Expand Down Expand Up @@ -601,6 +605,9 @@ def parse_binop(self, expr):

self.parse(expr2)

if expr.op == nmlop.STO_TMP:
self.in_store_op = False

def parse_constant(self, expr):
var = VarAction2Var(0x1A, 0, expr.value)
self.var_list.append(var)
Expand All @@ -614,7 +621,7 @@ def parse_param(self, expr):
self.var_list_size += var.get_size()

def parse_string(self, expr):
str_id, actions = action4.get_string_action4s(0, 0xD0, expr)
str_id, actions = action4.get_string_action4s(0, 0xDC if self.in_store_op else 0xD0, expr)
self.extra_actions.extend(actions)
self.parse_constant(expression.ConstantNumeric(str_id))

Expand Down

0 comments on commit 8f79c21

Please sign in to comment.