Changeset 4363 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- May 13, 2003, 2:19:57 PM (22 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/error_object.cpp
r3373 r4363 65 65 { 66 66 // toString() 67 UString s = "Error";67 UString s; 68 68 69 Value v = thisObj.get(exec, namePropertyName);69 Value v = thisObj.get(exec, "line"); 70 70 if (v.type() != UndefinedType) { 71 s = v.toString(exec); 71 s += v.toString(exec) += ": "; 72 } 73 74 75 v = thisObj.get(exec, namePropertyName); 76 if (v.type() != UndefinedType) { 77 s += v.toString(exec); 72 78 } 73 79 74 80 v = thisObj.get(exec, messagePropertyName); 75 81 if (v.type() != UndefinedType) { 76 s += " : "+v.toString(exec);82 s += " - " + v.toString(exec); 77 83 } 78 84 -
trunk/JavaScriptCore/kjs/internal.cpp
r4206 r4363 456 456 if (errMsg) 457 457 *errMsg = "Parse error at line " + UString::from(eline); 458 #ifndef NDEBUG459 fprintf(stderr, "KJS: JavaScript parse error at line %d.\n", eline);460 #endif461 458 delete prog; 462 459 return 0; -
trunk/JavaScriptCore/kjs/interpreter.cpp
r4087 r4363 116 116 } 117 117 118 Completion Interpreter::evaluate(const UString &code, const Value &thisV )118 Completion Interpreter::evaluate(const UString &code, const Value &thisV, const UString &filename) 119 119 { 120 120 Completion comp = rep->evaluate(code,thisV); 121 #ifndef NDEBUG 122 if (comp.complType() == Throw) { 121 122 #if APPLE_CHANGES 123 if (shouldPrintExceptions() && comp.complType() == Throw) { 123 124 lock(); 124 125 ExecState *exec = rep->globalExec(); 125 printf("Uncaught exception: %s\n", comp.value().toObject(exec).toString(exec).ascii()); 126 char *f = strdup(filename.ascii()); 127 const char *message = comp.value().toObject(exec).toString(exec).ascii(); 128 printf("%s:%s\n", f, message); 129 free(f); 126 130 unlock(); 127 131 } 128 132 #endif 133 129 134 return comp; 130 135 } … … 313 318 #endif 314 319 320 #if APPLE_CHANGES 321 static bool printExceptions = false; 322 323 bool Interpreter::shouldPrintExceptions() 324 { 325 return printExceptions; 326 } 327 328 void Interpreter::setShouldPrintExceptions(bool print) 329 { 330 printExceptions = print; 331 } 332 #endif 333 315 334 void Interpreter::virtual_hook( int, void* ) 316 335 { /*BASE::virtual_hook( id, data );*/ } -
trunk/JavaScriptCore/kjs/interpreter.h
r4087 r4363 187 187 * @return A completion object representing the result of the execution. 188 188 */ 189 Completion evaluate(const UString &code, const Value &thisV = Value() );189 Completion evaluate(const UString &code, const Value &thisV = Value(), const UString &filename = UString()); 190 190 191 191 /** … … 339 339 static void finalCheck(); 340 340 #endif 341 342 #if APPLE_CHANGES 343 static bool shouldPrintExceptions(); 344 static void setShouldPrintExceptions(bool); 345 #endif 346 341 347 private: 342 348 InterpreterImp *rep; -
trunk/JavaScriptCore/kjs/nodes.cpp
r4282 r4363 131 131 } 132 132 133 Value Node::throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr) 134 { 135 char *vStr = strdup(v.toString(exec).ascii()); 136 char *exprStr = strdup(expr->toString().ascii()); 137 138 int length = strlen(msg) - 4 /* two %s */ + strlen(vStr) + strlen(exprStr) + 1 /* null terminator */; 139 char *str = new char[length]; 140 sprintf(str, msg, vStr, exprStr); 141 free(vStr); 142 free(exprStr); 143 144 Value result = throwError(exec, e, str); 145 delete [] str; 146 147 return result; 148 } 149 150 151 Value Node::throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label) 152 { 153 const char *l = label.ascii(); 154 int length = strlen(msg) - 2 /* %s */ + strlen(l) + 1 /* null terminator */; 155 char *message = new char[length]; 156 sprintf(message, msg, l); 157 158 Value result = throwError(exec, e, message); 159 delete [] message; 160 161 return result; 162 } 163 133 164 // ------------------------------ StatementNode -------------------------------- 134 165 StatementNode::StatementNode() : l0(-1), l1(-1), sid(-1), breakPoint(false) … … 658 689 659 690 if (v.type() != ObjectType) { 660 return throwError(exec, TypeError, "Value used with new is not object.");691 return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr); 661 692 } 662 693 663 694 Object constr = Object(static_cast<ObjectImp*>(v.imp())); 664 695 if (!constr.implementsConstruct()) { 665 return throwError(exec, TypeError, "Value asked to construct is not a constructor.");696 return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr); 666 697 } 667 698 … … 704 735 705 736 if (v.type() != ObjectType) { 706 #ifndef NDEBUG 707 printInfo(exec, "WARNING: Failed function call attempt on", v, line); 708 #endif 709 return throwError(exec, TypeError, "Value is not object. Cannot be called."); 737 return throwError(exec, TypeError, "Value %s (result of expression %s) is not object. Cannot be called.", v, expr); 710 738 } 711 739 … … 713 741 714 742 if (!func.implementsCall()) { 715 #ifndef NDEBUG 716 printInfo(exec, "Failed function call attempt on", v, line); 717 #endif 718 return throwError(exec, TypeError, "Object does not allow calls."); 743 return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, expr); 719 744 } 720 745 … … 722 747 static int depth = 0; // sum of all concurrent interpreters 723 748 if (++depth > KJS_MAX_STACK) { 724 #ifndef NDEBUG 725 printInfo(exec, "Exceeded maximum function call depth", v, line); 726 #endif 727 return throwError(exec, RangeError, "Exceeded maximum function call depth."); 749 return throwError(exec, RangeError, "Exceeded maximum function call depth calling %s (result of expression %s).", v, expr); 728 750 } 729 751 #endif … … 1192 1214 if (v2.type() != ObjectType) 1193 1215 return throwError(exec, TypeError, 1194 " Used IN expression with non-object.");1216 "Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2); 1195 1217 Object o2(static_cast<ObjectImp*>(v2.imp())); 1196 1218 b = o2.hasProperty(exec, Identifier(v1.toString(exec))); … … 1198 1220 if (v2.type() != ObjectType) 1199 1221 return throwError(exec, TypeError, 1200 " Used instanceof operator on non-object.");1222 "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2); 1201 1223 1202 1224 Object o2(static_cast<ObjectImp*>(v2.imp())); … … 2148 2170 Value dummy; 2149 2171 return exec->context().imp()->seenLabels()->contains(ident) ? 2150 Completion( Continue, dummy, ident) :2172 Completion(Break, dummy, ident) : 2151 2173 Completion(Throw, 2152 throwError(exec, SyntaxError, "Label not found in containing block"));2174 throwError(exec, SyntaxError, "Label %s not found in containing block. Can't continue.", ident)); 2153 2175 } 2154 2176 … … 2164 2186 Completion(Break, dummy, ident) : 2165 2187 Completion(Throw, 2166 throwError(exec, SyntaxError, "Label not found in containing block"));2188 throwError(exec, SyntaxError, "Label %s not found in containing block. Can't break.", ident)); 2167 2189 } 2168 2190 … … 2519 2541 if (!exec->context().imp()->seenLabels()->push(label)) { 2520 2542 return Completion( Throw, 2521 throwError(exec, SyntaxError, "Duplicated label found"));2543 throwError(exec, SyntaxError, "Duplicated label %s found.", label)); 2522 2544 }; 2523 2545 e = statement->execute(exec); -
trunk/JavaScriptCore/kjs/nodes.h
r3373 r4363 100 100 protected: 101 101 Value throwError(ExecState *exec, ErrorType e, const char *msg); 102 Value throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr); 103 Value throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label); 102 104 int line; 103 105 unsigned int refcount;
Note:
See TracChangeset
for help on using the changeset viewer.