diff options
Diffstat (limited to 'std.py')
| -rw-r--r-- | std.py | 19 | 
1 files changed, 19 insertions, 0 deletions
| @@ -5,6 +5,10 @@ from collections import namedtuple  FuncImpl = namedtuple("FuncImpl", ("func", "impl"))  STD = {} +DEBUG = True + +def _get_debug(): +    return DEBUG  def std_exit(status=0):      sys.exit(status) @@ -15,6 +19,16 @@ def std_print(arg):      #return []  # TODO this should return empty list      return NebLiteral(NebType.BOOL, True) +def std_debug_on(): +    global DEBUG +    DEBUG = True +    return NebLiteral(NebType.BOOL, True) + +def std_debug_off(): +    global DEBUG +    DEBUG = False +    return NebLiteral(NebType.BOOL, True) +  # math  def std_add(arg1, arg2):      typ = NebType.INT @@ -45,6 +59,11 @@ def build_std():      exit_int = FuncImpl(NebFunction("exit", [NebType.INT], NebType.BOOL), std_exit)      STD["exit"] = build_sig_dict(exit_, exit_int) +    debug_on = FuncImpl(NebFunction("debug-on", [], NebType.BOOL), std_debug_on) +    STD["debug-on"] = build_sig_dict(debug_on) +    debug_off = FuncImpl(NebFunction("debug-off", [], NebType.BOOL), std_debug_off) +    STD["debug-off"] = build_sig_dict(debug_off) +      # arithmetic      add_int_int = FuncImpl(NebFunction("+", [NebType.INT, NebType.INT], NebType.INT), std_add)      add_int_float = FuncImpl(NebFunction("+", [NebType.INT, NebType.FLOAT], NebType.FLOAT), std_add) | 
