From fcff78ad45953c2473270c928e0256917f30d5c2 Mon Sep 17 00:00:00 2001 From: mryouse Date: Tue, 10 May 2022 05:05:39 +0000 Subject: add debug toggle --- std.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'std.py') diff --git a/std.py b/std.py index f957b53..6f591fc 100644 --- a/std.py +++ b/std.py @@ -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) -- cgit v1.2.3