+CYTarget *CYClassExpression::Replace(CYContext &context) {
+ CYBuilder builder;
+
+ CYIdentifier *super(context.Unique());
+
+ CYIdentifier *old(context.super_);
+ context.super_ = super;
+
+ CYIdentifier *constructor(context.Unique());
+ CYForEach (member, tail_->static_)
+ member->Replace(context, builder, $V(constructor), true);
+
+ CYIdentifier *prototype(context.Unique());
+ CYForEach (member, tail_->instance_)
+ member->Replace(context, builder, $V(prototype), true);
+
+ if (tail_->constructor_ == NULL)
+ tail_->constructor_ = $ CYFunctionExpression(NULL, NULL, NULL);
+ tail_->constructor_->name_ = name_;
+ tail_->constructor_ = CYSuperize(context, tail_->constructor_);
+
+ context.super_ = old;
+
+ return $C1($ CYFunctionExpression(NULL, $P($B(super)), $$
+ ->* $ CYVar($B1($B(constructor, tail_->constructor_)))
+ ->* $ CYVar($B1($B(prototype, $ CYFunctionExpression(NULL, NULL, NULL))))
+ ->* $E($ CYAssign($M($V(prototype), $S("prototype")), $M($V(super), $S("prototype"))))
+ ->* $E($ CYAssign($V(prototype), $N($V(prototype))))
+ ->* CYDefineProperty($V(prototype), $S("constructor"), false, false, $ CYPropertyValue($S("value"), $V(constructor)))
+ ->* $ CYVar(builder.bindings_)
+ ->* builder.statements_
+ ->* CYDefineProperty($V(constructor), $S("prototype"), false, false, $ CYPropertyValue($S("value"), $V(prototype)))
+ ->* $ CYReturn($V(constructor))
+ ), tail_->extends_ ?: $V($I("Object")));