Commit 9132b10b authored by mjs's avatar mjs

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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3009 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f8849e1a
2002-12-11 Maciej Stachowiak <mjs@apple.com>
Reviewed by NOBODY (OOPS!).
- 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):
2002-12-10 John Sullivan <sullivan@apple.com>
Fixed more "Alexander"s that were lurking in places I forgot
......
2002-12-11 Maciej Stachowiak <mjs@apple.com>
Reviewed by NOBODY (OOPS!).
- 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):
2002-12-10 John Sullivan <sullivan@apple.com>
Fixed more "Alexander"s that were lurking in places I forgot
......
......@@ -544,6 +544,12 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
res = String(s);
break;
}
#if !NDEBUG
case KJSPrint: {
UString str = args[0].toString(exec);
puts(str.ascii());
}
#endif
}
return res;
......
......@@ -126,7 +126,11 @@ namespace KJS {
virtual bool implementsCall() const;
virtual Value call(ExecState *exec, Object &thisObj, const List &args);
virtual CodeType codeType() const;
enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape };
enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape
#if !NDEBUG
, KJSPrint
#endif
};
private:
int id;
};
......
......@@ -647,6 +647,9 @@ void InterpreterImp::initGlobalObject()
global.put(globExec,"isFinite", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::IsFinite, 1)), DontEnum);
global.put(globExec,"escape", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::Escape, 1)), DontEnum);
global.put(globExec,"unescape", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::UnEscape, 1)), DontEnum);
#if !NDEBUG
global.put(globExec,"kjsprint", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::KJSPrint, 1)), DontEnum);
#endif
// built-in objects
global.put(globExec,"Math", Object(new MathObjectImp(globExec,objProto)), DontEnum);
......
......@@ -111,7 +111,16 @@ bool Interpreter::checkSyntax(const UString &code)
Completion Interpreter::evaluate(const UString &code, const Value &thisV)
{
return rep->evaluate(code,thisV);
Completion comp = rep->evaluate(code,thisV);
#if !NDEBUG
if (comp.complType() == Throw) {
lock();
ExecState *exec = rep->globalExec();
printf("Uncaught exception: %s\n", comp.value().toObject(exec).toString(exec).ascii());
unlock();
}
#endif
return comp;
}
InterpreterImp *Interpreter::imp()
......
......@@ -693,12 +693,12 @@ Value NewExprNode::evaluate(ExecState *exec)
}
if (v.type() != ObjectType) {
return throwError(exec, TypeError, "Expression is no object. Cannot be new'ed");
return throwError(exec, TypeError, "Value used with new is not object.");
}
Object constr = Object(static_cast<ObjectImp*>(v.imp()));
if (!constr.implementsConstruct()) {
return throwError(exec, TypeError, "Expression is no constructor.");
return throwError(exec, TypeError, "Value asked to construct is not a constructor.");
}
Value res = constr.construct(exec,argList);
......@@ -742,7 +742,7 @@ Value FunctionCallNode::evaluate(ExecState *exec)
#ifndef NDEBUG
printInfo(exec, "WARNING: Failed function call attempt on", v, line);
#endif
return throwError(exec, TypeError, "Expression is no object. Cannot be called.");
return throwError(exec, TypeError, "Value is not object. Cannot be called.");
}
Object func = Object(static_cast<ObjectImp*>(v.imp()));
......@@ -751,7 +751,7 @@ Value FunctionCallNode::evaluate(ExecState *exec)
#ifndef NDEBUG
printInfo(exec, "Failed function call attempt on", v, line);
#endif
return throwError(exec, TypeError, "Expression does not allow calls.");
return throwError(exec, TypeError, "Object does not allow calls.");
}
#if KJS_MAX_STACK > 0
......@@ -760,7 +760,7 @@ Value FunctionCallNode::evaluate(ExecState *exec)
#ifndef NDEBUG
printInfo(exec, "Exceeded maximum function call depth", v, line);
#endif
return throwError(exec, RangeError, "Exceeded maximum call stack size.");
return throwError(exec, RangeError, "Exceeded maximum function call depth.");
}
#endif
......@@ -1229,13 +1229,13 @@ Value RelationalNode::evaluate(ExecState *exec)
// Is all of this OK for host objects?
if (v2.type() != ObjectType)
return throwError(exec, TypeError,
"Shift expression not an object into IN expression." );
"Used IN expression with non-object." );
Object o2(static_cast<ObjectImp*>(v2.imp()));
b = o2.hasProperty(exec, Identifier(v1.toString(exec)));
} else {
if (v2.type() != ObjectType)
return throwError(exec, TypeError,
"Called instanceof operator on non-object." );
"Used instanceof operator on non-object." );
Object o2(static_cast<ObjectImp*>(v2.imp()));
if (!o2.implementsHasInstance()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment