[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kjs
From: Maks Orlovich <maksim () kde ! org>
Date: 2008-11-17 18:18:34
Message-ID: 1226945914.225272.25158.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 885675 by orlovich:
Provide a hook for KHTML to enable reindenting (plus an another one
I'll eventuallyuse to fix a bug on my TODO); fix line-numbering
off-by-one and top-level serialization
M +18 -0 debugger.cpp
M +16 -0 debugger.h
M +1 -3 function.cpp
M +1 -5 function_object.cpp
M +2 -3 interpreter.cpp
M +1 -0 nodes.h
M +11 -1 nodes2string.cpp
--- trunk/KDE/kdelibs/kjs/debugger.cpp #885674:885675
@@ -139,3 +139,21 @@
return true;
}
+bool Debugger::shouldReindentSources() const
+{
+ return false;
+}
+
+bool Debugger::shouldReportCaught() const
+{
+ return false;
+}
+
+void Debugger::reportSourceParsed(ExecState *exec, FunctionBodyNode *body, const \
UString &source, + int startingLineNumber, int \
errorLine, const UString &errorMsg) +{
+ UString code = source;
+ if (shouldReindentSources())
+ code = body->reindent(startingLineNumber);
+ sourceParsed(exec, body->sourceId(), body->sourceURL(), code, startingLineNumber, \
errorLine, errorMsg); +}
--- trunk/KDE/kdelibs/kjs/debugger.h #885674:885675
@@ -36,6 +36,7 @@
class JSValue;
class UString;
class List;
+ class FunctionBodyNode;
/**
* @internal
@@ -206,10 +207,23 @@
virtual bool exitContext(ExecState *exec, int sourceId, int lineno,
JSObject *function);
+
+ // Override this and return true if you want the debugger to report
+ // pretty-printed versions of the source.
+ virtual bool shouldReindentSources() const;
+
+ // Override this to return true if the debugger should report
+ // exceptions even if there is a try block waiting for it.
+ virtual bool shouldReportCaught() const;
+
// The two methods below call the events but also keep track/use of line # \
information // so we can associate it with exceptions
void reportAtStatement(ExecState *exec, int sourceId, int firstLine, int \
lastLine); void reportException (ExecState *exec, JSValue *exception);
+
+ // This notifies the debugger of source being parsed, reindenting it if need be.
+ void reportSourceParsed(ExecState *exec, FunctionBodyNode *body,
+ const UString &source, int startingLineNumber, int \
errorLine, const UString &errorMsg); private:
DebuggerImp *rep;
HashMap<Interpreter*, ProtectedPtr<JSValue> > latestExceptions;
@@ -221,3 +235,5 @@
}
#endif
+
+// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;
\ No newline at end of file
--- trunk/KDE/kdelibs/kjs/function.cpp #885674:885675
@@ -856,9 +856,7 @@
Debugger *dbg = exec->dynamicInterpreter()->debugger();
if (dbg) {
- bool cont = dbg->sourceParsed(exec, sourceId, UString(), s, 0, errLine, \
errMsg);
- if (!cont)
- return jsUndefined();
+ dbg->reportSourceParsed(exec, progNode.get(), s, 0, errLine, errMsg);
}
// no program node means a syntax occurred
--- trunk/KDE/kdelibs/kjs/function_object.cpp #885674:885675
@@ -191,11 +191,7 @@
Debugger *dbg = exec->dynamicInterpreter()->debugger();
if (dbg) {
// make sure to pass in sourceURL, since it's useful for lazy event listeners, \
and empty for actual function ctor
- bool cont = dbg->sourceParsed(exec, sourceId, sourceURL, body, lineNumber, \
errLine, errMsg);
- if (!cont) {
- dbg->imp()->abort();
- return new JSObject();
- }
+ dbg->reportSourceParsed(exec, functionBody.get(), body, lineNumber, errLine, \
errMsg); }
// no program node == syntax error - throw a syntax error
--- trunk/KDE/kdelibs/kjs/interpreter.cpp #885674:885675
@@ -509,9 +509,8 @@
// notify debugger that source has been parsed
if (m_debugger) {
- bool cont = m_debugger->sourceParsed(&m_globalExec, sourceId, sourceURL, \
UString(code, codeLength), startingLineNumber, errLine, errMsg);
- if (!cont)
- return Completion(Break);
+ m_debugger->reportSourceParsed(&m_globalExec, progNode.get(),
+ UString(code, codeLength), startingLineNumber, errLine, \
errMsg); }
// no program node means a syntax error occurred
--- trunk/KDE/kdelibs/kjs/nodes.h #885674:885675
@@ -1229,6 +1229,7 @@
class ProgramNode : public FunctionBodyNode {
public:
ProgramNode(SourceElementsNode *s);
+ virtual void streamTo(SourceStream&) const;
};
class PackageNameNode : public Node {
--- trunk/KDE/kdelibs/kjs/nodes2string.cpp #885674:885675
@@ -29,6 +29,8 @@
#include "function.h"
#include "scriptfunction.h"
+#include <typeinfo>
+
#define NOINLINE
#if COMPILER(CWP)
#pragma auto_inline off
@@ -149,7 +151,9 @@
{
if (n) {
// Update debug info with new line numbers if needed.
- int firstLine = reindentLine;
+ // Note that streamTo will output endLine first thing,
+ // so we want the next line in the debug info
+ int firstLine = reindentLine + 1;
n->streamTo(*this);
if (reindenting)
n->setLoc(firstLine, reindentLine - 1);
@@ -647,6 +651,12 @@
<< source << SourceStream::Unindent << SourceStream::Endl << '}';
}
+void ProgramNode::streamTo(SourceStream &s) const
+{
+ // we don't want braces here, unlike in the above
+ s << source << SourceStream::Endl;
+}
+
void EmptyStatementNode::streamTo(SourceStream &s) const
{
s << SourceStream::Endl << ';';
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic