virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
virtual const char *ForEachIn() const = 0;
- virtual CYExpression *ForEachIn(CYContext &out) = 0;
+ virtual CYStatement *ForEachIn(CYContext &out, CYExpression *value) = 0;
virtual CYExpression *Replace(CYContext &context) = 0;
};
virtual void ForIn(CYOutput &out, CYFlags flags) const;
virtual const char *ForEachIn() const;
- virtual CYExpression *ForEachIn(CYContext &out);
+ virtual CYStatement *ForEachIn(CYContext &out, CYExpression *value);
virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
virtual void ForIn(CYOutput &out, CYFlags flags) const;
virtual const char *ForEachIn() const;
- virtual CYExpression *ForEachIn(CYContext &out);
+ virtual CYStatement *ForEachIn(CYContext &out, CYExpression *value);
virtual CYExpression *Replace(CYContext &context);
virtual CYAssignment *Assignment(CYContext &context);
return initialiser_ == NULL ? NULL : $ CYAssign(variable, initialiser_);
}
-CYExpression *CYDeclaration::ForEachIn(CYContext &context) {
- return $V(identifier_);
+CYStatement *CYDeclaration::ForEachIn(CYContext &context, CYExpression *value) {
+ return $ CYVar($L1($L(identifier_, value)));
}
CYExpression *CYDeclaration::Replace(CYContext &context) {
return this;
}
-CYExpression *CYExpression::ForEachIn(CYContext &context) {
- return this;
+CYStatement *CYExpression::ForEachIn(CYContext &context, CYExpression *value) {
+ return $E($ CYAssign(this, value));
}
CYNumber *CYFalse::Number(CYContext &context) {
return $ CYLet($L2($L(cys, set_), $L(cyt)), $$->*
$ CYForIn($V(cyt), $V(cys), $ CYBlock($$->*
- $E($ CYAssign(initialiser_->ForEachIn(context), $M($V(cys), $V(cyt))))->*
+ initialiser_->ForEachIn(context, $M($V(cys), $V(cyt)))->*
code_
))
);