src/3rdparty/webkit/JavaScriptCore/runtime/ErrorPrototype.cpp
changeset 30 5dc02b23752f
parent 0 1918ee327afb
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    21 #include "config.h"
    21 #include "config.h"
    22 #include "ErrorPrototype.h"
    22 #include "ErrorPrototype.h"
    23 
    23 
    24 #include "JSFunction.h"
    24 #include "JSFunction.h"
    25 #include "JSString.h"
    25 #include "JSString.h"
       
    26 #include "JSStringBuilder.h"
    26 #include "ObjectPrototype.h"
    27 #include "ObjectPrototype.h"
    27 #include "PrototypeFunction.h"
    28 #include "PrototypeFunction.h"
    28 #include "UString.h"
    29 #include "UString.h"
    29 
    30 
    30 namespace JSC {
    31 namespace JSC {
    46 }
    47 }
    47 
    48 
    48 JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
    49 JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
    49 {
    50 {
    50     JSObject* thisObj = thisValue.toThisObject(exec);
    51     JSObject* thisObj = thisValue.toThisObject(exec);
       
    52     JSValue name = thisObj->get(exec, exec->propertyNames().name);
       
    53     JSValue message = thisObj->get(exec, exec->propertyNames().message);
    51 
    54 
    52     UString s = "Error";
    55     // Mozilla-compatible format.
    53 
    56 
    54     JSValue v = thisObj->get(exec, exec->propertyNames().name);
    57     if (!name.isUndefined()) {
    55     if (!v.isUndefined())
    58         if (!message.isUndefined())
    56         s = v.toString(exec);
    59             return jsMakeNontrivialString(exec, name.toString(exec), ": ", message.toString(exec));
    57 
    60         return jsNontrivialString(exec, name.toString(exec));
    58     v = thisObj->get(exec, exec->propertyNames().message);
       
    59     if (!v.isUndefined()) {
       
    60         // Mozilla-compatible format.
       
    61         s += ": ";
       
    62         s += v.toString(exec);
       
    63     }
    61     }
    64 
    62     if (!message.isUndefined())
    65     return jsNontrivialString(exec, s);
    63         return jsMakeNontrivialString(exec, "Error: ", message.toString(exec));
       
    64     return jsNontrivialString(exec, "Error");
    66 }
    65 }
    67 
    66 
    68 } // namespace JSC
    67 } // namespace JSC