25 #include "interpreter.h"
26 #include "operations.h"
27 #include "error_object.h"
34 const ClassInfo ErrorInstanceImp::info = {
"Error", 0, 0, 0};
36 ErrorInstanceImp::ErrorInstanceImp(ObjectImp *proto)
44 ErrorPrototypeImp::ErrorPrototypeImp(
ExecState *exec,
45 ObjectPrototypeImp *objectProto,
47 : ObjectImp(objectProto)
53 put(exec, namePropertyName,
String(
"Error"), DontEnum);
54 put(exec, messagePropertyName,
String(
"Unknown error"), DontEnum);
55 putDirect(toStringPropertyName,
new ErrorProtoFuncImp(exec,funcProto), DontEnum);
64 putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
68 bool ErrorProtoFuncImp::implementsCall()
const
78 Value v = thisObj.
get(exec, namePropertyName);
79 if (v.
type() != UndefinedType) {
83 v = thisObj.
get(exec, messagePropertyName);
84 if (v.
type() != UndefinedType) {
94 ErrorPrototypeImp *errorProto)
99 putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
100 putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
104 bool ErrorObjectImp::implementsConstruct()
const
113 ObjectImp *imp =
new ErrorInstanceImp(proto.imp());
116 if (!args.
isEmpty() && args[0].type() != UndefinedType) {
117 imp->putDirect(messagePropertyName,
new StringImp(args[0].toString(exec)));
123 bool ErrorObjectImp::implementsCall()
const
132 return construct(exec,args);
137 NativeErrorPrototypeImp::NativeErrorPrototypeImp(
ExecState * , ErrorPrototypeImp *errorProto,
139 : ObjectImp(errorProto)
143 putDirect(namePropertyName,
new StringImp(name), 0);
144 putDirect(messagePropertyName,
new StringImp(message), 0);
149 const ClassInfo NativeErrorImp::info = {
"Function", &InternalFunctionImp::info, 0, 0};
156 proto =
static_cast<ObjectImp*
>(prot.imp());
158 putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
159 putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
162 bool NativeErrorImp::implementsConstruct()
const
169 ObjectImp *imp =
new ErrorInstanceImp(proto);
171 if (args[0].type() != UndefinedType)
172 imp->putDirect(messagePropertyName,
new StringImp(args[0].toString(exec)));
176 bool NativeErrorImp::implementsCall()
const
183 return construct(exec,args);
186 void NativeErrorImp::mark()
189 if (proto && !proto->marked())
Represents the current state of script execution.
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)
Base class for all function objects.
Object builtinErrorPrototype() const
Returns the builtin "Error.prototype" object.
Value get(ExecState *exec, const Identifier &propertyName) const
Retrieves the specified property from the object.
Represents an primitive String value.
Represents an primitive Undefined value.
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)
Type type() const
Returns the type of value.