source: webkit/trunk/JavaScriptCore/kjs/reference.cpp@ 13015

Last change on this file since 13015 was 13015, checked in by mjs, 19 years ago

Reviewed by Darin.


  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/NP_jsobject.cpp: (jsAllocate): (_NPN_InvokeDefault): (_NPN_Evaluate): (_NPN_GetProperty): (_NPN_SetProperty): (_NPN_RemoveProperty): (_NPN_HasProperty): (_NPN_HasMethod):
  • bindings/c/c_class.h: (KJS::Bindings::CClass::constructorAt):
  • bindings/c/c_utility.cpp: (KJS::Bindings::convertNPVariantToValue):
  • bindings/jni/jni_class.cpp: (JavaClass::methodsNamed): (JavaClass::fieldNamed):
  • bindings/jni/jni_instance.cpp: (JavaInstance::invokeDefaultMethod):
  • bindings/jni/jni_jsobject.cpp:
  • bindings/jni/jni_objc.mm: (-[NSObject KJS::Bindings::]):
  • bindings/objc/WebScriptObject.mm: (+[WebUndefined allocWithZone:]): (-[WebUndefined initWithCoder:]): (-[WebUndefined encodeWithCoder:]): (-[WebUndefined copyWithZone:]):
  • bindings/objc/objc_class.h: (KJS::Bindings::ObjcClass::constructorAt):
  • bindings/objc/objc_class.mm: (KJS::Bindings::ObjcClass::methodsNamed): (KJS::Bindings::ObjcClass::fallbackObject):
  • bindings/objc/objc_instance.mm: (ObjcInstance::getValueOfUndefinedField):
  • bindings/objc/objc_runtime.mm: (ObjcFallbackObjectImp::getOwnPropertySlot): (ObjcFallbackObjectImp::put): (ObjcFallbackObjectImp::canPut): (ObjcFallbackObjectImp::deleteProperty): (ObjcFallbackObjectImp::toBoolean):
  • bindings/runtime.cpp: (KJS::Bindings::Instance::createLanguageInstanceForValue):
  • bindings/runtime.h: (KJS::Bindings::Instance::getValueOfUndefinedField): (KJS::Bindings::Instance::setValueOfUndefinedField):
  • bindings/runtime_array.cpp: (RuntimeArray::lengthGetter): (RuntimeArray::indexGetter): (RuntimeArray::put): (RuntimeArray::deleteProperty):
  • bindings/runtime_method.cpp: (RuntimeMethod::lengthGetter): (RuntimeMethod::execute):
  • bindings/runtime_object.cpp: (RuntimeObjectImp::fallbackObjectGetter): (RuntimeObjectImp::fieldGetter): (RuntimeObjectImp::methodGetter): (RuntimeObjectImp::put): (RuntimeObjectImp::canPut): (RuntimeObjectImp::deleteProperty): (RuntimeObjectImp::defaultValue): (RuntimeObjectImp::callAsFunction):
  • bindings/runtime_root.cpp: (performJavaScriptAccess):
  • kjs/array_object.cpp: (ArrayInstance::lengthGetter): (ArrayInstance::getOwnPropertySlot): (ArrayPrototype::ArrayPrototype): (ArrayPrototype::getOwnPropertySlot):
  • kjs/bool_object.cpp: (BooleanObjectImp::BooleanObjectImp):
  • kjs/date_object.cpp: (KJS::DateObjectFuncImp::DateObjectFuncImp): (KJS::DateObjectFuncImp::callAsFunction):
  • kjs/error_object.cpp: (ErrorObjectImp::ErrorObjectImp): (NativeErrorPrototype::NativeErrorPrototype): (NativeErrorImp::NativeErrorImp):
  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): (KJS::FunctionImp::lengthGetter): (KJS::Arguments::mappedIndexGetter): (KJS::ActivationImp::argumentsGetter): (KJS::ActivationImp::put):
  • kjs/function_object.cpp: (FunctionObjectImp::FunctionObjectImp):
  • kjs/internal.cpp: (KJS::GetterSetterImp::toPrimitive): (KJS::GetterSetterImp::toBoolean):
  • kjs/interpreter.cpp: (KJS::Interpreter::evaluate):
  • kjs/interpreter.h: (KJS::Interpreter::isGlobalObject): (KJS::Interpreter::interpreterForGlobalObject): (KJS::Interpreter::isSafeScript):
  • kjs/lexer.cpp: (Lexer::makeIdentifier): (Lexer::makeUString):
  • kjs/lookup.h: (KJS::staticFunctionGetter): (KJS::staticValueGetter):
  • kjs/nodes.cpp: (StatementNode::processFuncDecl): (PropertyNode::evaluate): (PropertyNameNode::evaluate):
  • kjs/number_object.cpp: (NumberObjectImp::NumberObjectImp): (NumberObjectImp::getOwnPropertySlot):
  • kjs/object.cpp: (KJS::JSObject::defineGetter): (KJS::JSObject::defineSetter): (KJS::JSObject::hasInstance): (KJS::JSObject::propertyIsEnumerable):
  • kjs/object_object.cpp: (ObjectObjectImp::ObjectObjectImp):
  • kjs/property_slot.cpp: (KJS::PropertySlot::undefinedGetter): (KJS::PropertySlot::functionGetter):
  • kjs/reference.cpp: (KJS::Reference::getPropertyName):
  • kjs/reference_list.cpp: (ReferenceListIterator::operator++):
  • kjs/regexp_object.cpp: (RegExpObjectImp::RegExpObjectImp): (RegExpObjectImp::getValueProperty): (RegExpObjectImp::putValueProperty):
  • kjs/string_object.cpp: (StringInstance::lengthGetter): (StringInstance::indexGetter): (StringPrototype::StringPrototype):
  • kxmlcore/Assertions.mm:
  • kxmlcore/FastMalloc.cpp: (KXMLCore::TCMalloc_PageHeap::CheckList):
  • kxmlcore/HashTable.h: (KXMLCore::HashTableConstIterator::checkValidity): (KXMLCore::IdentityHashTranslator::translate):
  • pcre/pcre_get.c: (pcre_get_stringnumber):
  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 2004 Apple Computer, Inc
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include "JSType.h"
24#include "config.h"
25#include "internal.h"
26#include "reference.h"
27
28namespace KJS {
29
30// ------------------------------ Reference ------------------------------------
31
32Reference::Reference(JSObject *b, const Identifier& p)
33 : base(b),
34 propertyNameIsNumber(false),
35 prop(p)
36{
37}
38
39Reference::Reference(JSObject *b, unsigned p)
40 : base(b),
41 propertyNameAsNumber(p),
42 propertyNameIsNumber(true)
43{
44}
45
46Identifier Reference::getPropertyName(ExecState*) const
47{
48 if (propertyNameIsNumber && prop.isNull())
49 prop = Identifier::from(propertyNameAsNumber);
50 return prop;
51}
52
53JSValue *Reference::getValue(ExecState *exec) const
54{
55 JSValue *o = base;
56 if (!o || !o->isObject()) {
57 if (!o || o->isNull())
58 return throwError(exec, ReferenceError, "Can't find variable: " + getPropertyName(exec).ustring());
59 return throwError(exec, ReferenceError, "Base is not an object");
60 }
61
62 if (propertyNameIsNumber)
63 return static_cast<JSObject*>(o)->get(exec, propertyNameAsNumber);
64 return static_cast<JSObject*>(o)->get(exec, prop);
65}
66
67bool Reference::deleteValue(ExecState *exec)
68{
69 JSValue *o = base;
70 JSType t = o ? o->type() : NullType;
71
72 // The spec doesn't mention what to do if the base is null... just return true
73 if (t != ObjectType) {
74 assert(t == NullType);
75 return true;
76 }
77
78 if (propertyNameIsNumber)
79 return static_cast<JSObject*>(o)->deleteProperty(exec,propertyNameAsNumber);
80 return static_cast<JSObject*>(o)->deleteProperty(exec,prop);
81}
82
83}
Note: See TracBrowser for help on using the repository browser.