diff options
| author | mryouse | 2022-05-10 05:05:39 +0000 | 
|---|---|---|
| committer | mryouse | 2022-05-10 05:05:39 +0000 | 
| commit | fcff78ad45953c2473270c928e0256917f30d5c2 (patch) | |
| tree | fcbac87029def35873453208082b2e806b6093a5 /std.py | |
| parent | b9db8d7c741ca81e71a56e84b030c67659597735 (diff) | |
add debug toggle
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) | 
