Mercurial Hosting > luan
diff core/src/luan/impl/$Luan.java @ 652:067d9470184d
compile SetStmt and ForStmt
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 Apr 2016 23:26:06 -0600 |
parents | 140cc5191b7a |
children |
line wrap: on
line diff
--- a/core/src/luan/impl/$Luan.java Fri Apr 01 17:24:44 2016 -0600 +++ b/core/src/luan/impl/$Luan.java Mon Apr 04 23:26:06 2016 -0600 @@ -40,6 +40,19 @@ } + private static List<Settable> listSettable = new ArrayList<Settable>(); + + static int addSettable(Settable settable) { + int i = listSettable.size(); + listSettable.add(settable); + return i; + } + + public static Settable getSettable(int i) { + return listSettable.get(i); + } + + public static Object first(Object obj) { return Luan.first(obj); } @@ -76,6 +89,10 @@ return Luan.checkBoolean(o); } + public static LuanFunction checkFunction(Object o) throws LuanException { + return Luan.checkFunction(o); + } + public static boolean not(Object o) throws LuanException { return !checkBoolean(o); } @@ -194,4 +211,20 @@ public static void nop(Object o) {} + + public static void set(LuanStateImpl luan,Settable[] vars,Object obj) throws LuanException { + if( obj instanceof Object[] ) { + Object[] vals = (Object[])obj; + for( int i=0; i<vars.length; i++ ) { + Object val = i < vals.length ? vals[i] : null; + vars[i].set(luan,val); + } + } else { + vars[0].set(luan,obj); + for( int i=1; i<vars.length; i++ ) { + vars[i].set(luan,null); + } + } + } + }