Browse Source

Made SPECIAL_VARS in consts.py

master
Raphael Roberts 5 years ago
parent
commit
6e95abbefd
  1. 4
      c2logic/compiler.py
  2. 1
      c2logic/consts.py

4
c2logic/compiler.py

@ -8,7 +8,7 @@ from pycparser.c_ast import (
Compound, Constant, DeclList, Enum, FileAST, FuncDecl, Struct, TypeDecl, Typename
)
from .consts import func_binary_ops, func_unary_ops
from .consts import func_binary_ops, func_unary_ops, SPECIAL_VARS
from .instructions import (
Instruction,
Noop,
@ -338,7 +338,7 @@ class Compiler(c_ast.NodeVisitor):
varname = node.name
if varname not in self.functions:
varname = self.get_varname(varname)
if varname in ("links", "ipt", "counter", "time", "unit"):
if varname in SPECIAL_VARS:
varname = "@" + varname
self.push(Set("__rax", varname))

1
c2logic/consts.py

@ -34,3 +34,4 @@ func_binary_ops = ["pow", "max", "min", "angle", "len", "land", "idiv", "strictE
func_unary_ops = ["abs", "log", "log10", "sin", "cos", "tan", "floor", "ceil", "sqrt", "rand"]
binary_ops.update(dict(zip(func_binary_ops, func_binary_ops)))
unary_ops.update(dict(zip(func_unary_ops, func_unary_ops)))
SPECIAL_VARS = ("links", "ipt", "counter", "time", "unit")
Loading…
Cancel
Save