2024-08-28 08:52:07 +02:00
|
|
|
from juic.datatypes import *
|
|
|
|
from juic.eval import *
|
|
|
|
|
|
|
|
def juiPrint(*args):
|
2024-08-28 13:31:17 +02:00
|
|
|
print("[print]", *(juiValueString(a) for a in args))
|
2024-08-28 08:52:07 +02:00
|
|
|
|
|
|
|
def juiLen(x):
|
|
|
|
if type(x) not in [str, list]:
|
|
|
|
raise JuiTypeError("len")
|
|
|
|
return len(x)
|
|
|
|
|
2024-08-28 10:43:23 +02:00
|
|
|
R_record = RecordType("record", None)
|
|
|
|
R_subrecord = RecordType("subrecord", R_record)
|
2024-08-28 15:18:39 +02:00
|
|
|
R_jwidget = RecordType("jwidget", None)
|
|
|
|
R_jlabel = RecordType("jlabel", R_jwidget)
|
|
|
|
R_jfkeys = RecordType("jfkeys", R_jwidget)
|
2024-08-28 10:43:23 +02:00
|
|
|
|
2024-08-28 08:52:07 +02:00
|
|
|
builtinClosure = Closure(parent=None, scope=MutableScopeData(defs={
|
|
|
|
"print": (0, BuiltinFunction(juiPrint)),
|
|
|
|
"len": (0, BuiltinFunction(juiLen)),
|
|
|
|
|
|
|
|
# TODO: Remove the built-in record type "record" used for testing
|
2024-08-28 10:43:23 +02:00
|
|
|
"record": (0, R_record),
|
|
|
|
"subrecord": (0, R_subrecord),
|
2024-08-28 15:18:39 +02:00
|
|
|
"jwidget": (0, R_jwidget),
|
|
|
|
"jlabel": (0, R_jlabel),
|
|
|
|
"jfkeys": (0, R_jfkeys),
|
2024-08-28 08:52:07 +02:00
|
|
|
|
|
|
|
}, timestamp=1))
|