**/
/* }}} */
-#include "Parser.hpp"
-#include "Replace.hpp"
-
#include <iomanip>
+#include "Replace.hpp"
+#include "Syntax.hpp"
+
CYFunctionExpression *CYNonLocalize(CYContext &context, CYFunctionExpression *function) {
function->nonlocal_ = context.nextlocal_;
return function;
}
CYExpression *CYArray::Replace(CYContext &context) {
- elements_->Replace(context);
+ if (elements_ != NULL)
+ elements_->Replace(context);
return this;
}
next_->Replace(context);
}
-CYStatement *CYComment::Replace(CYContext &context) {
- return this;
-}
-
CYExpression *CYCompound::Replace(CYContext &context) {
context.Replace(expression_);
context.Replace(next_);
return this;
}
-void CYElement::Replace(CYContext &context) { $T()
+void CYElementSpread::Replace(CYContext &context) {
context.Replace(value_);
- next_->Replace(context);
+}
+
+void CYElementValue::Replace(CYContext &context) {
+ context.Replace(value_);
+ if (next_ != NULL)
+ next_->Replace(context);
}
CYStatement *CYEmpty::Replace(CYContext &context) {
}
CYFunctionParameter *CYForInComprehension::Parameter(CYContext &context) const {
- return $ CYFunctionParameter($ CYDeclaration(name_));
+ return $ CYFunctionParameter(declaration_);
}
CYStatement *CYForInComprehension::Replace(CYContext &context, CYStatement *statement) const {
- return $ CYForIn($V(name_), set_, CYComprehension::Replace(context, statement));
+ return $ CYForIn(declaration_->Variable(context), set_, CYComprehension::Replace(context, statement));
}
CYStatement *CYForOf::Replace(CYContext &context) {
}
CYFunctionParameter *CYForOfComprehension::Parameter(CYContext &context) const {
- return $ CYFunctionParameter($ CYDeclaration(name_));
+ return $ CYFunctionParameter(declaration_);
}
CYStatement *CYForOfComprehension::Replace(CYContext &context, CYStatement *statement) const {
return $E($C0($F(NULL, $P1($L("$cys")), $$->*
$E($ CYAssign($V(cys), set_))->*
- $ CYForIn($V(name_), $V(cys), $ CYBlock($$->*
- $E($ CYAssign($V(name_), $M($V(cys), $V(name_))))->*
+ $ CYForIn(declaration_->Variable(context), $V(cys), $ CYBlock($$->*
+ $E($ CYAssign(declaration_->Variable(context), $M($V(cys), declaration_->Variable(context))))->*
CYComprehension::Replace(context, statement)
))
)));
return call_->AddArgument(context, proc_->Replace(context));
}
+CYExpression *CYRubyBlock::AddArgument(CYContext &context, CYExpression *value) {
+ return Replace(context)->AddArgument(context, value);
+}
+
CYExpression *CYRubyProc::Replace(CYContext &context) {
CYFunctionExpression *function($ CYFunctionExpression(NULL, parameters_, code_));
function = CYNonLocalize(context, function);
}
}
+CYElementValue *CYSpan::Replace(CYContext &context) { $T(NULL)
+ return $ CYElementValue(expression_, $ CYElementValue(string_, next_->Replace(context)));
+}
+
CYStatement *CYStatement::Return() {
return this;
}
return this;
}
+CYExpression *CYTemplate::Replace(CYContext &context) {
+ return $C2($M($M($M($V("String"), $S("prototype")), $S("concat")), $S("apply")), $S(""), $ CYArray($ CYElementValue(string_, spans_->Replace(context))));
+}
+
CYExpression *CYThis::Replace(CYContext &context) {
if (context.this_ != NULL)
return $V(context.this_->Identifier(context));