26 #include "interpreter.h" 27 #include "operations.h" 28 #include "error_object.h" 35 const ClassInfo ErrorInstanceImp::info = {
"Error", 0, 0, 0};
37 ErrorInstanceImp::ErrorInstanceImp(ObjectImp *proto)
45 ErrorPrototypeImp::ErrorPrototypeImp(
ExecState *exec,
46 ObjectPrototypeImp *objectProto,
48 : ObjectImp(objectProto)
54 put(exec, namePropertyName,
String(
"Error"), DontEnum);
55 put(exec, messagePropertyName,
String(
"Unknown error"), DontEnum);
56 putDirect(toStringPropertyName,
new ErrorProtoFuncImp(exec,funcProto), DontEnum);
65 putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
69 bool ErrorProtoFuncImp::implementsCall()
const 79 Value v = thisObj.
get(exec, namePropertyName);
80 if (v.
type() != UndefinedType) {
84 v = thisObj.
get(exec, messagePropertyName);
85 if (v.
type() != UndefinedType) {
95 ErrorPrototypeImp *errorProto)
100 putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
101 putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
105 bool ErrorObjectImp::implementsConstruct()
const 114 ObjectImp *imp =
new ErrorInstanceImp(proto.imp());
117 if (!args.
isEmpty() && args[0].type() != UndefinedType) {
118 imp->putDirect(messagePropertyName,
new StringImp(args[0].toString(exec)));
124 bool ErrorObjectImp::implementsCall()
const 133 return construct(exec,args);
138 NativeErrorPrototypeImp::NativeErrorPrototypeImp(
ExecState * , ErrorPrototypeImp *errorProto,
140 : ObjectImp(errorProto)
144 putDirect(namePropertyName,
new StringImp(name), 0);
145 putDirect(messagePropertyName,
new StringImp(message), 0);
150 const ClassInfo NativeErrorImp::info = {
"Function", &InternalFunctionImp::info, 0, 0};
157 proto =
static_cast<ObjectImp*
>(prot.imp());
159 putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
160 putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
163 bool NativeErrorImp::implementsConstruct()
const 170 ObjectImp *imp =
new ErrorInstanceImp(proto);
172 if (args[0].type() != UndefinedType)
173 imp->putDirect(messagePropertyName,
new StringImp(args[0].toString(exec)));
177 bool NativeErrorImp::implementsCall()
const 184 return construct(exec,args);
187 void NativeErrorImp::mark()
190 if (proto && !proto->marked())
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...
UString toString(ExecState *exec) const
Performs the ToString type conversion operation on this value (ECMA 9.8)
Base class for all function objects.
Value get(ExecState *exec, const Identifier &propertyName) const
Retrieves the specified property from the object.
Type type() const
Returns the type of value.
Interpreter * lexicalInterpreter() const
Returns the interpreter associated with the current scope's global object.
The initial value of Function.prototype (and thus all objects created with the Function constructor) ...
Object builtinErrorPrototype() const
Returns the builtin "Error.prototype" object.
Represents an primitive Undefined value.
Represents an primitive String value.
static Object dynamicCast(const Value &v)
Converts a Value into an Object.
Represents the current state of script execution.