};
struct CYExpression;
+struct CYAssignment;
enum CYNeeded {
CYNever = -1,
virtual CYStatement *ForEachIn(CYContext &out, CYExpression *value) = 0;
virtual CYExpression *Replace(CYContext &context) = 0;
+ virtual CYAssignment *Assignment(CYContext &context) = 0;
};
struct CYNumber;
virtual void ClassName(CYOutput &out, bool object) const;
virtual CYExpression *Replace(CYContext &context) = 0;
+ virtual CYAssignment *Assignment(CYContext &context);
virtual CYExpression *Primitive(CYContext &context) {
return this;
return $E($ CYAssign(this, value));
}
+CYAssignment *CYExpression::Assignment(CYContext &context) {
+ return NULL;
+}
+
CYNumber *CYFalse::Number(CYContext &context) {
return $D(0);
}
}
CYStatement *CYForIn::Replace(CYContext &context) {
- // XXX: this actually might need a prefix statement
+ CYAssignment *assignment(initialiser_->Assignment(context));
+
context.Replace(initialiser_);
context.Replace(set_);
context.Replace(code_);
- return this;
+
+ if (assignment == NULL)
+ return this;
+
+ return $ CYBlock($$->*
+ $E(assignment)->*
+ this
+ );
}
CYFunctionParameter *CYForInComprehension::Parameter(CYContext &context) const {