UString JSImmediate::toString(JSValuePtr v) { ASSERT(isImmediate(v)); if (isIntegerNumber(v)) return UString::from(getTruncatedInt32(v)); #if USE(ALTERNATE_JSIMMEDIATE) if (isNumber(v)) { ASSERT(isDoubleNumber(v)); double value = doubleValue(v); if (value == 0.0) // +0.0 or -0.0 return "0"; return UString::from(value); } #else ASSERT(!isNumber(v)); #endif if (jsBoolean(false) == v) return "false"; if (jsBoolean(true) == v) return "true"; if (v.isNull()) return "null"; ASSERT(v.isUndefined()); return "undefined"; }
JSValuePtr errorProtoFuncToString(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList&) { JSObject* thisObj = thisValue->toThisObject(exec); UString s = "Error"; JSValuePtr v = thisObj->get(exec, exec->propertyNames().name); if (!v->isUndefined()) s = v->toString(exec); v = thisObj->get(exec, exec->propertyNames().message); if (!v->isUndefined()) { // Mozilla-compatible format. s += ": "; s += v->toString(exec); } return jsNontrivialString(exec, s); }
bool JSValueIsUndefined(JSContextRef, JSValueRef value) { JSValuePtr jsValue = toJS(value); return jsValue.isUndefined(); }