out << "typedef" << ' ' << *typed_;
}
-void CYLetStatement::Output(CYOutput &out, CYFlags flags) const {
- out << "let" << ' ' << '(' << *declarations_ << ')';
- code_->Single(out, CYRight(flags), CYCompactShort);
+void CYLet::Output(CYOutput &out, CYFlags flags) const {
+ out << "let" << ' ';
+ declarations_->Output(out, flags); // XXX: flags
+ out << ';';
}
void CYModule::Output(CYOutput &out) const {
void CYVar::Output(CYOutput &out, CYFlags flags) const {
out << "var" << ' ';
- declarations_->Output(out, flags);
+ declarations_->Output(out, flags); // XXX: flags
out << ';';
}
%type <statement_> LabelledItem
%type <statement_> LabelledStatement
%type <expression_> LeftHandSideExpression
-%type <statement_> LetStatement
%type <declaration_> LexicalBinding
%type <statement_> LexicalDeclaration
%type <literal_> Literal
/* }}} */
/* 13.3 Let and Const Declarations {{{ */
LexicalDeclaration
- : LetOrConst BindingList Terminator { $$ = CYNew CYVar($2); }
+ : LetOrConst BindingList Terminator { $$ = CYNew CYLet($2); }
;
LetOrConst
: "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
;
/* }}} */
-/* JavaScript FTL: let Statements {{{ */
-LetStatement
- : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
- ;
-
-Statement__
- : LetStatement
- ;
-/* }}} */
/* JavaScript FTW: Array Comprehensions {{{ */
PrimaryExpression
this
);
- CYIdentifier *cys($I("$cys")), *cyt($I("$cyt"));
+ CYIdentifier *cys(context.Unique()), *cyt(context.Unique());
- return $ CYLetStatement($L2($ CYDeclaration(cys, set_), $ CYDeclaration(cyt)), $$->*
- $ CYForIn($V(cyt), $V(cys), $ CYBlock($$->*
- initialiser_->ForEachIn(context, $M($V(cys), $V(cyt)))->*
- code_
- ))
- );
+ return $ CYBlock($$
+ ->* $ CYLet($L2($L(cys, set_), $L(cyt)))
+ ->* $ CYForIn($V(cyt), $V(cys), $ CYBlock($$
+ ->* initialiser_->ForEachIn(context, $M($V(cys), $V(cyt)))
+ ->* code_
+ )));
}
CYFunctionParameter *CYForOfComprehension::Parameter(CYContext &context) const {
return $N2($V("Functor"), $ CYFunctionExpression(NULL, parameters_->Parameters(context), code_), parameters_->TypeSignature(context, typed_->Replace(context)));
}
-CYStatement *CYLetStatement::Replace(CYContext &context) {
- return $E($ CYCall(CYNonLocalize(context, $ CYFunctionExpression(NULL, declarations_->Parameter(context), code_)), declarations_->Argument(context)));
+CYStatement *CYLet::Replace(CYContext &context) {
+ declarations_->Replace(context);
+ if (CYExpression *expression = declarations_->Expression(context))
+ return $E(expression);
+ return $ CYEmpty();
}
CYFunctionExpression *CYMethod::Constructor() {
virtual void Output(CYOutput &out, CYFlags flags) const;
};
-struct CYLetStatement :
+struct CYLet :
CYStatement
{
CYDeclarations *declarations_;
- CYStatement *code_;
- CYLetStatement(CYDeclarations *declarations, CYStatement *code) :
- declarations_(declarations),
- code_(code)
+ CYLet(CYDeclarations *declarations) :
+ declarations_(declarations)
{
}
- CYCompact(Long)
+ CYCompact(None)
virtual CYStatement *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;