23 #include "reference.h"
36 propertyNameIsNumber(false),
41 Reference::Reference(
const Object& b,
unsigned p)
43 propertyNameAsNumber(p),
45 propertyNameIsNumber(true)
49 Reference::Reference(ObjectImp *b,
const Identifier& p)
52 propertyNameIsNumber(false),
57 Reference::Reference(ObjectImp *b,
unsigned p)
59 propertyNameAsNumber(p),
61 propertyNameIsNumber(true)
68 propertyNameIsNumber(false),
73 Reference::Reference(
const Null& b,
unsigned p)
75 propertyNameAsNumber(p),
77 propertyNameIsNumber(true)
85 valueRef.baseIsValue =
true;
89 Reference::Reference()
97 exec->setException(err);
113 if (propertyNameIsNumber && prop.
isNull())
114 prop = Identifier::from(propertyNameAsNumber);
129 exec->setException(err);
133 if (o.
type() != ObjectType) {
134 UString m = I18N_NOOP(
"Base is not an object");
136 exec->setException(err);
140 ObjectImp *oimp =
static_cast<ObjectImp*
>(o.imp());
141 if (propertyNameIsNumber)
142 return oimp->getPropertyByIndex(exec, propertyNameAsNumber);
143 return oimp->
get(exec, prop);
150 exec->setException(err);
158 if (o.
type() == NullType)
159 o =
Value(exec->
context().imp()->scopeChain().bottom());
161 ObjectImp *oimp =
static_cast<ObjectImp*
>(o.imp());
162 if (propertyNameIsNumber)
163 oimp->putPropertyByIndex(exec, propertyNameAsNumber, w);
165 oimp->put(exec, prop, w);
168 bool Reference::deleteValue(
ExecState *exec)
172 exec->setException(err);
179 if (b.
type() != ObjectType) {
180 assert(b.
type() == NullType);
184 ObjectImp *bimp =
static_cast<ObjectImp*
>(b.imp());
185 if (propertyNameIsNumber)
186 return bimp->deletePropertyByIndex(exec, propertyNameAsNumber);
187 return bimp->deleteProperty(exec, prop);
190 bool Reference::isMutable()
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...
Type type() const
Returns the type of value.
bool isNull() const
Returns the identfiers state of being unset.
Value get(ExecState *exec, const Identifier &propertyName) const
Retrieves the specified property from the object.
Represents an primitive Null value.
static Object create(ExecState *exec, ErrorType errtype=GeneralError, const char *message=0, int lineno=-1, int sourceId=-1)
Factory method for error objects.
Identifier getPropertyName(ExecState *exec) const
Performs the GetPropertyName type conversion operation on this value (ECMA 8.7)
Value getValue(ExecState *exec) const
Performs the GetValue type conversion operation on this value (ECMA 8.7.1)
Defines a Javascript reference.
const UString & ustring() const
returns a UString of the identifier
Context context() const
Returns the execution context associated with this execution state.
Value getBase(ExecState *exec) const
Performs the GetBase type conversion operation on this value (ECMA 8.7)
void putValue(ExecState *exec, const Value &w)
Performs the PutValue type conversion operation on this value (ECMA 8.7.1)
bool isValid() const
Returns whether or not this is a valid value.
char * ascii() const
Convert the Unicode string to plain ASCII chars chopping of any higher bytes.
Represents the current state of script execution.
Represents an Identifier for a Javascript object.