22 #include "reference.h" 35 propertyNameIsNumber(false),
40 Reference::Reference(
const Object& b,
unsigned p)
42 propertyNameAsNumber(p),
44 propertyNameIsNumber(true)
48 Reference::Reference(ObjectImp *b,
const Identifier& p)
51 propertyNameIsNumber(false),
56 Reference::Reference(ObjectImp *b,
unsigned p)
58 propertyNameAsNumber(p),
60 propertyNameIsNumber(true)
67 propertyNameIsNumber(false),
72 Reference::Reference(
const Null& b,
unsigned p)
74 propertyNameAsNumber(p),
76 propertyNameIsNumber(true)
84 valueRef.baseIsValue =
true;
88 Reference::Reference()
96 exec->setException(err);
112 if (propertyNameIsNumber && prop.isNull())
113 prop = Identifier::from(propertyNameAsNumber);
123 Value o = getBase(exec);
126 UString m = I18N_NOOP(
"Can't find variable: ") + getPropertyName(exec).ustring();
128 exec->setException(err);
132 if (o.
type() != ObjectType) {
133 UString m = I18N_NOOP(
"Base is not an object");
135 exec->setException(err);
139 ObjectImp *oimp =
static_cast<ObjectImp*
>(o.imp());
140 if (propertyNameIsNumber)
141 return oimp->getPropertyByIndex(exec, propertyNameAsNumber);
142 return oimp->
get(exec, prop);
149 exec->setException(err);
154 printInfo(exec,(
UString(
"setting property ")+getPropertyName(exec).ustring()).cstring().c_str(),w);
156 Value o = getBase(exec);
157 if (o.
type() == NullType)
158 o =
Value(exec->
context().imp()->scopeChain().bottom());
160 ObjectImp *oimp =
static_cast<ObjectImp*
>(o.imp());
161 if (propertyNameIsNumber)
162 oimp->putPropertyByIndex(exec, propertyNameAsNumber, w);
164 oimp->put(exec, prop, w);
167 bool Reference::deleteValue(
ExecState *exec)
171 exec->setException(err);
175 Value b = getBase(exec);
178 if (b.
type() != ObjectType) {
179 assert(b.
type() == NullType);
183 ObjectImp *bimp =
static_cast<ObjectImp*
>(b.imp());
184 if (propertyNameIsNumber)
185 return bimp->deletePropertyByIndex(exec, propertyNameAsNumber);
186 return bimp->deleteProperty(exec, prop);
189 bool Reference::isMutable()
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...
Value getValue(ExecState *exec) const
Performs the GetValue type conversion operation on this value (ECMA 8.7.1)
Value get(ExecState *exec, const Identifier &propertyName) const
Retrieves the specified property from the object.
Type type() const
Returns the type of value.
Represents an primitive Null value.
Value getBase(ExecState *exec) const
Performs the GetBase type conversion operation on this value (ECMA 8.7)
char * ascii() const
Convert the Unicode string to plain ASCII chars chopping of any higher bytes.
static Object create(ExecState *exec, ErrorType errtype=GeneralError, const char *message=0, int lineno=-1, int sourceId=-1)
Factory method for error objects.
Defines a Javascript reference.
bool isValid() const
Returns whether or not this is a valid value.
void putValue(ExecState *exec, const Value &w)
Performs the PutValue type conversion operation on this value (ECMA 8.7.1)
Identifier getPropertyName(ExecState *exec) const
Performs the GetPropertyName type conversion operation on this value (ECMA 8.7)
Context context() const
Returns the execution context associated with this execution state.
Represents the current state of script execution.
Represents an Identifier for a Javascript object.