Commit fd3fb099 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 7a847df2 96bff6ea
......@@ -31,7 +31,6 @@
#include <cctype>
#include <QtCore/QFile>
#include <QtCore/QDir>
#include <QtCore/QFutureInterface>
#include <QtCore/QtConcurrentRun>
#include <QtCore/QRegExp>
......@@ -158,7 +157,7 @@ void runFileSearch(QFutureInterface<FileSearchResult> &future,
int n = 0;
while (startOfLastLine[i] != '\n' && startOfLastLine[i] != '\r' && i < textLength && n++ < 256)
res.append(startOfLastLine[i++]);
future.reportResult(FileSearchResult(QDir::toNativeSeparators(s), lineNr, QString(res),
future.reportResult(FileSearchResult(s, lineNr, QString(res),
regionPtr - startOfLastLine, sa.length()));
++numMatches;
}
......@@ -204,7 +203,7 @@ void runFileSearchRegExp(QFutureInterface<FileSearchResult> &future,
line = stream.readLine();
int pos = 0;
while ((pos = expression.indexIn(line, pos)) != -1) {
future.reportResult(FileSearchResult(QDir::toNativeSeparators(s), lineNr, line,
future.reportResult(FileSearchResult(s, lineNr, line,
pos, expression.matchedLength()));
pos += expression.matchedLength();
}
......
----------------------------------------------------------------------------
--
-- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-- Contact: Nokia Corporation (qt-info@nokia.com)
-- Contact: Qt Software Information (qt-info@nokia.com)
--
-- This file is part of the QtScript module of the Qt Toolkit.
-- This file is part of the QtDeclarative module of the Qt Toolkit.
--
-- $QT_BEGIN_LICENSE:LGPL$
-- No Commercial Usage
......@@ -34,7 +34,7 @@
-- met: http://www.gnu.org/copyleft/gpl.html.
--
-- If you are unsure which license is appropriate for your use, please
-- contact the sales department at http://www.qtsoftware.com/contact.
-- contact the sales department at qt-sales@nokia.com.
-- $QT_END_LICENSE$
--
-- This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
......@@ -84,18 +84,24 @@
--- context keywords.
%token T_PUBLIC "public"
%token T_IMPORT "import"
%token T_AS "as"
--- feed tokens
%token T_FEED_UI_PROGRAM
%token T_FEED_JS_STATEMENT
%token T_FEED_JS_EXPRESSION
%nonassoc SHIFT_THERE
%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY
%nonassoc REDUCE_HERE
%start UiProgram
%start TopLevel
/.
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
......@@ -128,7 +134,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......@@ -148,7 +154,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
......@@ -181,7 +187,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......@@ -254,6 +260,7 @@ public:
AST::UiProgram *UiProgram;
AST::UiImportList *UiImportList;
AST::UiImport *UiImport;
AST::UiParameterList *UiParameterList;
AST::UiPublicMember *UiPublicMember;
AST::UiObjectDefinition *UiObjectDefinition;
AST::UiObjectInitializer *UiObjectInitializer;
......@@ -270,10 +277,29 @@ public:
Parser(Engine *engine);
~Parser();
bool parse();
// parse a UI program
bool parse() { return parse(T_FEED_UI_PROGRAM); }
bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
AST::UiProgram *ast() const
{ return AST::cast<AST::UiProgram *>(program); }
AST::Statement *statement() const
{
if (! program)
return 0;
return program->statementCast();
}
AST::ExpressionNode *expression() const
{
if (! program)
return 0;
AST::UiProgram *ast()
{ return program; }
return program->expressionCast();
}
QList<DiagnosticMessage> diagnosticMessages() const
{ return diagnostic_messages; }
......@@ -298,6 +324,8 @@ public:
{ return diagnosticMessage().loc.startColumn; }
protected:
bool parse(int startToken);
void reallocateStack();
inline Value &sym(int index)
......@@ -316,7 +344,7 @@ protected:
int *state_stack;
AST::SourceLocation *location_stack;
AST::UiProgram *program;
AST::Node *program;
// error recovery
enum { TOKEN_BUFFER_SIZE = 3 };
......@@ -437,14 +465,16 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
return 0;
}
bool Parser::parse()
bool Parser::parse(int startToken)
{
Lexer *lexer = driver->lexer();
bool hadErrors = false;
int yytoken = -1;
int action = 0;
first_token = last_token = 0;
token_buffer[0].token = startToken;
first_token = &token_buffer[0];
last_token = &token_buffer[1];
tos = -1;
program = 0;
......@@ -492,12 +522,35 @@ bool Parser::parse()
-- Declarative UI
--------------------------------------------------------------------------------------------------------
TopLevel: T_FEED_UI_PROGRAM UiProgram ;
/.
case $rule_number: {
sym(1).Node = sym(2).Node;
program = sym(1).Node;
} break;
./
TopLevel: T_FEED_JS_STATEMENT Statement ;
/.
case $rule_number: {
sym(1).Node = sym(2).Node;
program = sym(1).Node;
} break;
./
TopLevel: T_FEED_JS_EXPRESSION Expression ;
/.
case $rule_number: {
sym(1).Node = sym(2).Node;
program = sym(1).Node;
} break;
./
UiProgram: UiImportListOpt UiRootMember ;
/.
case $rule_number: {
program = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
sym(2).UiObjectMemberList->finish());
sym(1).UiProgram = program;
} break;
./
......@@ -536,6 +589,77 @@ case $rule_number: {
} break;
./
UiImport: T_IMPORT T_STRING_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT T_STRING_LITERAL T_AS JsIdentifier T_SEMICOLON;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval);
node->importId = sym(4).sval;
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->asToken = loc(3);
node->importIdToken = loc(4);
node->semicolonToken = loc(5);
sym(1).Node = node;
} break;
./
UiImport: T_IMPORT UiQualifiedId T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_SEMICOLON;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
./
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_SEMICOLON;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->versionToken = loc(3);
node->semicolonToken = loc(4);
sym(1).Node = node;
} break;
./
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importId = sym(5).sval;
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->versionToken = loc(3);
node->asToken = loc(4);
node->importIdToken = loc(5);
node->semicolonToken = loc(6);
sym(1).Node = node;
} break;
./
UiImport: T_IMPORT UiQualifiedId T_AS JsIdentifier T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_AS JsIdentifier T_SEMICOLON;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importId = sym(4).sval;
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->asToken = loc(3);
node->importIdToken = loc(4);
node->semicolonToken = loc(5);
sym(1).Node = node;
} break;
./
Empty: ;
/.
case $rule_number: {
......@@ -706,6 +830,52 @@ case $rule_number: {
UiPropertyType: T_IDENTIFIER ;
UiParameterListOpt: ;
/.
case $rule_number: {
sym(1).Node = 0;
} break;
./
UiParameterListOpt: UiParameterList ;
/.
case $rule_number: {
sym(1).Node = sym(1).UiParameterList->finish ();
} break;
./
UiParameterList: UiPropertyType JsIdentifier ;
/.
case $rule_number: {
AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
node->identifierToken = loc(2);
sym(1).Node = node;
} break;
./
UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
/.
case $rule_number: {
AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval);
node->commaToken = loc(2);
node->identifierToken = loc(4);
sym(1).Node = node;
} break;
./
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
node->parameters = sym(4).UiParameterList;
sym(1).Node = node;
} break;
./
UiObjectMember: T_SIGNAL T_IDENTIFIER ;
/.
case $rule_number: {
......@@ -2843,7 +3013,8 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
}
for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
if (tk == T_AUTOMATIC_SEMICOLON)
if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION)
continue;
int a = t_action(errorState, tk);
......
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
......@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
......@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......@@ -209,6 +209,7 @@ public:
Kind_UiObjectMemberList,
Kind_UiArrayMemberList,
Kind_UiProgram,
Kind_UiParameterList,
Kind_UiPublicMember,
Kind_UiQualifiedId,
Kind_UiScriptBinding,
......@@ -2220,15 +2221,24 @@ public:
QMLJS_DECLARE_AST_NODE(UiImport)
UiImport(NameId *fileName)
: fileName(fileName)
: fileName(fileName), importUri(0), importId(0)
{ kind = K; }
UiImport(UiQualifiedId *uri)
: fileName(0), importUri(uri), importId(0)
{ kind = K; }
virtual void accept0(Visitor *visitor);
// attributes
NameId *fileName;
UiQualifiedId *importUri;
NameId *importId;
SourceLocation importToken;
SourceLocation fileNameToken;
SourceLocation versionToken;
SourceLocation asToken;
SourceLocation importIdToken;
SourceLocation semicolonToken;
};
......@@ -2351,6 +2361,42 @@ public:
SourceLocation rbraceToken;
};
class UiParameterList: public Node
{
public:
QMLJS_DECLARE_AST_NODE(UiParameterList)
UiParameterList(NameId *t, NameId *n):
type (t), name (n), next (this)
{ kind = K; }
UiParameterList(UiParameterList *previous, NameId *t, NameId *n):
type (t), name (n)
{
kind = K;
next = previous->next;
previous->next = this;
}
virtual ~UiParameterList() {}
virtual void accept0(Visitor *) {}
inline UiParameterList *finish ()
{
UiParameterList *front = next;
next = 0;
return front;
}
// attributes
NameId *type;
NameId *name;
UiParameterList *next;
SourceLocation commaToken;
SourceLocation identifierToken;
};
class UiPublicMember: public UiObjectMember
{
public:
......@@ -2358,13 +2404,13 @@ public:
UiPublicMember(NameId *memberType,
NameId *name)
: type(Property), memberType(memberType), name(name), expression(0), isDefaultMember(false)
: type(Property), memberType(memberType), name(name), expression(0), isDefaultMember(false), parameters(0)
{ kind = K; }
UiPublicMember(NameId *memberType,
NameId *name,
ExpressionNode *expression)
: type(Property), memberType(memberType), name(name), expression(expression), isDefaultMember(false)
: type(Property), memberType(memberType), name(name), expression(expression), isDefaultMember(false), parameters(0)
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
......@@ -2388,6 +2434,7 @@ public:
NameId *name;
ExpressionNode *expression;
bool isDefaultMember;
UiParameterList *parameters;
SourceLocation defaultToken;
SourceLocation propertyToken;
SourceLocation typeToken;
......
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
......@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
......@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
......@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......
/**************************************************************************
/****************************************************************************
**
** This file is part of Qt Creator
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
......@@ -22,10 +20,24 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
**************************************************************************/
****************************************************************************/
#include "qmljsengine_p.h"
#include "qmljsnodepool_p.h"
......
/**************************************************************************
/****************************************************************************
**
** This file is part of Qt Creator
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser