aboutsummaryrefslogtreecommitdiff
path: root/std.py
diff options
context:
space:
mode:
Diffstat (limited to 'std.py')
-rw-r--r--std.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/std.py b/std.py
index 1393acf..26c6793 100644
--- a/std.py
+++ b/std.py
@@ -66,6 +66,13 @@ def std_if(cond, t_branch, f_branch):
ret = evaluate_expression(f_branch)
return ret
+# type validation
+def std_is_string(arg):
+ if isinstance(arg, NebString):
+ return NebBool(True)
+ else:
+ return NebBool(False)
+
def evaluate_expression(expr):
if not expr.symbol.name in STD:
raise Exception(f"no such symbol: {expr.symbol.name}")
@@ -83,6 +90,7 @@ def evaluate_expression(expr):
if isinstance(in_sig[idx], sig[idx]):
validated += 1
if validated == len(sig):
+ print(f"{value.func.args}")
ret = value.impl(*(expr.args))
return ret
@@ -122,7 +130,11 @@ def build_std():
STD["concat"] = [concat_string_string]
# flow control
- if_bool_expr_expr = FuncImpl(NebFunction("if", [NebBool, NebExpression, NebExpression], NebType.ANY), std_if)
+ if_bool_expr_expr = FuncImpl(NebFunction("if", [NebBool, NebExpression, NebExpression], NebAny), std_if)
STD["if"] = [if_bool_expr_expr]
+ # type checking
+ is_string = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_string)
+ STD["string?"] = [is_string]
+
build_std()