Changeset 3009 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Dec 11, 2002, 7:59:24 PM (22 years ago)
Author:
mjs
Message:

Reviewed by Don.

  • Add kjsprint global function in Development build for ease of debugging.
  • Print uncaught JavaScript exceptions to the console in Development.
  • Improve wording of exception error messages.
  • kjs/function.cpp: (GlobalFuncImp::call):
  • kjs/function.h:
  • kjs/internal.cpp: (InterpreterImp::initGlobalObject):
  • kjs/interpreter.cpp: (Interpreter::evaluate):
  • kjs/nodes.cpp: (NewExprNode::evaluate): (FunctionCallNode::evaluate): (RelationalNode::evaluate):
Location:
trunk/JavaScriptCore/kjs
Files:
5 edited

Legend:

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

    r2883 r3009  
    545545    break;
    546546  }
     547#if !NDEBUG
     548  case KJSPrint: {
     549    UString str = args[0].toString(exec);
     550    puts(str.ascii());
     551  }
     552#endif
    547553  }
    548554
  • trunk/JavaScriptCore/kjs/function.h

    r2883 r3009  
    127127    virtual Value call(ExecState *exec, Object &thisObj, const List &args);
    128128    virtual CodeType codeType() const;
    129     enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape };
     129    enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape
     130#if !NDEBUG
     131           , KJSPrint
     132#endif
     133};
    130134  private:
    131135    int id;
  • trunk/JavaScriptCore/kjs/internal.cpp

    r2935 r3009  
    648648  global.put(globExec,"escape",     Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::Escape,     1)), DontEnum);
    649649  global.put(globExec,"unescape",   Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::UnEscape,   1)), DontEnum);
     650#if !NDEBUG
     651  global.put(globExec,"kjsprint",   Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::KJSPrint,   1)), DontEnum);
     652#endif
    650653
    651654  // built-in objects
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r2935 r3009  
    112112Completion Interpreter::evaluate(const UString &code, const Value &thisV)
    113113{
    114   return rep->evaluate(code,thisV);
     114  Completion comp = rep->evaluate(code,thisV);
     115#if !NDEBUG
     116  if (comp.complType() == Throw) {
     117    lock();
     118    ExecState *exec = rep->globalExec();
     119    printf("Uncaught exception: %s\n", comp.value().toObject(exec).toString(exec).ascii());
     120    unlock();
     121  }
     122#endif
     123  return comp;
    115124}
    116125
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r2974 r3009  
    694694
    695695  if (v.type() != ObjectType) {
    696     return throwError(exec, TypeError, "Expression is no object. Cannot be new'ed");
     696    return throwError(exec, TypeError, "Value used with new is not object.");
    697697  }
    698698
    699699  Object constr = Object(static_cast<ObjectImp*>(v.imp()));
    700700  if (!constr.implementsConstruct()) {
    701     return throwError(exec, TypeError, "Expression is no constructor.");
     701    return throwError(exec, TypeError, "Value asked to construct is not a constructor.");
    702702  }
    703703
     
    743743    printInfo(exec, "WARNING: Failed function call attempt on", v, line);
    744744#endif
    745     return throwError(exec, TypeError, "Expression is no object. Cannot be called.");
     745    return throwError(exec, TypeError, "Value is not object. Cannot be called.");
    746746  }
    747747
     
    752752    printInfo(exec, "Failed function call attempt on", v, line);
    753753#endif
    754     return throwError(exec, TypeError, "Expression does not allow calls.");
     754    return throwError(exec, TypeError, "Object does not allow calls.");
    755755  }
    756756
     
    761761    printInfo(exec, "Exceeded maximum function call depth", v, line);
    762762#endif
    763     return throwError(exec, RangeError, "Exceeded maximum call stack size.");
     763    return throwError(exec, RangeError, "Exceeded maximum function call depth.");
    764764  }
    765765#endif
     
    12301230      if (v2.type() != ObjectType)
    12311231          return throwError(exec,  TypeError,
    1232                              "Shift expression not an object into IN expression." );
     1232                             "Used IN expression with non-object." );
    12331233      Object o2(static_cast<ObjectImp*>(v2.imp()));
    12341234      b = o2.hasProperty(exec, Identifier(v1.toString(exec)));
     
    12361236    if (v2.type() != ObjectType)
    12371237        return throwError(exec,  TypeError,
    1238                            "Called instanceof operator on non-object." );
     1238                           "Used instanceof operator on non-object." );
    12391239
    12401240    Object o2(static_cast<ObjectImp*>(v2.imp()));
Note: See TracChangeset for help on using the changeset viewer.