Mercurial Hosting > luan
comparison core/src/luan/LuanState.java @ 647:8e8c30b72e9b
move methods from LuanState to Luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2016 20:39:14 -0600 |
parents | cdc70de628b5 |
children | d3e5414bdf4c |
comparison
equal
deleted
inserted
replaced
646:cdc70de628b5 | 647:8e8c30b72e9b |
---|---|
60 LuanFunction fn = BasicLuan.load(this,cmd,"eval",env,true); | 60 LuanFunction fn = BasicLuan.load(this,cmd,"eval",env,true); |
61 return fn.call(this); | 61 return fn.call(this); |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 public Boolean checkBoolean(Object obj) throws LuanException { | |
66 if( obj instanceof Boolean ) | |
67 return (Boolean)obj; | |
68 throw new LuanException("attempt to use a " + Luan.type(obj) + " value as a boolean" ); | |
69 } | |
70 | |
71 public String checkString(Object obj) throws LuanException { | |
72 if( obj instanceof String ) | |
73 return (String)obj; | |
74 throw new LuanException("attempt to use a " + Luan.type(obj) + " value as a string" ); | |
75 } | |
76 | |
77 public LuanFunction checkFunction(Object obj) throws LuanException { | |
78 if( obj instanceof LuanFunction ) | |
79 return (LuanFunction)obj; | |
80 throw new LuanException("attempt to call a " + Luan.type(obj) + " value" ); | |
81 } | |
82 | |
83 abstract public boolean isLessThan(Object o1,Object o2) throws LuanException; | |
84 | |
85 public String toString(Object obj) throws LuanException { | 65 public String toString(Object obj) throws LuanException { |
86 if( obj instanceof LuanTable ) { | 66 if( obj instanceof LuanTable ) { |
87 LuanTable tbl = (LuanTable)obj; | 67 LuanTable tbl = (LuanTable)obj; |
88 return tbl.toString(this); | 68 return tbl.toString(this); |
89 } | 69 } |
108 | 88 |
109 /* | 89 /* |
110 public Number checkNumber(Object obj) throws LuanException { | 90 public Number checkNumber(Object obj) throws LuanException { |
111 if( obj instanceof Number ) | 91 if( obj instanceof Number ) |
112 return (Number)obj; | 92 return (Number)obj; |
113 throw new LuanException(this, "attempt to perform arithmetic on '"+context()+"' (a " + Luan.type(obj) + " value)" ); | 93 throw new LuanException( "attempt to perform arithmetic on '"+context()+"' (a " + Luan.type(obj) + " value)" ); |
114 } | 94 } |
115 */ | 95 */ |
116 } | 96 } |