From 6e95abbefdd81516c1fed0251c4d1f044575fe14 Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Wed, 19 May 2021 18:04:54 -0500 Subject: [PATCH] Made SPECIAL_VARS in consts.py --- c2logic/compiler.py | 4 ++-- c2logic/consts.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/c2logic/compiler.py b/c2logic/compiler.py index be1d714..51fecd8 100644 --- a/c2logic/compiler.py +++ b/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)) diff --git a/c2logic/consts.py b/c2logic/consts.py index 9e80e92..2662c76 100644 --- a/c2logic/consts.py +++ b/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")