Continuing JSValue fun.

git-svn-id: svn://10.0.0.236/trunk@32436 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
1999-05-21 00:54:26 +00:00
parent 426e6d0544
commit f70f2834fd
7 changed files with 212 additions and 10 deletions

View File

@@ -15,9 +15,76 @@ class JSString extends JSValue {
JSString vR = theEnv.theStack.pop().toJSString();
theEnv.theStack.push(new JSString(s + vR.s));
}
void gt(Environment theEnv) {
JSValue vR = theEnv.theStack.peek();
if (vR instanceof JSString) {
theEnv.theStack.pop();
theEnv.theStack.push((s.compareTo(vR.toJSString().s) == 1) ? JSBoolean.JSTrue : JSBoolean.JSFalse);
}
else
toJSDouble().gt(theEnv);
}
void ge(Environment theEnv) {
JSValue vR = theEnv.theStack.peek();
if (vR instanceof JSString) {
theEnv.theStack.pop();
theEnv.theStack.push((s.compareTo(vR.toJSString().s) != -1) ? JSBoolean.JSTrue : JSBoolean.JSFalse);
}
else
toJSDouble().ge(theEnv);
}
JSString toJSString()
{
void lt(Environment theEnv) {
JSValue vR = theEnv.theStack.peek();
if (vR instanceof JSString) {
theEnv.theStack.pop();
theEnv.theStack.push((s.compareTo(vR.toJSString().s) == -1) ? JSBoolean.JSTrue : JSBoolean.JSFalse);
}
else
toJSDouble().lt(theEnv);
}
void le(Environment theEnv) {
JSValue vR = theEnv.theStack.peek();
if (vR instanceof JSString) {
theEnv.theStack.pop();
theEnv.theStack.push((s.compareTo(vR.toJSString().s) != 1) ? JSBoolean.JSTrue : JSBoolean.JSFalse);
}
else
toJSDouble().le(theEnv);
}
void eq(Environment theEnv) {
JSValue vR = theEnv.theStack.peek();
if (vR instanceof JSString) {
theEnv.theStack.pop();
theEnv.theStack.push((s.compareTo(vR.toJSString().s) == 0) ? JSBoolean.JSTrue : JSBoolean.JSFalse);
}
else
toJSDouble().eq(theEnv);
}
void ne(Environment theEnv) {
JSValue vR = theEnv.theStack.peek();
if (vR instanceof JSString) {
theEnv.theStack.pop();
theEnv.theStack.push((s.compareTo(vR.toJSString().s) != 0) ? JSBoolean.JSTrue : JSBoolean.JSFalse);
}
else
toJSDouble().ne(theEnv);
}
JSDouble toJSDouble() {
return new JSDouble(s); // XXX Way More To Do, see Rhino ScriptRuntime.java
}
JSString toJSString() {
return this;
}
JSValue toPrimitive() {
return this;
}