summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/parser
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-07-26 23:43:22 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-07-26 23:43:22 (GMT)
commit05c1db3b28067336fcf14cce7909d1f09007998b (patch)
treea617a6eefd4f4ed93dcb896079f51ea76043e18e /src/declarative/qml/parser
parent80476372e6f4dd3e179eeba949e86a336bc8fde3 (diff)
downloadQt-05c1db3b28067336fcf14cce7909d1f09007998b.zip
Qt-05c1db3b28067336fcf14cce7909d1f09007998b.tar.gz
Qt-05c1db3b28067336fcf14cce7909d1f09007998b.tar.bz2
Added formal parameters to the QML signals.
Diffstat (limited to 'src/declarative/qml/parser')
-rw-r--r--src/declarative/qml/parser/qmljs.g52
-rw-r--r--src/declarative/qml/parser/qmljsast.cpp25
-rw-r--r--src/declarative/qml/parser/qmljsast_p.h88
-rw-r--r--src/declarative/qml/parser/qmljsastfwd_p.h3
-rw-r--r--src/declarative/qml/parser/qmljsastvisitor_p.h6
-rw-r--r--src/declarative/qml/parser/qmljsparser.cpp40
-rw-r--r--src/declarative/qml/parser/qmljsparser_p.h3
7 files changed, 216 insertions, 1 deletions
diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g
index ccfe7fd..a1c4ba2 100644
--- a/src/declarative/qml/parser/qmljs.g
+++ b/src/declarative/qml/parser/qmljs.g
@@ -271,6 +271,9 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
+ AST::UiSignature *UiSignature;
+ AST::UiFormalList *UiFormalList;
+ AST::UiFormal *UiFormal;
};
public:
@@ -880,13 +883,62 @@ case $rule_number: {
./
UiFormal: JsIdentifier ;
+/.
+case $rule_number: {
+ AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).UiFormal = node;
+} break;
+./
+
UiFormal: JsIdentifier T_AS JsIdentifier ;
+/.
+case $rule_number: {
+ AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(),
+ sym(1).sval, sym(3).sval);
+ node->identifierToken = loc(1);
+ node->asToken = loc(2);
+ node->aliasToken = loc(3);
+ sym(1).UiFormal = node;
+} break;
+./
UiFormalList: UiFormal ;
+/.
+case $rule_number: {
+ sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
+ sym(1).UiFormal);
+} break;
+./
+
UiFormalList: UiFormalList T_COMMA UiFormal ;
+/.
+case $rule_number: {
+ sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
+ sym(1).UiFormalList, sym(3).UiFormal);
+} break;
+./
UiSignature: T_LPAREN T_RPAREN ;
+/.
+case $rule_number: {
+ AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool());
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).UiSignature = node;
+} break;
+./
+
UiSignature: T_LPAREN UiFormalList T_RPAREN ;
+/.
+case $rule_number: {
+ AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool(),
+ sym(2).UiFormalList->finish());
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).UiSignature = node;
+} break;
+./
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
diff --git a/src/declarative/qml/parser/qmljsast.cpp b/src/declarative/qml/parser/qmljsast.cpp
index 52f19e2..1d7f09e 100644
--- a/src/declarative/qml/parser/qmljsast.cpp
+++ b/src/declarative/qml/parser/qmljsast.cpp
@@ -801,6 +801,31 @@ void UiProgram::accept0(Visitor *visitor)
visitor->endVisit(this);
}
+void UiSignature::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ acceptChild(formals, visitor);
+ }
+ visitor->endVisit(this);
+}
+
+void UiFormalList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiFormalList *it = this; it; it = it->next) {
+ acceptChild(it->formal, visitor);
+ }
+ }
+ visitor->endVisit(this);
+}
+
+void UiFormal::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+ visitor->endVisit(this);
+}
+
void UiPublicMember::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h
index eba9202..9745153 100644
--- a/src/declarative/qml/parser/qmljsast_p.h
+++ b/src/declarative/qml/parser/qmljsast_p.h
@@ -213,7 +213,10 @@ public:
Kind_UiPublicMember,
Kind_UiQualifiedId,
Kind_UiScriptBinding,
- Kind_UiSourceElement
+ Kind_UiSourceElement,
+ Kind_UiFormal,
+ Kind_UiFormalList,
+ Kind_UiSignature
};
inline Node()
@@ -269,6 +272,89 @@ public:
virtual SourceLocation lastSourceLocation() const = 0;
};
+class UiFormal: public Node
+{
+public:
+ QMLJS_DECLARE_AST_NODE(UiFormal)
+
+ UiFormal(NameId *name, NameId *alias = 0)
+ : name(name), alias(alias)
+ { }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *name;
+ NameId *alias;
+ SourceLocation identifierToken;
+ SourceLocation asToken;
+ SourceLocation aliasToken;
+};
+
+class UiFormalList: public Node
+{
+public:
+ QMLJS_DECLARE_AST_NODE(UiFormalList)
+
+ UiFormalList(UiFormal *formal)
+ : formal(formal), next(this) {}
+
+ UiFormalList(UiFormalList *previous, UiFormal *formal)
+ : formal(formal)
+ {
+ next = previous->next;
+ previous->next = this;
+ }
+
+ UiFormalList *finish()
+ {
+ UiFormalList *head = next;
+ next = 0;
+ return head;
+ }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiFormal *formal;
+ UiFormalList *next;
+};
+
+class UiSignature: public Node
+{
+public:
+ QMLJS_DECLARE_AST_NODE(UiSignature)
+
+ UiSignature(UiFormalList *formals = 0)
+ : formals(formals)
+ { }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ SourceLocation lparenToken;
+ UiFormalList *formals;
+ SourceLocation rparenToken;
+};
+
class NestedExpression: public ExpressionNode
{
public:
diff --git a/src/declarative/qml/parser/qmljsastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h
index 339bea4..f79cfc2 100644
--- a/src/declarative/qml/parser/qmljsastfwd_p.h
+++ b/src/declarative/qml/parser/qmljsastfwd_p.h
@@ -176,6 +176,9 @@ class UiObjectMember;
class UiObjectMemberList;
class UiArrayMemberList;
class UiQualifiedId;
+class UiFormalList;
+class UiFormal;
+class UiSignature;
} } // namespace AST
diff --git a/src/declarative/qml/parser/qmljsastvisitor_p.h b/src/declarative/qml/parser/qmljsastvisitor_p.h
index 3677b1a..237640f 100644
--- a/src/declarative/qml/parser/qmljsastvisitor_p.h
+++ b/src/declarative/qml/parser/qmljsastvisitor_p.h
@@ -82,6 +82,9 @@ public:
virtual bool visit(UiObjectMemberList *) { return true; }
virtual bool visit(UiArrayMemberList *) { return true; }
virtual bool visit(UiQualifiedId *) { return true; }
+ virtual bool visit(UiSignature *) { return true; }
+ virtual bool visit(UiFormalList *) { return true; }
+ virtual bool visit(UiFormal *) { return true; }
virtual void endVisit(UiProgram *) {}
virtual void endVisit(UiImportList *) {}
@@ -96,6 +99,9 @@ public:
virtual void endVisit(UiObjectMemberList *) {}
virtual void endVisit(UiArrayMemberList *) {}
virtual void endVisit(UiQualifiedId *) {}
+ virtual void endVisit(UiSignature *) {}
+ virtual void endVisit(UiFormalList *) {}
+ virtual void endVisit(UiFormal *) {}
// QmlJS
virtual bool visit(ThisExpression *) { return true; }
diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp
index 22f3820..9bd6e6f 100644
--- a/src/declarative/qml/parser/qmljsparser.cpp
+++ b/src/declarative/qml/parser/qmljsparser.cpp
@@ -419,6 +419,46 @@ case 47: {
sym(1).Node = node;
} break;
+case 48: {
+ AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).UiFormal = node;
+} break;
+
+case 49: {
+ AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(),
+ sym(1).sval, sym(3).sval);
+ node->identifierToken = loc(1);
+ node->asToken = loc(2);
+ node->aliasToken = loc(3);
+ sym(1).UiFormal = node;
+} break;
+
+case 50: {
+ sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
+ sym(1).UiFormal);
+} break;
+
+case 51: {
+ sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
+ sym(1).UiFormalList, sym(3).UiFormal);
+} break;
+
+case 52: {
+ AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool());
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).UiSignature = node;
+} break;
+
+case 53: {
+ AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool(),
+ sym(2).UiFormalList->finish());
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).UiSignature = node;
+} break;
+
case 55: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
node->type = AST::UiPublicMember::Signal;
diff --git a/src/declarative/qml/parser/qmljsparser_p.h b/src/declarative/qml/parser/qmljsparser_p.h
index be5317b..e352f43 100644
--- a/src/declarative/qml/parser/qmljsparser_p.h
+++ b/src/declarative/qml/parser/qmljsparser_p.h
@@ -120,6 +120,9 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
+ AST::UiSignature *UiSignature;
+ AST::UiFormalList *UiFormalList;
+ AST::UiFormal *UiFormal;
};
public: