+CYProperty *CYProperty::ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update) {
+ update |= name_->Computed();
+ if (update)
+ Replace(context, builder, self, false);
+ if (next_ != NULL)
+ next_ = next_->ReplaceAll(context, builder, self, update);
+ return update ? next_ : this;
+}
+
+void CYProperty::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, bool protect) {
+ CYExpression *name(name_->PropertyName(context));
+ if (name_->Computed()) {
+ CYIdentifier *unique(context.Unique());
+ builder.declarations_->*$L1($L(unique, name));
+ name = $V(unique);
+ }
+
+ Replace(context, builder, self, name, protect);
+}
+
+void CYPropertyGetter::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) {
+ CYIdentifier *unique(context.Unique());
+ builder.declarations_
+ ->* $L1($L(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_))));
+ builder.statements_
+ ->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("get"), $V(unique)));
+}
+
+CYFunctionExpression *CYPropertyMethod::Constructor() {
+ return name_->Constructor() ? $ CYFunctionExpression(NULL, parameters_, code_) : NULL;
+}
+
+void CYPropertyMethod::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) {
+ CYIdentifier *unique(context.Unique());
+ builder.declarations_
+ ->* $L1($L(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_))));
+ builder.statements_
+ ->* (!protect ? $E($ CYAssign($M(self, name), $V(unique))) :
+ CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("value"), $V(unique), $ CYPropertyValue($S("writable"), $ CYTrue()))));
+}
+
+void CYPropertySetter::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) {
+ CYIdentifier *unique(context.Unique());
+ builder.declarations_
+ ->* $L1($L(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_))));
+ builder.statements_
+ ->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("set"), $V(unique)));
+}
+
+void CYPropertyValue::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) {
+ _assert(!protect);
+ CYIdentifier *unique(context.Unique());
+ builder.declarations_
+ ->* $L1($L(unique, value_));
+ builder.statements_
+ ->* $E($ CYAssign($M(self, name), $V(unique)));
+}
+
+void CYPropertyValue::Replace(CYContext &context) {
+ context.Replace(value_);
+}
+