comparison src/luan/Luan.java @ 1334:c88b486a9511

make some Luan methods static
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Feb 2019 22:53:57 -0700
parents 25746915a241
children e0cf0d108a77
comparison
equal deleted inserted replaced
1333:25746915a241 1334:c88b486a9511
79 79
80 public Object require(String modName) throws LuanException { 80 public Object require(String modName) throws LuanException {
81 return PackageLuan.require(this,modName); 81 return PackageLuan.require(this,modName);
82 } 82 }
83 83
84 public String toString(Object obj) throws LuanException { 84 public static String luanToString(Object obj) throws LuanException {
85 if( obj instanceof LuanTable ) { 85 if( obj instanceof LuanTable ) {
86 LuanTable tbl = (LuanTable)obj; 86 LuanTable tbl = (LuanTable)obj;
87 return tbl.toStringLuan(); 87 return tbl.toStringLuan();
88 } 88 }
89 if( obj == null ) 89 if( obj == null )
121 if( fn != null ) 121 if( fn != null )
122 return Luan.checkBoolean( Luan.first(fn.call(this,new Object[]{o1,o2})) ); 122 return Luan.checkBoolean( Luan.first(fn.call(this,new Object[]{o1,o2})) );
123 throw new LuanException( "attempt to compare " + Luan.type(o1) + " with " + Luan.type(o2) ); 123 throw new LuanException( "attempt to compare " + Luan.type(o1) + " with " + Luan.type(o2) );
124 } 124 }
125 125
126 public LuanFunction getBinHandler(String op,Object o1,Object o2) throws LuanException { 126 public static LuanFunction getBinHandler(String op,Object o1,Object o2) throws LuanException {
127 if( o1 instanceof LuanTable ) { 127 if( o1 instanceof LuanTable ) {
128 LuanFunction f1 = getHandlerFunction(op,(LuanTable)o1); 128 LuanFunction f1 = getHandlerFunction(op,(LuanTable)o1);
129 if( f1 != null ) 129 if( f1 != null )
130 return f1; 130 return f1;
131 } 131 }
132 return o2 instanceof LuanTable ? getHandlerFunction(op,(LuanTable)o2) : null; 132 return o2 instanceof LuanTable ? getHandlerFunction(op,(LuanTable)o2) : null;
133 } 133 }
134 134
135 public LuanFunction getHandlerFunction(String op,LuanTable t) throws LuanException { 135 public static LuanFunction getHandlerFunction(String op,LuanTable t) throws LuanException {
136 Object f = t.getHandler(op); 136 Object f = t.getHandler(op);
137 if( f == null ) 137 if( f == null )
138 return null; 138 return null;
139 return Luan.checkFunction(f); 139 return Luan.checkFunction(f);
140 } 140 }