From: Jay Freeman (saurik) Date: Thu, 7 Jun 2012 04:06:39 +0000 (-0700) Subject: Rename CYForEachIn to CYForOf to better match ECMA6. X-Git-Tag: v0.9.456~11 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/d5618df7c804163dceb3eb48e5406aeb9de79c96?hp=0d56ef32c43d7df2033a687afae4c5b2b13e68c1 Rename CYForEachIn to CYForOf to better match ECMA6. --- diff --git a/Cycript.yy.in b/Cycript.yy.in index 9943a9d..410730a 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -358,7 +358,6 @@ int cylex(YYSTYPE *, cy::location *, void *); %type Declaration_ %type Declaration %type DefaultClause -%type DoWhileStatement %type Element %type ElementOpt %type ElementList @@ -372,9 +371,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %type ExpressionStatement %type FinallyOpt %type ForComprehension -%type ForStatement %type ForStatementInitialiser -%type ForInStatement %type ForInStatementInitialiser %type FormalParameter %type FormalParameterList_ @@ -441,7 +438,6 @@ int cylex(YYSTYPE *, cy::location *, void *); %type VariableDeclarationList_ %type VariableDeclarationList %type VariableStatement -%type WhileStatement %type WithStatement @begin ObjectiveC @@ -1098,26 +1094,18 @@ IfStatement ; /* }}} */ -/* 12.6 Iteration Statements {{{ */ -IterationStatement - : DoWhileStatement { $$ = $1; } - | WhileStatement { $$ = $1; } - | ForStatement { $$ = $1; } - | ForInStatement { $$ = $1; } - ; -/* }}} */ /* 12.6.1 The do-while Statement {{{ */ -DoWhileStatement +IterationStatement : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); } ; /* }}} */ /* 12.6.2 The while Statement {{{ */ -WhileStatement +IterationStatement : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); } ; /* }}} */ /* 12.6.3 The for Statement {{{ */ -ForStatement +IterationStatement : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); } ; @@ -1127,9 +1115,9 @@ ForStatementInitialiser ; /* }}} */ /* 12.6.4 The for-in and for-of Statements {{{ */ -ForInStatement +IterationStatement : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); } - | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForEachIn($4, $7, $9); } + | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); } ; ForInStatementInitialiser @@ -1665,7 +1653,7 @@ IfComprehension ForComprehension : "for" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForInComprehension($4, $7); } - | "for" "each" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForEachInComprehension($5, $8); } + | "for" "each" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); } ; ComprehensionList @@ -1683,8 +1671,8 @@ PrimaryExpression ; /* }}} */ /* JavaScript 1.7: for each {{{ */ -ForInStatement - : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForEachIn($5, $8, $10); } +IterationStatement + : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); } ; /* }}} */ /* JavaScript 1.7: let Statements {{{ */ diff --git a/Output.cpp b/Output.cpp index 752d8a9..53d5bfe 100644 --- a/Output.cpp +++ b/Output.cpp @@ -356,14 +356,14 @@ void CYFor::Output(CYOutput &out, CYFlags flags) const { code_->Single(out, CYRight(flags)); } -void CYForEachIn::Output(CYOutput &out, CYFlags flags) const { +void CYForOf::Output(CYOutput &out, CYFlags flags) const { out << "for" << ' ' << "each" << ' ' << '('; initialiser_->ForIn(out, CYNoIn); out << "in" << *set_ << ')'; code_->Single(out, CYRight(flags)); } -void CYForEachInComprehension::Output(CYOutput &out) const { +void CYForOfComprehension::Output(CYOutput &out) const { out << "for" << ' ' << "each" << ' ' << '(' << *name_ << ' ' << "in" << ' ' << *set_ << ')' << next_; } diff --git a/Parser.hpp b/Parser.hpp index 9364826..47a60c0 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -680,13 +680,13 @@ struct CYForInComprehension : virtual void Output(CYOutput &out) const; }; -struct CYForEachInComprehension : +struct CYForOfComprehension : CYComprehension { CYIdentifier *name_; CYExpression *set_; - CYForEachInComprehension(CYIdentifier *name, CYExpression *set) : + CYForOfComprehension(CYIdentifier *name, CYExpression *set) : name_(name), set_(set) { @@ -1268,14 +1268,14 @@ struct CYForIn : virtual void Output(CYOutput &out, CYFlags flags) const; }; -struct CYForEachIn : +struct CYForOf : CYStatement { CYForInInitialiser *initialiser_; CYExpression *set_; CYStatement *code_; - CYForEachIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) : + CYForOf(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) : initialiser_(initialiser), set_(set), code_(code) diff --git a/Replace.cpp b/Replace.cpp index d4037f8..9040f1a 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -360,7 +360,7 @@ CYStatement *CYForInComprehension::Replace(CYContext &context, CYStatement *stat return $ CYForIn($V(name_), set_, CYComprehension::Replace(context, statement)); } -CYStatement *CYForEachIn::Replace(CYContext &context) { +CYStatement *CYForOf::Replace(CYContext &context) { if (CYAssignment *assignment = initialiser_->Assignment(context)) return $ CYBlock($$->* $E(assignment)->* @@ -377,11 +377,11 @@ CYStatement *CYForEachIn::Replace(CYContext &context) { ); } -CYFunctionParameter *CYForEachInComprehension::Parameter(CYContext &context) const { +CYFunctionParameter *CYForOfComprehension::Parameter(CYContext &context) const { return $ CYFunctionParameter($ CYDeclaration(name_)); } -CYStatement *CYForEachInComprehension::Replace(CYContext &context, CYStatement *statement) const { +CYStatement *CYForOfComprehension::Replace(CYContext &context, CYStatement *statement) const { CYIdentifier *cys($I("cys")); return $E($C0($F(NULL, $P1($L("$cys")), $$->*