add callmethod function

This commit is contained in:
Daniella 2022-04-17 17:40:25 +02:00
parent 4cd3baeac2
commit f5307d2b97
3 changed files with 29 additions and 0 deletions

View file

@ -887,6 +887,15 @@ public class ISBPL {
addFunction(t, "=" + s, (stack1) -> t.varget(stack1.pop()).put(var, stack1.pop())); addFunction(t, "=" + s, (stack1) -> t.varget(stack1.pop()).put(var, stack1.pop()));
}; };
break; break;
case "callmethod":
func = (stack) -> {
ISBPLObject obj = stack.pop();
ISBPLObject str = stack.pop();
String s = toJavaString(str);
stack.push(obj);
obj.type.methods.get(s).call(stack);
};
break;
case "jio.class": case "jio.class":
func = (stack) -> { func = (stack) -> {
ISBPLObject str = stack.pop(); ISBPLObject str = stack.pop();

View file

@ -2,3 +2,22 @@
def iota_storage 0 =iota_storage def iota_storage 0 =iota_storage
func iota { iota_storage dup ++ =iota_storage } func iota { iota_storage dup ++ =iota_storage }
func riota { 0 1 =iota_storage } func riota { 0 1 =iota_storage }
def enum_storage 0 =enum_storage
def enum_type_storage 0 =enum_type_storage
def enum_holder_storage 0 =enum_holder_storage
func mkenum {
mktype =enum_type_storage
0 =enum_storage
-1 enum_type_storage settype dup =enum_holder_storage
}
func enum {
def name =name
def r enum_storage enum_type_storage settype =r
name enum_type_storage deffield
r "=" name strconcat enum_holder_storage callmethod
enum_storage inc
r
}

View file

@ -67,6 +67,7 @@ native fcall
native deffunc native deffunc
native defmethod native defmethod
native deffield native deffield
native callmethod
func ++ { 1 + } func ++ { 1 + }
func -- { 1 - } func -- { 1 - }