summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/JavaScriptCore/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/parser')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/Grammar.y2
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/Lexer.cpp16
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/Lexer.h4
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h1
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp84
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/Nodes.h11
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/Parser.h6
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h8
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.cpp109
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.h91
10 files changed, 292 insertions, 40 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Grammar.y b/src/3rdparty/webkit/JavaScriptCore/parser/Grammar.y
index 354c78630..a3bf1feae 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/Grammar.y
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/Grammar.y
@@ -62,7 +62,7 @@ static inline bool allowAutomaticSemicolon(JSC::Lexer&, int);
#define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0)
#define SET_EXCEPTION_LOCATION(node, start, divot, end) node->setExceptionSourceCode((divot), (divot) - (start), (end) - (divot))
-#define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line)
+#define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line, (s).first_column + 1)
using namespace JSC;
using namespace std;
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.cpp b/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.cpp
index 8e89c18a9..c36763c1b 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.cpp
@@ -59,6 +59,7 @@ static const UChar byteOrderMark = 0xFEFF;
Lexer::Lexer(JSGlobalData* globalData)
: m_isReparsing(false)
, m_globalData(globalData)
+ , m_startColumnNumberCorrection(0)
, m_keywordTable(JSC::mainTable)
{
m_buffer8.reserveInitialCapacity(initialReadBufferCapacity);
@@ -201,6 +202,7 @@ void Lexer::shiftLineTerminator()
else
shift1();
+ m_startColumnNumberCorrection = currentOffset();
++m_lineNumber;
}
@@ -293,11 +295,15 @@ start:
int startOffset = currentOffset();
if (m_current == -1) {
+#ifndef QT_BUILD_SCRIPT_LIB /* the parser takes cate about automatic semicolon.
+ this might add incorrect semicolons */
+ //m_delimited and m_isReparsing are now useless
if (!m_terminator && !m_delimited && !m_isReparsing) {
// automatic semicolon insertion if program incomplete
token = ';';
goto doneSemicolon;
}
+#endif
return 0;
}
@@ -893,11 +899,11 @@ doneString:
// Fall through into returnToken.
returnToken: {
- int lineNumber = m_lineNumber;
- llocp->first_line = lineNumber;
- llocp->last_line = lineNumber;
- llocp->first_column = startOffset;
- llocp->last_column = currentOffset();
+ llocp->first_line = m_lineNumber;
+ llocp->last_line = m_lineNumber;
+
+ llocp->first_column = startOffset - m_startColumnNumberCorrection;
+ llocp->last_column = currentOffset() - m_startColumnNumberCorrection;
m_lastToken = token;
return token;
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.h b/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.h
index 25831628d..0ef6dd49a 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.h
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/Lexer.h
@@ -87,6 +87,10 @@ namespace JSC {
static const size_t initialIdentifierTableCapacity = 64;
int m_lineNumber;
+ // this variable is supposed to keep index of last new line character ('\n' or '\r\n'or '\n\r'...)
+ // it is importent to calculate correct first_column in parser
+ int m_startColumnNumberCorrection;
+
Vector<char> m_buffer8;
Vector<UChar> m_buffer16;
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h b/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h
index 780a6246e..c25619079 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h
@@ -63,6 +63,7 @@ namespace JSC {
inline StatementNode::StatementNode(JSGlobalData* globalData)
: Node(globalData)
, m_lastLine(-1)
+ , m_column(-1)
{
}
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp b/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp
index 6c0d1af0c..9d9fe7202 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.cpp
@@ -83,10 +83,11 @@ RegisterID* ThrowableExpressionData::emitThrowError(BytecodeGenerator& generator
// ------------------------------ StatementNode --------------------------------
-void StatementNode::setLoc(int firstLine, int lastLine)
+void StatementNode::setLoc(int firstLine, int lastLine, int column)
{
m_line = firstLine;
m_lastLine = lastLine;
+ m_column = column;
}
// ------------------------------ SourceElements --------------------------------
@@ -1225,7 +1226,7 @@ RegisterID* ConstDeclNode::emitBytecode(BytecodeGenerator& generator, RegisterID
RegisterID* ConstStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
return generator.emitNode(m_next);
}
@@ -1250,7 +1251,7 @@ RegisterID* BlockNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RegisterID* EmptyStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
return dst;
}
@@ -1258,7 +1259,7 @@ RegisterID* EmptyStatementNode::emitBytecode(BytecodeGenerator& generator, Regis
RegisterID* DebuggerStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(DidReachBreakpoint, firstLine(), lastLine());
+ generator.emitDebugHook(DidReachBreakpoint, firstLine(), lastLine(), column());
return dst;
}
@@ -1267,7 +1268,7 @@ RegisterID* DebuggerStatementNode::emitBytecode(BytecodeGenerator& generator, Re
RegisterID* ExprStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
ASSERT(m_expr);
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
return generator.emitNode(dst, m_expr);
}
@@ -1276,7 +1277,7 @@ RegisterID* ExprStatementNode::emitBytecode(BytecodeGenerator& generator, Regist
RegisterID* VarStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
{
ASSERT(m_expr);
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
return generator.emitNode(m_expr);
}
@@ -1284,7 +1285,7 @@ RegisterID* VarStatementNode::emitBytecode(BytecodeGenerator& generator, Registe
RegisterID* IfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
RefPtr<Label> afterThen = generator.newLabel();
@@ -1302,7 +1303,7 @@ RegisterID* IfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
RegisterID* IfElseNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
RefPtr<Label> beforeElse = generator.newLabel();
RefPtr<Label> afterElse = generator.newLabel();
@@ -1332,12 +1333,14 @@ RegisterID* DoWhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID*
RefPtr<Label> topOfLoop = generator.newLabel();
generator.emitLabel(topOfLoop.get());
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
RefPtr<RegisterID> result = generator.emitNode(dst, m_statement);
generator.emitLabel(scope->continueTarget());
- generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo());
+#ifndef QT_BUILD_SCRIPT_LIB
+ generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo(), column());
+#endif
RegisterID* cond = generator.emitNode(m_expr);
generator.emitJumpIfTrue(cond, topOfLoop.get());
@@ -1350,7 +1353,9 @@ RegisterID* DoWhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID*
RegisterID* WhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
-
+#ifdef QT_BUILD_SCRIPT_LIB
+ generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo(), column());
+#endif
generator.emitJump(scope->continueTarget());
RefPtr<Label> topOfLoop = generator.newLabel();
@@ -1359,7 +1364,9 @@ RegisterID* WhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
generator.emitNode(dst, m_statement);
generator.emitLabel(scope->continueTarget());
- generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo());
+#ifndef QT_BUILD_SCRIPT_LIB
+ generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo(), column());
+#endif
RegisterID* cond = generator.emitNode(m_expr);
generator.emitJumpIfTrue(cond, topOfLoop.get());
@@ -1378,7 +1385,7 @@ RegisterID* ForNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
if (m_expr1)
generator.emitNode(generator.ignoredResult(), m_expr1);
@@ -1392,7 +1399,9 @@ RegisterID* ForNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
RefPtr<RegisterID> result = generator.emitNode(dst, m_statement);
generator.emitLabel(scope->continueTarget());
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+#ifndef QT_BUILD_SCRIPT_LIB
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
+#endif
if (m_expr3)
generator.emitNode(generator.ignoredResult(), m_expr3);
@@ -1418,7 +1427,7 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RefPtr<Label> continueTarget = generator.newLabel();
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
if (m_init)
generator.emitNode(generator.ignoredResult(), m_init);
@@ -1466,7 +1475,9 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
generator.emitLabel(scope->continueTarget());
generator.emitNextPropertyName(propertyName, iter.get(), loopStart.get());
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+#ifndef QT_BUILD_SCRIPT_LIB
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
+#endif
generator.emitLabel(scope->breakTarget());
return dst;
}
@@ -1476,7 +1487,7 @@ RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
// ECMA 12.7
RegisterID* ContinueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
LabelScope* scope = generator.continueTarget(m_ident);
@@ -1494,7 +1505,7 @@ RegisterID* ContinueNode::emitBytecode(BytecodeGenerator& generator, RegisterID*
// ECMA 12.8
RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
LabelScope* scope = generator.breakTarget(m_ident);
@@ -1511,7 +1522,7 @@ RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RegisterID* ReturnNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
if (generator.codeType() != FunctionCode)
return emitThrowError(generator, SyntaxError, "Invalid return statement.");
@@ -1528,7 +1539,7 @@ RegisterID* ReturnNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d
generator.emitJumpScopes(l0.get(), 0);
generator.emitLabel(l0.get());
}
- generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine());
+ generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine(), column());
return generator.emitReturn(r0);
}
@@ -1536,7 +1547,7 @@ RegisterID* ReturnNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d
RegisterID* WithNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
RefPtr<RegisterID> scope = generator.newTemporary();
generator.emitNode(scope.get(), m_expr); // scope must be protected until popped
@@ -1695,7 +1706,7 @@ RegisterID* CaseBlockNode::emitBytecodeForBlock(BytecodeGenerator& generator, Re
RegisterID* SwitchNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Switch);
@@ -1710,7 +1721,7 @@ RegisterID* SwitchNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d
RegisterID* LabelNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
if (generator.breakTarget(m_name))
return emitThrowError(generator, SyntaxError, "Duplicate label: %s.", m_name);
@@ -1726,7 +1737,7 @@ RegisterID* LabelNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RegisterID* ThrowNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
if (dst == generator.ignoredResult())
dst = 0;
@@ -1740,7 +1751,9 @@ RegisterID* ThrowNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RegisterID* TryNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+#ifndef QT_BUILD_SCRIPT_LIB
+ generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine(), column());
+#endif
RefPtr<Label> tryStartLabel = generator.newLabel();
RefPtr<Label> tryEndLabel = generator.newLabel();
@@ -1875,13 +1888,13 @@ PassRefPtr<ProgramNode> ProgramNode::create(JSGlobalData* globalData, SourceElem
RegisterID* ProgramNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
{
- generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine(), column());
RefPtr<RegisterID> dstRegister = generator.newTemporary();
generator.emitLoad(dstRegister.get(), jsUndefined());
statementListEmitCode(children(), generator, dstRegister.get());
- generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine());
+ generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine(), column());
generator.emitEnd(dstRegister.get());
return 0;
}
@@ -1930,13 +1943,13 @@ PassRefPtr<EvalNode> EvalNode::create(JSGlobalData* globalData, SourceElements*
RegisterID* EvalNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
{
- generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine());
+ generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine(), column());
RefPtr<RegisterID> dstRegister = generator.newTemporary();
generator.emitLoad(dstRegister.get(), jsUndefined());
statementListEmitCode(children(), generator, dstRegister.get());
- generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine());
+ generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine(), column());
generator.emitEnd(dstRegister.get());
return 0;
}
@@ -1996,6 +2009,9 @@ inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData)
, m_parameters(0)
, m_parameterCount(0)
{
+#ifdef QT_BUILD_SCRIPT_LIB
+ sourceToken = globalData->scriptpool->objectRegister();
+#endif
}
inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
@@ -2003,10 +2019,16 @@ inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, SourceElemen
, m_parameters(0)
, m_parameterCount(0)
{
+#ifdef QT_BUILD_SCRIPT_LIB
+ sourceToken = globalData->scriptpool->objectRegister();
+#endif
}
FunctionBodyNode::~FunctionBodyNode()
{
+#ifdef QT_BUILD_SCRIPT_LIB
+ if (sourceToken) delete sourceToken;
+#endif
for (size_t i = 0; i < m_parameterCount; ++i)
m_parameters[i].~Identifier();
fastFree(m_parameters);
@@ -2116,7 +2138,7 @@ CodeBlock& FunctionBodyNode::bytecodeForExceptionInfoReparse(ScopeChainNode* sco
RegisterID* FunctionBodyNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
{
- generator.emitDebugHook(DidEnterCallFrame, firstLine(), lastLine());
+ generator.emitDebugHook(DidEnterCallFrame, firstLine(), lastLine(), column());
statementListEmitCode(children(), generator, generator.ignoredResult());
if (children().size() && children().last()->isBlock()) {
BlockNode* blockNode = static_cast<BlockNode*>(children().last());
@@ -2125,7 +2147,7 @@ RegisterID* FunctionBodyNode::emitBytecode(BytecodeGenerator& generator, Registe
}
RegisterID* r0 = generator.emitLoad(0, jsUndefined());
- generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine());
+ generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine(), column());
generator.emitReturn(r0);
return 0;
}
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.h b/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.h
index 84e8b958a..185cedeee 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.h
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/Nodes.h
@@ -36,6 +36,10 @@
#include <wtf/MathExtras.h>
#include <wtf/OwnPtr.h>
+#ifdef QT_BUILD_SCRIPT_LIB
+#include "SourcePoolQt.h"
+#endif
+
namespace JSC {
class ArgumentListNode;
@@ -191,9 +195,10 @@ namespace JSC {
public:
StatementNode(JSGlobalData*);
- void setLoc(int line0, int line1);
+ void setLoc(int line0, int line1, int column);
int firstLine() const { return lineNo(); }
int lastLine() const { return m_lastLine; }
+ int column() const { return m_column; }
virtual bool isEmptyStatement() const { return false; }
virtual bool isReturnNode() const { return false; }
@@ -203,6 +208,7 @@ namespace JSC {
private:
int m_lastLine;
+ int m_column;
};
class NullNode : public ExpressionNode {
@@ -1605,6 +1611,9 @@ namespace JSC {
Identifier* m_parameters;
size_t m_parameterCount;
OwnPtr<CodeBlock> m_code;
+#ifdef QT_BUILD_SCRIPT_LIB
+ SourcePool::SourcePoolToken* sourceToken;
+#endif
};
class FuncExprNode : public ExpressionNode, public ParserArenaRefCounted {
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/Parser.h b/src/3rdparty/webkit/JavaScriptCore/parser/Parser.h
index 373dc0008..5a182a631 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/Parser.h
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/Parser.h
@@ -76,7 +76,8 @@ namespace JSC {
*m_source,
m_features,
m_numConstants);
- result->setLoc(m_source->firstLine(), m_lastLine);
+ int column = m_source->startOffset(); //is it good way to find column number?
+ result->setLoc(m_source->firstLine(), m_lastLine, column);
}
m_arena.reset();
@@ -103,7 +104,8 @@ namespace JSC {
*m_source,
oldParsedNode->features(),
m_numConstants);
- result->setLoc(m_source->firstLine(), m_lastLine);
+ int column = m_source->startOffset(); //is it good way to find column number?
+ result->setLoc(m_source->firstLine(), m_lastLine, column);
}
m_arena.reset();
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h b/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h
index 84360b84c..305b80444 100644
--- a/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h
@@ -47,7 +47,11 @@ namespace JSC {
: m_provider(provider)
, m_startChar(0)
, m_endChar(m_provider->length())
+#ifdef QT_BUILD_SCRIPT_LIB
+ , m_firstLine(firstLine)
+#else
, m_firstLine(std::max(firstLine, 1))
+#endif
{
}
@@ -55,7 +59,11 @@ namespace JSC {
: m_provider(provider)
, m_startChar(start)
, m_endChar(end)
+#ifdef QT_BUILD_SCRIPT_LIB
+ , m_firstLine(firstLine)
+#else
, m_firstLine(std::max(firstLine, 1))
+#endif
{
}
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.cpp b/src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.cpp
new file mode 100644
index 000000000..4fc859f54
--- /dev/null
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.cpp
@@ -0,0 +1,109 @@
+/*
+ Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "SourcePoolQt.h"
+
+
+#ifdef QT_BUILD_SCRIPT_LIB
+
+#include "SourceCode.h"
+#include "Debugger.h"
+
+
+namespace JSC {
+
+ void SourcePool::startEvaluating(const SourceCode& source)
+ {
+ int id = source.provider()->asID();
+
+ codes.insert(id,source.toString());
+
+ currentScript.push(id);
+ scriptRef.insert(id,ScriptActivCount());
+
+ if (debug)
+ debug->scriptLoad(id,source.toString(),source.provider()->url(),source.firstLine());
+ }
+
+
+ void SourcePool::stopEvaluating(const SourceCode& source)
+ {
+ int id = source.provider()->asID();
+ currentScript.pop();
+
+ if (scriptRef.contains(id)) {
+ ScriptActivCount info = scriptRef.take(id);
+ if (info.getCount()) {
+ //we can't remove info from scriptRef
+ info.isActive = false;
+ scriptRef.insert(id,info);
+ } else {
+ //we are unloading source code
+ if (debug)
+ debug->scriptUnload(id);
+ }
+ }
+ }
+
+ SourcePool::SourcePoolToken* SourcePool::objectRegister()
+ {
+ if (currentScript.isEmpty()) {
+ return 0;
+ }
+
+ int id = currentScript.top();
+
+ SourcePoolToken* token = new SourcePoolToken(id,this);
+
+ ScriptActivCount info = scriptRef.take(id);
+
+ info.incCount();
+ scriptRef.insert(id,info);
+ return token;
+ }
+
+ void SourcePool::objectUnregister(const SourcePool::SourcePoolToken *token)
+ {
+ int id = token->id;
+
+ ScriptActivCount info = scriptRef.take(id);
+ info.decCount();
+ if (info.isActive) {
+ scriptRef.insert(id,info);
+ } else {
+ if (info.getCount() == 0) {
+ //remove from scriptRef (script is not active and there is no objects connected)
+ if(debug)
+ debug->scriptUnload(id);
+ } else {
+ scriptRef.insert(id,info);
+ }
+ }
+
+ }
+
+
+ void SourcePool::setDebugger(JSC::Debugger *debugger) { this->debug = debugger; }
+ Debugger* SourcePool::debugger() { return debug; }
+
+} //namespace JSC
+
+
+#endif //QT_BUILD_SCRIPT_LIB
diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.h b/src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.h
new file mode 100644
index 000000000..baed3ba64
--- /dev/null
+++ b/src/3rdparty/webkit/JavaScriptCore/parser/SourcePoolQt.h
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef SOURCEPOOL_H
+#define SOURCEPOOL_H
+
+#ifdef QT_BUILD_SCRIPT_LIB
+
+#include "qhash.h"
+#include "qstack.h"
+#include "qdebug.h"
+#include <stdint.h>
+
+namespace JSC {
+
+ class SourceCode;
+ class Debugger;
+
+ class SourcePool
+ {
+ class ScriptActivCount
+ {
+ int count;
+ public:
+ void incCount()
+ {
+ count++;
+ };
+ void decCount()
+ {
+ count--;
+ };
+ int getCount() const
+ {
+ return count;
+ };
+ bool isActive;
+ ScriptActivCount() : count(0), isActive(true) {}
+ };
+ QStack<intptr_t> currentScript;
+ QHash<unsigned, ScriptActivCount> scriptRef;
+ QHash<int, QString> codes; //debug
+ Debugger *debug;
+
+ friend class SourcePoolToken;
+ public:
+ class SourcePoolToken
+ {
+ unsigned id;
+ SourcePool *ptr;
+ SourcePoolToken(unsigned scriptId, SourcePool *scriptPool) : id(scriptId),ptr(scriptPool) {}
+ SourcePoolToken(const SourcePoolToken&) : id(0), ptr(0) {} //private - do not use - will crash
+ public:
+ ~SourcePoolToken() { ptr->objectUnregister(this); }
+ friend class SourcePool;
+ };
+
+ SourcePool() : debug(0) {}
+
+ void startEvaluating(const SourceCode& source);
+ void stopEvaluating(const SourceCode& source);
+ SourcePoolToken* objectRegister();
+
+ void setDebugger(Debugger *debugger);
+ Debugger* debugger();
+
+ private:
+ void objectUnregister(const SourcePoolToken *token);
+ };
+
+} //namespace JSC
+
+
+#endif //QT_BUILD_SCRIPT_LIB
+
+#endif // SOURCEPOOL_H