[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [qmlweb/development/qmlweb2] /: [Compiler] Add various elements
From: Jan Marker <jan () jangmarker ! de>
Date: 2015-09-30 20:44:35
Message-ID: E1ZhOEt-0000CB-UD () scm ! kde ! org
[Download RAW message or body]
Git commit 187a7ce777aefbb3a90c8ef59176103c6fb01892 by Jan Marker.
Committed on 30/09/2015 at 20:41.
Pushed by jangmarker into branch 'development/qmlweb2'.
[Compiler] Add various elements
* RegExp literals
* some source elements
* comma expression
* function expression
* labelled statement
* with statement
M +54 -2 src/qmljsc/purejavascriptgenerator.cpp
M +9 -0 src/qmljsc/purejavascriptgenerator.h
M +1 -1 tests/auto/data/javascript/expressions.js
M +1 -1 tests/auto/data/javascript/functions.compiled.js
M +7 -1 tests/auto/data/javascript/functions.js
M +1 -1 tests/auto/data/javascript/literals.compiled.js
M +4 -1 tests/auto/data/javascript/literals.js
M +1 -1 tests/auto/data/javascript/objectliterals.compiled.js
M +2 -1 tests/auto/data/javascript/objectliterals.js
M +1 -1 tests/auto/data/javascript/otherstatements.compiled.js
M +4 -1 tests/auto/data/javascript/otherstatements.js
M +40 -0 tests/auto/qmljsc/testpurejavascriptgenerator.cpp
http://commits.kde.org/qmlweb/187a7ce777aefbb3a90c8ef59176103c6fb01892
diff --git a/src/qmljsc/purejavascriptgenerator.cpp \
b/src/qmljsc/purejavascriptgenerator.cpp index 10708c6..811ba84 100644
--- a/src/qmljsc/purejavascriptgenerator.cpp
+++ b/src/qmljsc/purejavascriptgenerator.cpp
@@ -18,6 +18,8 @@
*
*/
+#include <private/qqmljslexer_p.h>
+
#include "purejavascriptgenerator.h"
#include "utils/error.h"
@@ -145,10 +147,36 @@ bool PureJavaScriptGenerator::visit(AST::NullExpression *) {
}
bool PureJavaScriptGenerator::visit(AST::NumericLiteral *numericLiteral) {
- m_outputStack.push(QString::number(numericLiteral->value));
+ m_outputStack<< QString::number(numericLiteral->value);
+ return true;
+}
+
+bool PureJavaScriptGenerator::visit(AST::NumericLiteralPropertyName \
*numericPropertyName) { + m_outputStack << numericPropertyName->asString();
+ return true;
+}
+
+bool PureJavaScriptGenerator::visit(AST::RegExpLiteral *regExpLiteral) {
+ const QString regExp = regExpLiteral->pattern.toString();
+ const QString flags = regExpFlagsString((Lexer::RegExpFlag) \
regExpLiteral->flags); + m_outputStack << '/' + regExp + '/' + flags;
return true;
}
+const QString PureJavaScriptGenerator::regExpFlagsString(const Lexer::RegExpFlag \
&flagsAsEnum) const { + QString flags;
+ if (flagsAsEnum & Lexer::RegExp_Global) {
+ flags += 'g';
+ }
+ if (flagsAsEnum & Lexer::RegExp_IgnoreCase) {
+ flags += 'i';
+ }
+ if (flagsAsEnum & Lexer::RegExp_Multiline) {
+ flags += 'm';
+ }
+ return flags;
+}
+
bool PureJavaScriptGenerator::visit(AST::StringLiteral *stringLiteral) {
m_outputStack << '"' + stringLiteral->value.toString() + '"';
return true;
@@ -284,6 +312,13 @@ void PureJavaScriptGenerator::endVisit(AST::ExpressionStatement \
*) { m_outputStack << m_outputStack.pop() + ';';
}
+void PureJavaScriptGenerator::endVisit(AST::Expression *) {
+ // this is a comma expression a,b
+ const QString secondExpression = m_outputStack.pop();
+ const QString firstExpression = m_outputStack.pop();
+ m_outputStack << firstExpression + ',' + secondExpression;
+}
+
void PureJavaScriptGenerator::endVisit(AST::FieldMemberExpression \
*fieldMemberExpression) { const QString objectExpression = m_outputStack.pop();
const QString memberName = fieldMemberExpression->name.toString();
@@ -317,6 +352,13 @@ void PureJavaScriptGenerator::endVisit(AST::FunctionDeclaration \
*functionDeclara m_outputStack << "function " + name + '(' + parameters + ')' + \
body; }
+void PureJavaScriptGenerator::endVisit(QQmlJS::AST::FunctionExpression \
*functionExpression) { + const QString body = \
(functionExpression->body)?m_outputStack.pop():"{}"; + const QString parameters = \
(functionExpression->formals)?m_outputStack.pop():""; + const QString name = \
functionExpression->name.toString(); + m_outputStack << "function " + name + '(' + \
parameters + ')' + body; +}
+
void PureJavaScriptGenerator::endVisit(AST::IdentifierExpression *) {
}
@@ -332,6 +374,11 @@ void PureJavaScriptGenerator::endVisit(AST::IfStatement \
*ifExpression) { m_outputStack << code;
}
+void PureJavaScriptGenerator::endVisit(AST::LabelledStatement *labelledStatement) {
+ const QString statement = m_outputStack.pop();
+ m_outputStack << labelledStatement->label.toString() + ':' + statement;
+}
+
void PureJavaScriptGenerator::endVisit(AST::LocalForEachStatement *) {
const QString statement = m_outputStack.pop();
const QString objectExpression = m_outputStack.pop();
@@ -481,13 +528,18 @@ void PureJavaScriptGenerator::endVisit(AST::VoidExpression *) {
m_outputStack << "void " + expression;
}
-
void PureJavaScriptGenerator::endVisit(AST::WhileStatement *) {
const QString statement = m_outputStack.pop();
const QString expression = m_outputStack.pop();
m_outputStack << "while(" + expression + ')' + statement;
}
+void PureJavaScriptGenerator::endVisit(AST::WithStatement *) {
+ const QString statement = m_outputStack.pop();
+ const QString expression = m_outputStack.pop();
+ m_outputStack << "with(" + expression + ')' + statement;
+}
+
void PureJavaScriptGenerator::reduceJumpStatement(const char *keyword, QStringRef \
label) { QString labelStatementCode(keyword);
if (label.length() > 0) {
diff --git a/src/qmljsc/purejavascriptgenerator.h \
b/src/qmljsc/purejavascriptgenerator.h index ad4635e..9994b62 100644
--- a/src/qmljsc/purejavascriptgenerator.h
+++ b/src/qmljsc/purejavascriptgenerator.h
@@ -24,6 +24,7 @@
#include <QStack>
#include <private/qqmljsast_p.h>
+#include <private/qqmljslexer_p.h>
class PureJavaScriptGenerator : public QQmlJS::AST::Visitor {
@@ -44,6 +45,8 @@ public:
virtual bool visit(QQmlJS::AST::IdentifierPropertyName *) override;
virtual bool visit(QQmlJS::AST::NullExpression *) override;
virtual bool visit(QQmlJS::AST::NumericLiteral *) override;
+ virtual bool visit(QQmlJS::AST::NumericLiteralPropertyName *) override;
+ virtual bool visit(QQmlJS::AST::RegExpLiteral *) override;
virtual bool visit(QQmlJS::AST::StringLiteral *) override;
virtual bool visit(QQmlJS::AST::ThisExpression *) override;
virtual bool visit(QQmlJS::AST::TrueLiteral *) override;
@@ -63,14 +66,17 @@ public:
virtual void endVisit(QQmlJS::AST::DoWhileStatement *) override;
virtual void endVisit(QQmlJS::AST::ElementList *) override;
virtual void endVisit(QQmlJS::AST::EmptyStatement *) override;
+ virtual void endVisit(QQmlJS::AST::Expression *) override;
virtual void endVisit(QQmlJS::AST::ExpressionStatement *) override;
virtual void endVisit(QQmlJS::AST::FieldMemberExpression *) override;
virtual void endVisit(QQmlJS::AST::ForEachStatement *) override;
virtual void endVisit(QQmlJS::AST::ForStatement *) override;
virtual void endVisit(QQmlJS::AST::FunctionBody *) override;
virtual void endVisit(QQmlJS::AST::FunctionDeclaration *) override;
+ virtual void endVisit(QQmlJS::AST::FunctionExpression *) override;
virtual void endVisit(QQmlJS::AST::IdentifierExpression *) override;
virtual void endVisit(QQmlJS::AST::IfStatement *) override;
+ virtual void endVisit(QQmlJS::AST::LabelledStatement *) override;
virtual void endVisit(QQmlJS::AST::LocalForEachStatement *) override;
virtual void endVisit(QQmlJS::AST::LocalForStatement *) override;
virtual void endVisit(QQmlJS::AST::NewExpression *) override;
@@ -100,6 +106,7 @@ public:
virtual void endVisit(QQmlJS::AST::VariableStatement *) override;
virtual void endVisit(QQmlJS::AST::VoidExpression *) override;
virtual void endVisit(QQmlJS::AST::WhileStatement *) override;
+ virtual void endVisit(QQmlJS::AST::WithStatement *) override;
private:
template<typename ListType> void reduceListStack(ListType* list, const char* \
separator = ""); @@ -108,6 +115,8 @@ private:
QStack<QString> m_outputStack;
friend class TestPureJavaScriptGenerator;
+
+ const QString regExpFlagsString(const QQmlJS::Lexer::RegExpFlag &flagsAsEnum) \
const; };
template<typename ListType> void PureJavaScriptGenerator::reduceListStack(ListType* \
current, const char* separator) {
diff --git a/tests/auto/data/javascript/expressions.js \
b/tests/auto/data/javascript/expressions.js index 3923c92..e37f3f2 100644
--- a/tests/auto/data/javascript/expressions.js
+++ b/tests/auto/data/javascript/expressions.js
@@ -1 +1 @@
-var x;var i;var e=i++;e=++i;e=i--;e=--i;5*(2+3);true?1:2;
\ No newline at end of file
+var x;var i;var e=i++;e=++i;e=i--;e=--i;5*(2+3);true?1:2;a,b,c;
\ No newline at end of file
diff --git a/tests/auto/data/javascript/functions.compiled.js \
b/tests/auto/data/javascript/functions.compiled.js index 19a0abb..6d89508 100644
--- a/tests/auto/data/javascript/functions.compiled.js
+++ b/tests/auto/data/javascript/functions.compiled.js
@@ -1 +1 @@
-function noParameters(){var i=5;}function oneParameter(p1){var i=p1;}function \
multipleParameters(p1,p2){var i=p2;}function noBody(){}return 5;return; \ No newline \
at end of file +function noParameters(){var i=5;}function oneParameter(p1){var \
i=p1;}function multipleParameters(p1,p2){var i=p2;}function noBody(){}return \
5;return;x=function asfd(){};x=function asdf(x){print();};x=function \
asdf(x,x1){print();};x=function asdf(x){print();};x=function (x){print();}; \ No \
newline at end of file
diff --git a/tests/auto/data/javascript/functions.js \
b/tests/auto/data/javascript/functions.js index da92cc3..405c7a6 100644
--- a/tests/auto/data/javascript/functions.js
+++ b/tests/auto/data/javascript/functions.js
@@ -13,4 +13,10 @@ function multipleParameters(p1,p2) {
function noBody() {}
return 5;
-return;
\ No newline at end of file
+return;
+
+x = function asfd() {}
+x = function asdf(x) {print()}
+x = function asdf(x, x1) {print()}
+x = function asdf(x) {print()}
+x = function(x){print()}
\ No newline at end of file
diff --git a/tests/auto/data/javascript/literals.compiled.js \
b/tests/auto/data/javascript/literals.compiled.js index 4a47b75..4d50987 100644
--- a/tests/auto/data/javascript/literals.compiled.js
+++ b/tests/auto/data/javascript/literals.compiled.js
@@ -1 +1 @@
-this;null;identifier;true;false;4.1;"string";
\ No newline at end of file
+this;null;identifier;true;false;4.1;"string";/a/i;/a/gim;/a/;
\ No newline at end of file
diff --git a/tests/auto/data/javascript/literals.js \
b/tests/auto/data/javascript/literals.js index a6a89c0..4b4b4b4 100644
--- a/tests/auto/data/javascript/literals.js
+++ b/tests/auto/data/javascript/literals.js
@@ -4,4 +4,7 @@ identifier;
true;
false;
4.1;
-"string";
\ No newline at end of file
+"string";
+/a/i;
+/a/gim;
+/a/;
\ No newline at end of file
diff --git a/tests/auto/data/javascript/objectliterals.compiled.js \
b/tests/auto/data/javascript/objectliterals.compiled.js index ddcf169..4ca0a3a 100644
--- a/tests/auto/data/javascript/objectliterals.compiled.js
+++ b/tests/auto/data/javascript/objectliterals.compiled.js
@@ -1 +1 @@
-x={property1:"value"};x={property1:"value",property2:"value2"};x={property1:null,get \
property1(){},set property1(x){}}; \ No newline at end of file
+x={property1:"value"};x={property1:"value",property2:"value2"};x={property1:null,get \
property1(){},set property1(x){}};x={1:5}; \ No newline at end of file
diff --git a/tests/auto/data/javascript/objectliterals.js \
b/tests/auto/data/javascript/objectliterals.js index 030ad6a..058414a 100644
--- a/tests/auto/data/javascript/objectliterals.js
+++ b/tests/auto/data/javascript/objectliterals.js
@@ -1,3 +1,4 @@
x = {property1: "value"};
x = {property1: "value", property2: "value2"};
-x = {property1: null, get property1(){}, set property1(x){}};
\ No newline at end of file
+x = {property1: null, get property1(){}, set property1(x){}};
+x = {1: 5};
\ No newline at end of file
diff --git a/tests/auto/data/javascript/otherstatements.compiled.js \
b/tests/auto/data/javascript/otherstatements.compiled.js index b361832..1714c45 \
100644
--- a/tests/auto/data/javascript/otherstatements.compiled.js
+++ b/tests/auto/data/javascript/otherstatements.compiled.js
@@ -1 +1 @@
-;break;break someLabel;continue;continue someLabel;
\ No newline at end of file
+;break;break someLabel;continue;continue someLabel;labelled:return;with(x)y;
\ No newline at end of file
diff --git a/tests/auto/data/javascript/otherstatements.js \
b/tests/auto/data/javascript/otherstatements.js index a046334..3d111fe 100644
--- a/tests/auto/data/javascript/otherstatements.js
+++ b/tests/auto/data/javascript/otherstatements.js
@@ -2,4 +2,7 @@
break;
break someLabel;
continue;
-continue someLabel;
\ No newline at end of file
+continue someLabel;
+labelled: return;
+with (x)
+ y;
\ No newline at end of file
diff --git a/tests/auto/qmljsc/testpurejavascriptgenerator.cpp \
b/tests/auto/qmljsc/testpurejavascriptgenerator.cpp index 4542e21..164b5f4 100644
--- a/tests/auto/qmljsc/testpurejavascriptgenerator.cpp
+++ b/tests/auto/qmljsc/testpurejavascriptgenerator.cpp
@@ -21,6 +21,8 @@
#include <QtTest/QTest>
#include <private/qqmljsast_p.h>
+#include <private/qqmljsgrammar_p.h>
+#include <private/qqmljslexer_p.h>
#include "../../../src/qmljsc/utils/error.h"
#include "../../../src/qmljsc/purejavascriptgenerator.h"
@@ -85,6 +87,7 @@ public:
, m_anotherIdentifierStringRef(&m_anotherIdentifier)
, m_propertyIdentifier("property")
, m_propertyIdentifierStringRef(&m_propertyIdentifier)
+ , m_program(nullptr)
/* Expressions */
, m_thisExpression()
, m_nullExpression()
@@ -93,6 +96,9 @@ public:
, m_falseLiteral()
, m_numericalExpressionPi(3.14)
, m_stringLiteral(m_someStringStringRef)
+ , m_regexpNoFlag(m_someStringStringRef, 0)
+ , m_regexpOneFlag(m_someStringStringRef, Lexer::RegExp_Global)
+ , m_regexpAllFlags(m_someStringStringRef, Lexer::RegExp_Global | \
Lexer::RegExp_IgnoreCase | Lexer::RegExp_Multiline) , m_twoElisions()
, m_elisionsPart2(&m_twoElisions)
, m_arrayElementsExp(nullptr, &m_trueLiteral)
@@ -104,6 +110,7 @@ public:
, m_arrayLiteralWithoutElision(&m_arrayElementsExp)
, m_arrayLiteralOnlyElision(&m_twoElisions)
, m_arrayElementsExpElisionExpPart2(&m_arrayElementsExpElisionExp, \
&m_twoElisions, &m_trueLiteral) + , m_numericPropertyName(3.14)
, m_identifierPropertyName(m_someIdentifierStringRef)
, m_propertyNameAndValue(&m_identifierPropertyName, &m_falseLiteral)
, m_propertyGetter(&m_identifierPropertyName, &m_functionBody)
@@ -138,6 +145,9 @@ public:
, m_typeOfExpression(&m_identifierExpression)
, m_voidExpression(&m_identifierExpression)
, m_conditionalExpression(&m_trueLiteral, &m_numericalExpressionPi, \
&m_numericalExpressionPi) + , m_commaExpression(&m_identifierExpression, \
&m_trueLiteral) + , \
m_functionExpressionParameterBody(m_someIdentifierStringRef, &m_twoParameters, \
&m_functionBody) + , \
m_functionExpressionNoParameterNoBody(m_someIdentifierStringRef, nullptr, nullptr) \
/* Variable Declarations */ , m_constDeclaration1(m_someIdentifierStringRef, \
nullptr) , m_constDeclaration2(m_anotherIdentifierStringRef, nullptr)
@@ -171,6 +181,9 @@ public:
, m_threeSourceElementsList(&m_sourceElement1)
, m_sourceElementsListPart2(&m_threeSourceElementsList, &m_sourceElement2)
, m_sourceElementsListPart3(&m_sourceElementsListPart2, &m_sourceElement3)
+ , m_labelledStatement(m_someLabelStringRef, &m_expressionStatement)
+ , m_withStatement(&m_trueLiteral, &m_block)
+ , m_statementSourceElement(&m_block)
/* Function declaration */
, m_twoParameters(m_someIdentifierStringRef)
, m_parameterListPart2(&m_twoParameters, m_anotherIdentifierStringRef)
@@ -178,6 +191,7 @@ public:
, m_functionDeclarationWithoutParameters(m_someIdentifierStringRef, nullptr, \
&m_functionBody)
, m_functionDeclarationWithParameters(m_someIdentifierStringRef, \
&m_twoParameters , &m_functionBody)
, m_functionDeclarationWithoutBody(m_someIdentifierStringRef, \
&m_twoParameters, nullptr) + , \
m_functionSourceElement(&m_functionDeclarationWithoutBody) /* Switch */
, m_caseClause1(&m_trueLiteral, &m_threeStatementsList)
, m_caseClause2(&m_trueLiteral, &m_threeStatementsList)
@@ -232,6 +246,8 @@ private:
const QString m_propertyIdentifier;
const QStringRef m_propertyIdentifierStringRef;
+ AST::Program m_program;
+
/* Expressions */
AST::ThisExpression m_thisExpression;
AST::NullExpression m_nullExpression;
@@ -240,6 +256,9 @@ private:
AST::FalseLiteral m_falseLiteral;
AST::NumericLiteral m_numericalExpressionPi;
AST::StringLiteral m_stringLiteral;
+ AST::RegExpLiteral m_regexpNoFlag;
+ AST::RegExpLiteral m_regexpOneFlag;
+ AST::RegExpLiteral m_regexpAllFlags;
AST::Elision m_twoElisions;
AST::Elision m_elisionsPart2;
@@ -253,6 +272,7 @@ private:
AST::ArrayLiteral m_arrayLiteralWithoutElision;
AST::ArrayLiteral m_arrayLiteralOnlyElision;
+ AST::NumericLiteralPropertyName m_numericPropertyName;
AST::IdentifierPropertyName m_identifierPropertyName;
AST::PropertyNameAndValue m_propertyNameAndValue;
AST::PropertyGetterSetter m_propertyGetter;
@@ -292,6 +312,9 @@ private:
AST::VoidExpression m_voidExpression;
AST::ConditionalExpression m_conditionalExpression;
+ AST::Expression m_commaExpression;
+ AST::FunctionExpression m_functionExpressionParameterBody;
+ AST::FunctionExpression m_functionExpressionNoParameterNoBody;
/* Variable Declarations */
AST::VariableDeclaration m_constDeclaration1;
@@ -328,6 +351,9 @@ private:
AST::SourceElements m_threeSourceElementsList;
AST::SourceElements m_sourceElementsListPart2;
AST::SourceElements m_sourceElementsListPart3;
+ AST::LabelledStatement m_labelledStatement;
+ AST::WithStatement m_withStatement;
+ AST::StatementSourceElement m_statementSourceElement;
/* Function declarations */
AST::FormalParameterList m_twoParameters;
@@ -336,6 +362,8 @@ private:
AST::FunctionDeclaration m_functionDeclarationWithoutParameters;
AST::FunctionDeclaration m_functionDeclarationWithParameters;
AST::FunctionDeclaration m_functionDeclarationWithoutBody;
+
+ AST::FunctionSourceElement m_functionSourceElement;
/* Switch */
AST::CaseClause m_caseClause1;
@@ -411,10 +439,14 @@ private slots:
TEST_VISIT_DEFAULT_IMPL_(IfStatement \
, m_ifStatementWithoutElse)
TEST_VISIT_PUTS_ON_STACK(NullExpression , AnyCase , "null" \
, m_nullExpression)
TEST_VISIT_PUTS_ON_STACK(NumericLiteral , Pi , "3.14" \
, m_numericalExpressionPi) + TEST_VISIT_PUTS_ON_STACK(NumericLiteralPropertyName, \
AnyCase , "3.14" , m_numericPropertyName)
TEST_VISIT_DEFAULT_IMPL_(PostDecrementExpression \
, m_postDecrementExpression)
TEST_VISIT_DEFAULT_IMPL_(PostIncrementExpression \
, m_postIncrementExpression)
TEST_VISIT_DEFAULT_IMPL_(PreDecrementExpression \
, m_preDecrementExpression)
TEST_VISIT_DEFAULT_IMPL_(PreIncrementExpression \
, m_preIncrementExpression) + TEST_VISIT_PUTS_ON_STACK(RegExpLiteral , \
NoFlags , "/some string/" , m_regexpNoFlag) + \
TEST_VISIT_PUTS_ON_STACK(RegExpLiteral , OneFlag , "/some \
string/g" , m_regexpOneFlag) + TEST_VISIT_PUTS_ON_STACK(RegExpLiteral , \
AllFlags , "/some string/gim", m_regexpAllFlags)
TEST_VISIT_DEFAULT_IMPL_(ReturnStatement \
, m_returnStatementWithoutValue)
TEST_VISIT_DEFAULT_IMPL_(SourceElements \
, m_threeSourceElementsList)
TEST_VISIT_DEFAULT_IMPL_(StatementList \
, m_threeStatementsList) @@ -450,6 +482,7 @@ private slots:
TEST_ENDVISIT_REDUCES(ElementList , ElisionExpression , \
"elisionexpr," , ({"elision", "expr"}) , \
m_arrayElementsElisionExp)
TEST_ENDVISIT_REDUCES(ElementList , ExprElisionExpr , \
"expr,eliexpr," , ({"expr", "eli", "expr"}) , \
m_arrayElementsExpElisionExp)
TEST_ENDVISIT_REDUCES(EmptyStatement , DefaultScenario , ";" \
, ({}) , m_emptyStatement) + \
TEST_ENDVISIT_REDUCES(/*Comma*/Expression , AnyCase , "a,b" \
, ({"a", "b"}) , m_commaExpression)
TEST_ENDVISIT_REDUCES(ExpressionStatement , AnyCase , \
"expression;" , ({"expression"}) , \
m_expressionStatement)
TEST_ENDVISIT_REDUCES(FieldMemberExpression , AnyCase , \
"obj.property" , ({"obj"}) , \
m_fieldMemberExpression)
TEST_ENDVISIT_REDUCES(FormalParameterList , AnyCase , "i" \
, ({"i"}) , m_twoParameters) // does nothing @@ -460,9 +493,13 \
@@ private slots:
TEST_ENDVISIT_REDUCES(FunctionDeclaration , BodyNoParameters , "function \
i(){body}" , ({"{body}"}) , \
m_functionDeclarationWithoutParameters)
TEST_ENDVISIT_REDUCES(FunctionDeclaration , BodyParameters , "function \
i(para){body}", ({"para", "{body}"}) , \
m_functionDeclarationWithParameters)
TEST_ENDVISIT_REDUCES(FunctionDeclaration , WithoutBody , "function \
i(para){}" , ({"para"}) , m_functionDeclarationWithoutBody) + \
TEST_ENDVISIT_REDUCES(FunctionExpression , ParametersBody , "function \
i(para){body}", ({"para", "{body}"}) , m_functionExpressionParameterBody) + \
TEST_ENDVISIT_REDUCES(FunctionExpression , NoParametersNoBody, "function i(){}" \
, ({}) , m_functionExpressionNoParameterNoBody) + \
TEST_ENDVISIT_REDUCES(FunctionSourceElement , AnyCase , "i" \
, ({"i"}) , m_functionSourceElement) // does \
nothing
TEST_ENDVISIT_REDUCES(IdentifierExpression , AnyCase , "abc" \
, ({"abc"}) , m_identifierExpression)
TEST_ENDVISIT_REDUCES(IfStatement , OnlyIf , \
"if(exp)stm;" , ({"exp", "stm;"}) , \
m_ifStatementWithoutElse)
TEST_ENDVISIT_REDUCES(IfStatement , IfElse , \
"if(exp)s;else s;", ({"exp", "s;", "s;"}) , m_ifStatementWithElse) + \
TEST_ENDVISIT_REDUCES(LabelledStatement , AnyCase , "ALabel:stm;" \
, ({"stm;"}) , m_labelledStatement)
TEST_ENDVISIT_REDUCES(LocalForEachStatement , AnyCase , "for(var i \
in o)stm;", ({"i", "o", "stm;"}) , m_localForEachStatement)
TEST_ENDVISIT_REDUCES(LocalForStatement , AllParts , "for(var \
i;c;++)stm;", ({"var i", "c", "++", "stm;"}), \
m_localForStatementAllParts)
TEST_ENDVISIT_REDUCES(LocalForStatement , NoPart , \
"for(;;)stm;" , ({"stm;"}) , m_localForStatementNoPart) @@ \
-477,6 +514,7 @@ private slots:
TEST_ENDVISIT_REDUCES(PostIncrementExpression , AnyCase , "2.7++" \
, ({"2.7"}) , m_postIncrementExpression)
TEST_ENDVISIT_REDUCES(PreDecrementExpression , AnyCase , "--2.7" \
, ({"2.7"}) , m_preDecrementExpression)
TEST_ENDVISIT_REDUCES(PreIncrementExpression , AnyCase , "++2.7" \
, ({"2.7"}) , m_preIncrementExpression) + \
TEST_ENDVISIT_REDUCES(Program , AnyCase , "i" \
, ({"i"}) , m_program) // does nothing
TEST_ENDVISIT_REDUCES(PropertyAssignmentList , TwoProperties , \
"prop1,prop2" , ({"prop1", "prop2"}) , m_twoProperties)
TEST_ENDVISIT_REDUCES(PropertyGetterSetter , Getter , "get \
i(){body}" , ({"i", "{body}"}) , m_propertyGetter)
TEST_ENDVISIT_REDUCES(PropertyGetterSetter , GetterEmptyBody , "get i(){}" \
, ({"i"}) , m_propertyGetterEmptyBody) @@ -487,6 +525,7 @@ \
private slots:
TEST_ENDVISIT_REDUCES(ReturnStatement , WithReturnValue , "return \
true;" , ({"true"}) , \
m_returnStatementWithValue)
TEST_ENDVISIT_REDUCES(SourceElements , ThreeSrcElements , \
"sEl1sEl2sEl3" , ({"sEl1", "sEl2", "sEl3"}) , \
m_threeSourceElementsList)
TEST_ENDVISIT_REDUCES(SourceElements , ThreeStatements , "st1st2st3" \
, ({"st1", "st2", "st3"}) , m_threeStatementsList) + \
TEST_ENDVISIT_REDUCES(StatementSourceElement , AnyCase , "i" \
, ({"i"}) , m_statementSourceElement) // does \
nothing
TEST_ENDVISIT_REDUCES(StringLiteral , AnyCase , "another \
string" , ({"another string"}) , m_stringLiteral)
TEST_ENDVISIT_REDUCES(SwitchStatement , AnyCase , \
"switch(e){blk}" , ({"e", "{blk}"}) , m_switchStatement)
TEST_ENDVISIT_REDUCES(TildeExpression , AnyCase , "~5" \
, ({"5"}) , m_tildeExpression) @@ -501,6 +540,7 @@ private \
slots:
TEST_ENDVISIT_REDUCES(VariableStatement , AnyCase , "x;" \
, ({"x"}) , m_variableStatement)
TEST_ENDVISIT_REDUCES(VoidExpression , AnyCase , "void v" \
, ({"v"}) , m_voidExpression)
TEST_ENDVISIT_REDUCES(WhileStatement , AnyCase , \
"while(e)stm" , ({"e", "stm"}) , m_whileStatement) + \
TEST_ENDVISIT_REDUCES(WithStatement , AnyCase , "with(e)stm" \
, ({"e", "stm"}) , m_withStatement)
TEST_VISIT_BINARYOP_PUTS_ON_STACK(Assign, "=")
TEST_VISIT_BINARYOP_PUTS_ON_STACK(InplaceAdd, "+=")
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic