Changeset 60708 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Jun 4, 2010, 2:38:38 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/ArrayConstructor.cpp
r60631 r60708 65 65 } 66 66 67 static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)67 static EncodedJSValue JSC_HOST_CALL constructWithArrayConstructor(ExecState* exec) 68 68 { 69 return constructArrayWithSizeQuirk(exec, args); 69 ArgList args(exec); 70 return JSValue::encode(constructArrayWithSizeQuirk(exec, args)); 70 71 } 71 72 -
trunk/JavaScriptCore/runtime/BooleanConstructor.cpp
r60631 r60708 46 46 } 47 47 48 static JSObject* constructWithBooleanConstructor(ExecState* exec, JSObject*, const ArgList& args)48 static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* exec) 49 49 { 50 return constructBoolean(exec, args); 50 ArgList args(exec); 51 return JSValue::encode(constructBoolean(exec, args)); 51 52 } 52 53 -
trunk/JavaScriptCore/runtime/ConstructData.cpp
r60392 r60708 34 34 namespace JSC { 35 35 36 JSObject* construct(ExecState* exec, JSValue object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)36 JSObject* construct(ExecState* exec, JSValue constructorObject, ConstructType constructType, const ConstructData& constructData, const ArgList& args) 37 37 { 38 if (constructType == ConstructTypeHost) 39 return constructData.native.function(exec, asObject(object), args); 40 41 ASSERT(constructType == ConstructTypeJS); 42 JSFunction* jsFunction = asFunction(object); 43 44 ASSERT(!jsFunction->isHostFunction()); 45 Structure* structure; 46 JSValue prototype = jsFunction->get(exec, exec->propertyNames().prototype); 47 if (prototype.isObject()) 48 structure = asObject(prototype)->inheritorID(); 49 else 50 structure = exec->lexicalGlobalObject()->emptyObjectStructure(); 51 JSObject* thisObj = new (exec) JSObject(structure); 52 53 JSValue result = exec->interpreter()->executeConstruct(jsFunction->jsExecutable(), exec, jsFunction, thisObj, args, jsFunction->scope().node(), exec->exceptionSlot()); 54 if (exec->hadException() || !result.isObject()) 55 return thisObj; 56 return asObject(result); 38 ASSERT(constructType == ConstructTypeJS || constructType == ConstructTypeHost); 39 return exec->interpreter()->executeConstruct(exec, asObject(constructorObject), constructType, constructData, args, exec->exceptionSlot()); 57 40 } 58 41 -
trunk/JavaScriptCore/runtime/ConstructData.h
r47412 r60708 30 30 #define ConstructData_h 31 31 32 #include "JSValue.h" 33 32 34 namespace JSC { 33 35 … … 36 38 class FunctionExecutable; 37 39 class JSObject; 38 class JSValue;39 40 class ScopeChainNode; 40 41 … … 45 46 }; 46 47 47 typedef JSObject* (*NativeConstructor)(ExecState*, JSObject*, const ArgList&);48 typedef EncodedJSValue (JSC_HOST_CALL *NativeConstructor)(ExecState*); 48 49 49 50 union ConstructData { -
trunk/JavaScriptCore/runtime/DateConstructor.cpp
r60631 r60708 117 117 } 118 118 119 static JSObject* constructWithDateConstructor(ExecState* exec, JSObject*, const ArgList& args)119 static EncodedJSValue JSC_HOST_CALL constructWithDateConstructor(ExecState* exec) 120 120 { 121 return constructDate(exec, args); 121 ArgList args(exec); 122 return JSValue::encode(constructDate(exec, args)); 122 123 } 123 124 -
trunk/JavaScriptCore/runtime/Error.cpp
r54464 r60708 39 39 const char* expressionEndOffsetPropertyName = "expressionEndOffset"; 40 40 41 static JSObject* constructNativeError(ExecState* exec, const UString& message, NativeErrorConstructor* constructor, const char* name) 42 { 43 ErrorInstance* object = new (exec) ErrorInstance(constructor->errorStructure()); 44 JSString* messageString = message.isEmpty() ? jsString(exec, name) : jsString(exec, message); 45 object->putDirect(exec->propertyNames().message, messageString); 46 return object; 47 } 48 41 49 JSObject* Error::create(ExecState* exec, ErrorType type, const UString& message, int lineNumber, intptr_t sourceID, const UString& sourceURL) 42 50 { 43 JSObject* constructor;44 const char* name; 51 JSObject* error; 52 45 53 switch (type) { 46 54 case EvalError: 47 constructor = exec->lexicalGlobalObject()->evalErrorConstructor(); 48 name = "Evaluation error"; 55 error = constructNativeError(exec, message, exec->lexicalGlobalObject()->evalErrorConstructor(), "Evaluation error"); 49 56 break; 50 57 case RangeError: 51 constructor = exec->lexicalGlobalObject()->rangeErrorConstructor(); 52 name = "Range error"; 58 error = constructNativeError(exec, message, exec->lexicalGlobalObject()->rangeErrorConstructor(), "Range error"); 53 59 break; 54 60 case ReferenceError: 55 constructor = exec->lexicalGlobalObject()->referenceErrorConstructor(); 56 name = "Reference error"; 61 error = constructNativeError(exec, message, exec->lexicalGlobalObject()->referenceErrorConstructor(), "Reference error"); 57 62 break; 58 63 case SyntaxError: 59 constructor = exec->lexicalGlobalObject()->syntaxErrorConstructor(); 60 name = "Syntax error"; 64 error = constructNativeError(exec, message, exec->lexicalGlobalObject()->syntaxErrorConstructor(), "Syntax error"); 61 65 break; 62 66 case TypeError: 63 constructor = exec->lexicalGlobalObject()->typeErrorConstructor(); 64 name = "Type error"; 67 error = constructNativeError(exec, message, exec->lexicalGlobalObject()->typeErrorConstructor(), "Type error"); 65 68 break; 66 69 case URIError: 67 constructor = exec->lexicalGlobalObject()->URIErrorConstructor(); 68 name = "URI error"; 70 error = constructNativeError(exec, message, exec->lexicalGlobalObject()->URIErrorConstructor(), "URI error"); 69 71 break; 70 72 default: 71 constructor = exec->lexicalGlobalObject()->errorConstructor(); 72 name = "Error"; 73 break; 73 JSObject* constructor = exec->lexicalGlobalObject()->errorConstructor(); 74 const char* name = "Error"; 75 MarkedArgumentBuffer args; 76 if (message.isEmpty()) 77 args.append(jsString(exec, name)); 78 else 79 args.append(jsString(exec, message)); 80 ConstructData constructData; 81 ConstructType constructType = constructor->getConstructData(constructData); 82 error = construct(exec, constructor, constructType, constructData, args); 74 83 } 75 76 MarkedArgumentBuffer args;77 if (message.isEmpty())78 args.append(jsString(exec, name));79 else80 args.append(jsString(exec, message));81 ConstructData constructData;82 ConstructType constructType = constructor->getConstructData(constructData);83 JSObject* error = construct(exec, constructor, constructType, constructData, args);84 84 85 85 if (lineNumber != -1) -
trunk/JavaScriptCore/runtime/ErrorConstructor.cpp
r60631 r60708 47 47 } 48 48 49 static JSObject* constructWithErrorConstructor(ExecState* exec, JSObject*, const ArgList& args)49 static EncodedJSValue JSC_HOST_CALL constructWithErrorConstructor(ExecState* exec) 50 50 { 51 return constructError(exec, args); 51 ArgList args(exec); 52 return JSValue::encode(constructError(exec, args)); 52 53 } 53 54 -
trunk/JavaScriptCore/runtime/FunctionConstructor.cpp
r60631 r60708 45 45 } 46 46 47 static JSObject* constructWithFunctionConstructor(ExecState* exec, JSObject*, const ArgList& args)47 static EncodedJSValue JSC_HOST_CALL constructWithFunctionConstructor(ExecState* exec) 48 48 { 49 return constructFunction(exec, args); 49 ArgList args(exec); 50 return JSValue::encode(constructFunction(exec, args)); 50 51 } 51 52 -
trunk/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r60631 r60708 52 52 } 53 53 54 static JSObject* constructWithNativeErrorConstructor(ExecState* exec, JSObject* constructor, const ArgList& args)54 static EncodedJSValue JSC_HOST_CALL constructWithNativeErrorConstructor(ExecState* exec) 55 55 { 56 return static_cast<NativeErrorConstructor*>(constructor)->construct(exec, args); 56 ArgList args(exec); 57 return JSValue::encode(static_cast<NativeErrorConstructor*>(exec->callee())->construct(exec, args)); 57 58 } 58 59 -
trunk/JavaScriptCore/runtime/NativeErrorConstructor.h
r59974 r60708 38 38 ErrorInstance* construct(ExecState*, const ArgList&); 39 39 40 Structure* errorStructure() { return m_errorStructure.get(); } 41 40 42 private: 41 43 virtual ConstructType getConstructData(ConstructData&); -
trunk/JavaScriptCore/runtime/NumberConstructor.cpp
r60631 r60708 101 101 102 102 // ECMA 15.7.1 103 static JSObject* constructWithNumberConstructor(ExecState* exec, JSObject*, const ArgList& args)103 static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec) 104 104 { 105 105 NumberObject* object = new (exec) NumberObject(exec->lexicalGlobalObject()->numberObjectStructure()); 106 double n = args.isEmpty() ? 0 : args.at(0).toNumber(exec);106 double n = exec->argumentCount() ? exec->argument(0).toNumber(exec) : 0; 107 107 object->setInternalValue(jsNumber(exec, n)); 108 return object;108 return JSValue::encode(object); 109 109 } 110 110 -
trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
r60631 r60708 70 70 } 71 71 72 static JSObject* constructWithObjectConstructor(ExecState* exec, JSObject*, const ArgList& args) 73 { 74 return constructObject(exec, args); 72 static EncodedJSValue JSC_HOST_CALL constructWithObjectConstructor(ExecState* exec) 73 { 74 ArgList args(exec); 75 return JSValue::encode(constructObject(exec, args)); 75 76 } 76 77 -
trunk/JavaScriptCore/runtime/RegExpConstructor.cpp
r60631 r60708 308 308 } 309 309 310 static JSObject* constructWithRegExpConstructor(ExecState* exec, JSObject*, const ArgList& args) 311 { 312 return constructRegExp(exec, args); 310 static EncodedJSValue JSC_HOST_CALL constructWithRegExpConstructor(ExecState* exec) 311 { 312 ArgList args(exec); 313 return JSValue::encode(constructRegExp(exec, args)); 313 314 } 314 315 -
trunk/JavaScriptCore/runtime/StringConstructor.cpp
r60631 r60708 67 67 68 68 // ECMA 15.5.2 69 static JSObject* constructWithStringConstructor(ExecState* exec, JSObject*, const ArgList& args)69 static EncodedJSValue JSC_HOST_CALL constructWithStringConstructor(ExecState* exec) 70 70 { 71 if ( args.isEmpty())72 return new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure());73 return new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure(), args.at(0).toString(exec));71 if (!exec->argumentCount()) 72 return JSValue::encode(new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure())); 73 return JSValue::encode(new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure(), exec->argument(0).toString(exec))); 74 74 } 75 75
Note:
See TracChangeset
for help on using the changeset viewer.