Ignore:
Timestamp:
Dec 13, 2005, 1:24:53 PM (19 years ago)
Author:
andersca
Message:

2005-12-12 Anders Carlsson <[email protected]>

Reviewed by Darin.

  • bindings/runtime_array.cpp: (RuntimeArray::lengthGetter): (RuntimeArray::indexGetter):
  • bindings/runtime_array.h:
  • bindings/runtime_method.cpp: (RuntimeMethod::lengthGetter):
  • bindings/runtime_method.h:
  • bindings/runtime_object.cpp: (RuntimeObjectImp::fallbackObjectGetter): (RuntimeObjectImp::fieldGetter): (RuntimeObjectImp::methodGetter):
  • bindings/runtime_object.h:
  • kjs/array_instance.h:
  • kjs/array_object.cpp: (ArrayInstance::lengthGetter): (getProperty): Update for changes to PropertySlot::getValue and PropertySlot::GetValueFunc.
  • kjs/collector.cpp: (KJS::className): Handle GetterSetterType.
  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): (KJS::FunctionImp::lengthGetter): (KJS::Arguments::mappedIndexGetter): (KJS::ActivationImp::argumentsGetter):
  • kjs/function.h: Update for changes to PropertySlot::getValue and PropertySlot::GetValueFunc.
  • kjs/grammar.y: Rework grammar parts for get set declarations directly in the object literal.
  • kjs/internal.cpp: (KJS::GetterSetterImp::mark): (KJS::GetterSetterImp::toPrimitive): (KJS::GetterSetterImp::toBoolean): (KJS::GetterSetterImp::toNumber): (KJS::GetterSetterImp::toString): (KJS::GetterSetterImp::toObject): Add type conversion functions. These aren't meant to be called.

(KJS::printInfo):
Handle GetterSetterType.

  • kjs/lookup.h: (KJS::staticFunctionGetter): (KJS::staticValueGetter): Update for changes to PropertySlot::GetValueFunc.
  • kjs/nodes.cpp: Refactor they way properties nodes are implemented. We now have a PropertyListNode which is a list of PropertyNodes. Each PropertyNode has a name (which is a PropertyNameNode) and an associated value node. PropertyNodes can be of different types. The Constant type is the old constant declaration and the Getter and Setter types are for property getters and setters. (ResolveNode::evaluate): Update for changes to PropertySlot::getValue.

(PropertyListNode::evaluate):
Go through all property nodes and set them on the newly created object. If the
property nodes are of type Getter or Setter, define getters and setters. Otherwise,
just add the properties like before.

(PropertyNode::evaluate):
This should never be called directly.

(PropertyNameNode::evaluate):
Rename from PropertyNode::evaluate.

(FunctionCallResolveNode::evaluate):
(FunctionCallBracketNode::evaluate):
(FunctionCallDotNode::evaluate):
(PostfixResolveNode::evaluate):
(PostfixBracketNode::evaluate):
(PostfixDotNode::evaluate):
(TypeOfResolveNode::evaluate):
(PrefixResolveNode::evaluate):
(PrefixBracketNode::evaluate):
(PrefixDotNode::evaluate):
(AssignResolveNode::evaluate):
(AssignDotNode::evaluate):
(AssignBracketNode::evaluate):
Update for changes to PropertySlot::getValue.

  • kjs/nodes.h: (KJS::PropertyNameNode::PropertyNameNode): Rename from PropertyNode.

(KJS::PropertyNode::):
(KJS::PropertyNode::PropertyNode):
New class, representing a single property.

(KJS::PropertyListNode::PropertyListNode):
Rename from PropertyValueNode.

(KJS::FuncExprNode::FuncExprNode):
Put ParameterNode parameter last, and make it optional.

(KJS::ObjectLiteralNode::ObjectLiteralNode):
Use a PropertyListNode here now.

  • kjs/nodes2string.cpp: (PropertyListNode::streamTo): Iterate through all property nodes.

(PropertyNode::streamTo):
Print out the name and value. Doesn't handle getters and setters currently.

(PropertyNameNode::streamTo):
Rename from PropertyNode::streamTo.

  • kjs/object.cpp: (KJS::JSObject::get): Update for changes to PropertySlot::getValue.

(KJS::JSObject::put):
If the property already exists and has a Setter, invoke
the setter function instead of setting the property directly.

(KJS::JSObject::defineGetter):
(KJS::JSObject::defineSetter):
New functions for defining property getters and setters on the object.

  • kjs/object.h: (KJS::GetterSetterImp::type): (KJS::GetterSetterImp::GetterSetterImp): (KJS::GetterSetterImp::getGetter): (KJS::GetterSetterImp::setGetter): (KJS::GetterSetterImp::getSetter): (KJS::GetterSetterImp::setSetter): New class for properties which have getters and setters defined. This class is only used internally and should never be seen from the outside.

(KJS::JSObject::getOwnPropertySlot):

If the property is a getter, call setGetterSlot on the property slot.

  • kjs/object_object.cpp: (ObjectPrototype::ObjectPrototype): Add defineGetter, defineSetter, lookupGetter, lookupSetter to prototype.

(ObjectProtoFunc::callAsFunction):
Implement handlers for new functions.

  • kjs/object_object.h: (KJS::ObjectProtoFunc::): Add ids for new functions.
  • kjs/property_slot.cpp: (KJS::PropertySlot::undefinedGetter): Update for changes to PropertySlot::GetValueFunc.

(KJS::PropertySlot::functionGetter):
Call the function getter object and return its value.

  • kjs/property_slot.h: (KJS::PropertySlot::getValue): Add a new argument which is the original object that getPropertySlot was called on.

(KJS::PropertySlot::setGetterSlot):
(KJS::PropertySlot::):
New function which sets a getter slot. When getValue is called on a
getter slot, the getter function object is invoked.

  • kjs/string_object.cpp: (StringInstance::lengthGetter): (StringInstance::indexGetter):
  • kjs/string_object.h: Update for changes to PropertySlot::GetValueFunc.
  • kjs/value.h: (KJS::): Add GetterSetterType and make GetterSetterImp a friend class of JSCell.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r11377 r11566  
    156156}
    157157
    158 void PropertyValueNode::streamTo(SourceStream &s) const
    159 {
    160   for (const PropertyValueNode *n = this; n; n = n->list.get())
    161     s << n->name << ": " << n->assign;
     158void PropertyListNode::streamTo(SourceStream &s) const
     159{
     160  s << node;
     161 
     162  for (const PropertyListNode *n = list.get(); n; n = n->list.get())
     163    s << ", " << n->node;
    162164}
    163165
    164166void PropertyNode::streamTo(SourceStream &s) const
     167{
     168  switch (type) {
     169    case Constant:
     170      s << name << ": " << assign;
     171      break;
     172    case Getter:
     173    case Setter: {
     174      const FuncExprNode *func = static_cast<const FuncExprNode *>(assign.get());
     175      if (type == Getter)
     176        s << "get ";
     177      else
     178        s << "set ";
     179     
     180      s << name << "(" << func->param << ")" << func->body;
     181      break;
     182    }
     183  }
     184}
     185
     186void PropertyNameNode::streamTo(SourceStream &s) const
    165187{
    166188  if (str.isNull())
Note: See TracChangeset for help on using the changeset viewer.