Skip to content

Commit

Permalink
Fix variables names in declarations (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
a5kin committed Mar 21, 2019
1 parent 7600cd2 commit 4e978c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions xentica/core/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def op_func(self_var, value):
self_var.declare_once()
code = "%s %s= %s;\n" % (self_var.var_name, oper, value)
self_var.bsca.append_code(code)
has_fallback = hasattr(self_var, "fallback_name")
is_default = self_var.fallback_name == "var"
if has_fallback and is_default:
self_var.fallback_name = self.var_name
return self_var
return op_func

Expand Down
2 changes: 1 addition & 1 deletion xentica/core/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def var_name(self):
if isinstance(var, self.__class__):
if hash(self) == hash(var) and k != "self_var":
return k
return "%s%d" % (self.fallback_name, abs(hash(self)))
return self.fallback_name

def declare_once(self):
"""Declare variable and assign initial value to it."""
Expand Down

0 comments on commit 4e978c0

Please sign in to comment.