Mozilla/mozilla/js/js2/java/JSBoolean.java
rogerl%netscape.com 1c31755a34 JSValue changes, closing in on JSObject API. Began 'correct' semantic
implementation for various operators.


git-svn-id: svn://10.0.0.236/trunk@32626 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-25 21:49:40 +00:00

52 lines
979 B
Java

class JSBoolean extends JSValue {
static JSBoolean JSTrue = new JSBoolean(true);
static JSBoolean JSFalse = new JSBoolean(false);
private JSBoolean(boolean p)
{
b = p;
}
void eval(Environment theEnv)
{
theEnv.theStack.push(this);
}
boolean isTrue()
{
return b;
}
boolean isFalse()
{
return !b;
}
void bang(Environment theEnv) {
theEnv.theStack.push((b) ? JSFalse : JSTrue);
}
void typeof(Environment theEnv) {
theEnv.theStack.push(new JSString("boolean"));
}
JSBoolean toJSBoolean() {
return this;
}
JSValue toPrimitive(String hint) {
return this;
}
JSString toJSString() {
return (b) ? new JSString("true") : new JSString("false");
}
JSDouble toJSDouble() {
return (b) ? new JSDouble(1) : new JSDouble(0);
}
boolean b;
}