From 95da50a02a58a9cce6fe2b824ca244038fba3cfd Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 12 Apr 2022 16:43:51 +0200 Subject: [PATCH] add def native --- bootstrap/ISBPL.java | 13 +++++++++++++ std.isbpl | 1 + 2 files changed, 14 insertions(+) diff --git a/bootstrap/ISBPL.java b/bootstrap/ISBPL.java index dfc3dfa..5282c5b 100644 --- a/bootstrap/ISBPL.java +++ b/bootstrap/ISBPL.java @@ -15,6 +15,10 @@ import java.util.function.Supplier; */ public class ISBPL { + // TODO: fully implement JIO + // public static final boolean ENABLE_JINTEROP = true; + + static boolean debug = false; public ISBPLDebugger.IPC debuggerIPC = new ISBPLDebugger.IPC(); ArrayList types = new ArrayList<>(); @@ -846,6 +850,15 @@ public class ISBPL { } }; break; + case "def": + func = (stack) -> { + ISBPLObject str = stack.pop(); + ISBPLObject callable = stack.pop(); + String s = toJavaString(str); + callable.checkType(getType("func")); + addFunction(s, (ISBPLCallable) callable.object); + }; + break; default: func = natives.get(name); break; diff --git a/std.isbpl b/std.isbpl index ecf04e2..fc94e3d 100644 --- a/std.isbpl +++ b/std.isbpl @@ -64,6 +64,7 @@ native % native ^ native fcall +native def func ++ { 1 + } func -- { 1 - }