From kde-commits Wed Sep 30 20:44:35 2015 From: Jan Marker Date: Wed, 30 Sep 2015 20:44:35 +0000 To: kde-commits Subject: [qmlweb/development/qmlweb2] /: [Compiler] Add various elements Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=144364588921995 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/purejavasc= riptgenerator.cpp index 10708c6..811ba84 100644 --- a/src/qmljsc/purejavascriptgenerator.cpp +++ b/src/qmljsc/purejavascriptgenerator.cpp @@ -18,6 +18,8 @@ * */ = +#include + #include "purejavascriptgenerator.h" #include "utils/error.h" = @@ -145,10 +147,36 @@ bool PureJavaScriptGenerator::visit(AST::NullExpressi= on *) { } = 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 *numer= icPropertyName) { + m_outputStack << numericPropertyName->asString(); + return true; +} + +bool PureJavaScriptGenerator::visit(AST::RegExpLiteral *regExpLiteral) { + const QString regExp =3D regExpLiteral->pattern.toString(); + const QString flags =3D regExpFlagsString((Lexer::RegExpFlag) regExpLi= teral->flags); + m_outputStack << '/' + regExp + '/' + flags; return true; } = +const QString PureJavaScriptGenerator::regExpFlagsString(const Lexer::RegE= xpFlag &flagsAsEnum) const { + QString flags; + if (flagsAsEnum & Lexer::RegExp_Global) { + flags +=3D 'g'; + } + if (flagsAsEnum & Lexer::RegExp_IgnoreCase) { + flags +=3D 'i'; + } + if (flagsAsEnum & Lexer::RegExp_Multiline) { + flags +=3D 'm'; + } + return flags; +} + bool PureJavaScriptGenerator::visit(AST::StringLiteral *stringLiteral) { m_outputStack << '"' + stringLiteral->value.toString() + '"'; return true; @@ -284,6 +312,13 @@ void PureJavaScriptGenerator::endVisit(AST::Expression= Statement *) { m_outputStack << m_outputStack.pop() + ';'; } = +void PureJavaScriptGenerator::endVisit(AST::Expression *) { + // this is a comma expression a,b + const QString secondExpression =3D m_outputStack.pop(); + const QString firstExpression =3D m_outputStack.pop(); + m_outputStack << firstExpression + ',' + secondExpression; +} + void PureJavaScriptGenerator::endVisit(AST::FieldMemberExpression *fieldMe= mberExpression) { const QString objectExpression =3D m_outputStack.pop(); const QString memberName =3D fieldMemberExpression->name.toString(); @@ -317,6 +352,13 @@ void PureJavaScriptGenerator::endVisit(AST::FunctionDe= claration *functionDeclara m_outputStack << "function " + name + '(' + parameters + ')' + body; } = +void PureJavaScriptGenerator::endVisit(QQmlJS::AST::FunctionExpression *fu= nctionExpression) { + const QString body =3D (functionExpression->body)?m_outputStack.pop():= "{}"; + const QString parameters =3D (functionExpression->formals)?m_outputSta= ck.pop():""; + const QString name =3D functionExpression->name.toString(); + m_outputStack << "function " + name + '(' + parameters + ')' + body; +} + void PureJavaScriptGenerator::endVisit(AST::IdentifierExpression *) { } = @@ -332,6 +374,11 @@ void PureJavaScriptGenerator::endVisit(AST::IfStatemen= t *ifExpression) { m_outputStack << code; } = +void PureJavaScriptGenerator::endVisit(AST::LabelledStatement *labelledSta= tement) { + const QString statement =3D m_outputStack.pop(); + m_outputStack << labelledStatement->label.toString() + ':' + statement; +} + void PureJavaScriptGenerator::endVisit(AST::LocalForEachStatement *) { const QString statement =3D m_outputStack.pop(); const QString objectExpression =3D m_outputStack.pop(); @@ -481,13 +528,18 @@ void PureJavaScriptGenerator::endVisit(AST::VoidExpre= ssion *) { m_outputStack << "void " + expression; } = - void PureJavaScriptGenerator::endVisit(AST::WhileStatement *) { const QString statement =3D m_outputStack.pop(); const QString expression =3D m_outputStack.pop(); m_outputStack << "while(" + expression + ')' + statement; } = +void PureJavaScriptGenerator::endVisit(AST::WithStatement *) { + const QString statement =3D m_outputStack.pop(); + const QString expression =3D m_outputStack.pop(); + m_outputStack << "with(" + expression + ')' + statement; +} + void PureJavaScriptGenerator::reduceJumpStatement(const char *keyword, QSt= ringRef label) { QString labelStatementCode(keyword); if (label.length() > 0) { diff --git a/src/qmljsc/purejavascriptgenerator.h b/src/qmljsc/purejavascri= ptgenerator.h index ad4635e..9994b62 100644 --- a/src/qmljsc/purejavascriptgenerator.h +++ b/src/qmljsc/purejavascriptgenerator.h @@ -24,6 +24,7 @@ #include = #include +#include = 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 void reduceListStack(ListType* list, const= char* separator =3D ""); @@ -108,6 +115,8 @@ private: QStack m_outputStack; = friend class TestPureJavaScriptGenerator; + + const QString regExpFlagsString(const QQmlJS::Lexer::RegExpFlag &flags= AsEnum) const; }; = template void PureJavaScriptGenerator::reduceListStack(= ListType* current, const char* separator) { diff --git a/tests/auto/data/javascript/expressions.js b/tests/auto/data/ja= vascript/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=3Di++;e=3D++i;e=3Di--;e=3D--i;5*(2+3);true?1:2; \ No newline at end of file +var x;var i;var e=3Di++;e=3D++i;e=3Di--;e=3D--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=3D5;}function oneParameter(p1){var i=3Dp1;}f= unction multipleParameters(p1,p2){var i=3Dp2;}function noBody(){}return 5;r= eturn; \ No newline at end of file +function noParameters(){var i=3D5;}function oneParameter(p1){var i=3Dp1;}f= unction multipleParameters(p1,p2){var i=3Dp2;}function noBody(){}return 5;r= eturn;x=3Dfunction asfd(){};x=3Dfunction asdf(x){print();};x=3Dfunction asd= f(x,x1){print();};x=3Dfunction asdf(x){print();};x=3Dfunction (x){print();}; \ No newline at end of file diff --git a/tests/auto/data/javascript/functions.js b/tests/auto/data/java= script/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 =3D function asfd() {} +x =3D function asdf(x) {print()} +x =3D function asdf(x, x1) {print()} +x =3D function asdf(x) {print()} +x =3D function(x){print()} \ No newline at end of file diff --git a/tests/auto/data/javascript/literals.compiled.js b/tests/auto/d= ata/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/javas= cript/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=3D{property1:"value"};x=3D{property1:"value",property2:"value2"};x=3D{pr= operty1:null,get property1(){},set property1(x){}}; \ No newline at end of file +x=3D{property1:"value"};x=3D{property1:"value",property2:"value2"};x=3D{pr= operty1:null,get property1(){},set property1(x){}};x=3D{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 =3D {property1: "value"}; x =3D {property1: "value", property2: "value2"}; -x =3D {property1: null, get property1(){}, set property1(x){}}; \ No newline at end of file +x =3D {property1: null, get property1(){}, set property1(x){}}; +x =3D {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/dat= a/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 = #include +#include +#include = #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 | L= exer::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_falseLitera= l) , 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_sourceE= lement2) , m_sourceElementsListPart3(&m_sourceElementsListPart2, &m_sourceE= lement3) + , 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_anotherIdentifierString= Ref) @@ -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_t= woParameters, 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 , "e= lisionexpr," , ({"elision", "expr"}) , m_arrayElementsElisionExp) TEST_ENDVISIT_REDUCES(ElementList , ExprElisionExpr , "e= xpr,eliexpr," , ({"expr", "eli", "expr"}) , m_arrayElementsExpElisionE= xp) TEST_ENDVISIT_REDUCES(EmptyStatement , DefaultScenario , ";= " , ({}) , m_emptyStatement) + TEST_ENDVISIT_REDUCES(/*Comma*/Expression , AnyCase , "a= ,b" , ({"a", "b"}) , m_commaExpression) TEST_ENDVISIT_REDUCES(ExpressionStatement , AnyCase , "e= xpression;" , ({"expression"}) , m_expressionStatement) TEST_ENDVISIT_REDUCES(FieldMemberExpression , AnyCase , "o= bj.property" , ({"obj"}) , m_fieldMemberExpression) TEST_ENDVISIT_REDUCES(FormalParameterList , AnyCase , "i= " , ({"i"}) , m_twoParameters) // does n= othing @@ -460,9 +493,13 @@ private slots: TEST_ENDVISIT_REDUCES(FunctionDeclaration , BodyNoParameters , "f= unction i(){body}" , ({"{body}"}) , m_functionDeclarationWitho= utParameters) TEST_ENDVISIT_REDUCES(FunctionDeclaration , BodyParameters , "f= unction i(para){body}", ({"para", "{body}"}) , m_functionDeclarationWithP= arameters) TEST_ENDVISIT_REDUCES(FunctionDeclaration , WithoutBody , "f= unction i(para){}" , ({"para"}) , m_functionDeclarationWitho= utBody) + TEST_ENDVISIT_REDUCES(FunctionExpression , ParametersBody , "f= unction i(para){body}", ({"para", "{body}"}) , m_functionExpressionPara= meterBody) + TEST_ENDVISIT_REDUCES(FunctionExpression , NoParametersNoBody, "f= unction i(){}" , ({}) , m_functionExpressionNoPara= meterNoBody) + TEST_ENDVISIT_REDUCES(FunctionSourceElement , AnyCase , "i= " , ({"i"}) , m_functionSourceElement) /= / does nothing TEST_ENDVISIT_REDUCES(IdentifierExpression , AnyCase , "a= bc" , ({"abc"}) , m_identifierExpression) TEST_ENDVISIT_REDUCES(IfStatement , OnlyIf , "i= f(exp)stm;" , ({"exp", "stm;"}) , m_ifStatementWithoutElse) TEST_ENDVISIT_REDUCES(IfStatement , IfElse , "i= f(exp)s;else s;", ({"exp", "s;", "s;"}) , m_ifStatementWithElse) + TEST_ENDVISIT_REDUCES(LabelledStatement , AnyCase , "A= Label:stm;" , ({"stm;"}) , m_labelledStatement) TEST_ENDVISIT_REDUCES(LocalForEachStatement , AnyCase , "f= or(var i in o)stm;", ({"i", "o", "stm;"}) , m_localForEachStatement) TEST_ENDVISIT_REDUCES(LocalForStatement , AllParts , "f= or(var i;c;++)stm;", ({"var i", "c", "++", "stm;"}), m_localForStatementAll= Parts) TEST_ENDVISIT_REDUCES(LocalForStatement , NoPart , "f= or(;;)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 , "p= rop1,prop2" , ({"prop1", "prop2"}) , m_twoProperties) TEST_ENDVISIT_REDUCES(PropertyGetterSetter , Getter , "g= et i(){body}" , ({"i", "{body}"}) , m_propertyGetter) TEST_ENDVISIT_REDUCES(PropertyGetterSetter , GetterEmptyBody , "g= et i(){}" , ({"i"}) , m_propertyGetterEmptyBody) @@ -487,6 +525,7 @@ private slots: TEST_ENDVISIT_REDUCES(ReturnStatement , WithReturnValue , "r= eturn true;" , ({"true"}) , m_returnStatementWithValue) TEST_ENDVISIT_REDUCES(SourceElements , ThreeSrcElements , "s= El1sEl2sEl3" , ({"sEl1", "sEl2", "sEl3"}) , m_threeSourceElementsList) TEST_ENDVISIT_REDUCES(SourceElements , ThreeStatements , "s= t1st2st3" , ({"st1", "st2", "st3"}) , m_threeStatementsList) + TEST_ENDVISIT_REDUCES(StatementSourceElement , AnyCase , "i= " , ({"i"}) , m_statementSourceElement) = // does nothing TEST_ENDVISIT_REDUCES(StringLiteral , AnyCase , "a= nother string" , ({"another string"}) , m_stringLiteral) TEST_ENDVISIT_REDUCES(SwitchStatement , AnyCase , "s= witch(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 , "v= oid v" , ({"v"}) , m_voidExpression) TEST_ENDVISIT_REDUCES(WhileStatement , AnyCase , "w= hile(e)stm" , ({"e", "stm"}) , m_whileStatement) + TEST_ENDVISIT_REDUCES(WithStatement , AnyCase , "w= ith(e)stm" , ({"e", "stm"}) , m_withStatement) = TEST_VISIT_BINARYOP_PUTS_ON_STACK(Assign, "=3D") TEST_VISIT_BINARYOP_PUTS_ON_STACK(InplaceAdd, "+=3D")