Switching to JSValue throughout. Implementing operators per base type.
git-svn-id: svn://10.0.0.236/trunk@32415 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,40 +1,38 @@
|
||||
class JSObject extends JSValue {
|
||||
|
||||
JSObject(String aType, String aValue)
|
||||
static JSObject JSUndefined = new JSObject("undefined");
|
||||
|
||||
JSObject(String aValue)
|
||||
{
|
||||
type = aType;
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
String print(String indent)
|
||||
{
|
||||
return indent + "JSObject " + type + " : " + value + "\n";
|
||||
return indent + "JSObject : " + value + "\n";
|
||||
}
|
||||
|
||||
void evalLHS(Environment theEnv)
|
||||
{
|
||||
if (type == "object") {
|
||||
theEnv.theStack.push(new StackValue(value));
|
||||
}
|
||||
else {
|
||||
System.out.println("EvalLHS on non-object");
|
||||
}
|
||||
theEnv.theStack.push(this);
|
||||
}
|
||||
|
||||
void eval(Environment theEnv)
|
||||
{
|
||||
if (type.equals("object")) {
|
||||
Double d = (Double)(theEnv.theGlobals.get(value));
|
||||
if (d == null) {
|
||||
System.out.println("Accessed undefined : " + value);
|
||||
theEnv.theStack.push(new StackValue(0.0));
|
||||
}
|
||||
else
|
||||
theEnv.theStack.push(new StackValue(d.doubleValue()));
|
||||
JSValue v = (JSValue)(theEnv.theGlobals.get(value));
|
||||
if (v == null) {
|
||||
System.out.println("Accessed undefined : " + value);
|
||||
theEnv.theStack.push(JSUndefined);
|
||||
}
|
||||
else
|
||||
theEnv.theStack.push(v);
|
||||
}
|
||||
|
||||
String type;
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
String value;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user