Changeset 4363 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- May 13, 2003, 2:19:57 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.