Ignore:
Timestamp:
Oct 17, 2007, 2:01:27 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Darin Adler.


Merged DeclaredFunctionImp into FunctionImp (the base class) because
the distinction between the two was unused.


Removed codeType() from FunctionImp because FunctionImp and its
subclasses all returned FunctionCode, so it was unused, practically
speaking.


Removed a different codeType() from GlobalFuncImp because it was unused.
(Perhaps it was vestigial from a time when GlobalFuncImp used to
inherit from FunctionImp.)

  • bindings/runtime_method.cpp:
  • bindings/runtime_method.h:
  • kjs/function.cpp: (KJS::): (KJS::FunctionImp::FunctionImp): (KJS::FunctionImp::callAsFunction): (KJS::FunctionImp::construct): (KJS::FunctionImp::execute): (KJS::FunctionImp::processVarDecls):
  • kjs/function.h: (KJS::FunctionImp::implementsConstruct): (KJS::FunctionImp::scope):
  • kjs/function_object.cpp: (FunctionProtoFunc::callAsFunction): (FunctionObjectImp::construct):
  • kjs/nodes.cpp: (FuncDeclNode::processFuncDecl): (FuncExprNode::evaluate):
File:
1 edited

Legend:

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

    r26690 r26715  
    4949// ----------------------------- FunctionImp ----------------------------------
    5050
    51 const ClassInfo FunctionImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
    52 
    53 FunctionImp::FunctionImp(ExecState* exec, const Identifier& n, FunctionBodyNode* b)
    54   : InternalFunctionImp(static_cast<FunctionPrototype*>
    55                         (exec->lexicalInterpreter()->builtinFunctionPrototype()), n)
     51const ClassInfo FunctionImp::info = { "Function", &InternalFunctionImp::info, 0, 0 };
     52
     53FunctionImp::FunctionImp(ExecState* exec, const Identifier& name, FunctionBodyNode* b, const ScopeChain& sc)
     54  : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
    5655  , body(b)
     56  , _scope(sc)
    5757{
    5858}
     
    6464}
    6565
    66 FunctionImp::~FunctionImp()
    67 {
    68 }
    69 
    7066JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    7167{
     
    7470  // enter a new execution context
    7571  Context ctx(globalObj, exec->dynamicInterpreter(), thisObj, body.get(),
    76                  codeType(), exec->context(), this, &args);
     72                 FunctionCode, exec->context(), this, &args);
    7773  ExecState newExec(exec->dynamicInterpreter(), &ctx);
    7874  if (exec->hadException())
     
    8076  ctx.setExecState(&newExec);
    8177
    82   // assign user supplied arguments to parameters
    8378  passInParameters(&newExec, args);
    84   // add variable declarations (initialized to undefined)
    8579  processVarDecls(&newExec);
    8680
     
    8983  int lineno = -1;
    9084  if (dbg) {
    91     if (inherits(&DeclaredFunctionImp::info)) {
    92       sid = static_cast<DeclaredFunctionImp*>(this)->body->sourceId();
    93       lineno = static_cast<DeclaredFunctionImp*>(this)->body->firstLine();
    94     }
     85    sid = body->sourceId();
     86    lineno = body->firstLine();
    9587
    9688    bool cont = dbg->callEvent(&newExec,sid,lineno,this,args);
     
    113105
    114106  if (dbg) {
    115     if (inherits(&DeclaredFunctionImp::info))
    116       lineno = static_cast<DeclaredFunctionImp*>(this)->body->lastLine();
     107    lineno = body->lastLine();
    117108
    118109    if (comp.complType() == Throw)
     
    147138      variable->put(exec, parameters[i], args[i], DontDelete);
    148139    }
    149 }
    150 
    151 void FunctionImp::processVarDecls(ExecState*)
    152 {
    153140}
    154141
     
    256243}
    257244
    258 // ------------------------------ DeclaredFunctionImp --------------------------
    259 
    260 // ### is "Function" correct here?
    261 const ClassInfo DeclaredFunctionImp::info = {"Function", &FunctionImp::info, 0, 0};
    262 
    263 DeclaredFunctionImp::DeclaredFunctionImp(ExecState* exec, const Identifier& n,
    264                                          FunctionBodyNode* b, const ScopeChain& sc)
    265   : FunctionImp(exec, n, b)
    266 {
    267   setScope(sc);
    268 }
    269 
    270 bool DeclaredFunctionImp::implementsConstruct() const
    271 {
    272   return true;
    273 }
    274 
    275245// ECMA 13.2.2 [[Construct]]
    276 JSObject* DeclaredFunctionImp::construct(ExecState* exec, const List& args)
     246JSObject* FunctionImp::construct(ExecState* exec, const List& args)
    277247{
    278248  JSObject* proto;
     
    293263}
    294264
    295 Completion DeclaredFunctionImp::execute(ExecState* exec)
     265Completion FunctionImp::execute(ExecState* exec)
    296266{
    297267  Completion result = body->execute(exec);
     
    302272}
    303273
    304 void DeclaredFunctionImp::processVarDecls(ExecState* exec)
     274void FunctionImp::processVarDecls(ExecState* exec)
    305275{
    306276    body->processDeclarations(exec);
     
    525495{
    526496  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    527 }
    528 
    529 CodeType GlobalFuncImp::codeType() const
    530 {
    531   return id == Eval ? EvalCode : codeType();
    532497}
    533498
Note: See TracChangeset for help on using the changeset viewer.