- return $C0($F(NULL, $P1($L($I("$cyv")), comprehensions_->Parameters(context)), $$
- ->* $E($ CYAssign(cyv, $ CYArray()))
- ->* comprehensions_->Replace(context, $E($C1($M(cyv, $S("push")), expression_)))
- ->* $ CYReturn(cyv)
+ return $C0($F(NULL, $P1($B(cyv), comprehensions_->Parameters(context)), $$
+ ->* $E($ CYAssign($V(cyv), $ CYArray()))
+ ->* comprehensions_->Replace(context, $E($C1($M($V(cyv), $S("push")), expression_)))
+ ->* $ CYReturn($V(cyv))
- return $C1($ CYFunctionExpression(NULL, $P($L(super)), $$
- ->* $ CYVar($L1($L(constructor, tail_->constructor_)))
- ->* $ CYVar($L1($L(prototype, $ CYFunctionExpression(NULL, NULL, NULL))))
+ 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)))
->* $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)))
->* builder.statements_
->* CYDefineProperty($V(constructor), $S("prototype"), false, false, $ CYPropertyValue($S("value"), $V(prototype)))
->* $ CYReturn($V(constructor))
->* builder.statements_
->* CYDefineProperty($V(constructor), $S("prototype"), false, false, $ CYPropertyValue($S("value"), $V(prototype)))
->* $ CYReturn($V(constructor))
cy::Syntax::Catch *rescue(
$ cy::Syntax::Catch(cye, $$
cy::Syntax::Catch *rescue(
$ cy::Syntax::Catch(cye, $$
-CYExpression *CYDeclarations::Replace(CYContext &context, CYIdentifierKind kind) { $T(NULL)
- CYAssignment *assignment(declaration_->Replace(context, kind));
+CYExpression *CYBindings::Replace(CYContext &context, CYIdentifierKind kind) { $T(NULL)
+ CYAssignment *assignment(binding_->Replace(context, kind));
-CYFunctionParameter *CYDeclarations::Parameter(CYContext &context) { $T(NULL)
- return $ CYFunctionParameter($ CYDeclaration(declaration_->identifier_), next_->Parameter(context));
+CYFunctionParameter *CYBindings::Parameter(CYContext &context) { $T(NULL)
+ return $ CYFunctionParameter($ CYBinding(binding_->identifier_), next_->Parameter(context));
-CYArgument *CYDeclarations::Argument(CYContext &context) { $T(NULL)
- return $ CYArgument(declaration_->initialiser_, next_->Argument(context));
+CYArgument *CYBindings::Argument(CYContext &context) { $T(NULL)
+ return $ CYArgument(binding_->initializer_, next_->Argument(context));
CYStatement *CYFor::Replace(CYContext &context) {
CYScope outer(true, context);
CYStatement *CYFor::Replace(CYContext &context) {
CYScope outer(true, context);
- _assert(declaration_->Replace(context, CYIdentifierLexical) == NULL);
- return declaration_->Target(context);
+ _assert(binding_->Replace(context, CYIdentifierLexical) == NULL);
+ return binding_->Target(context);
}
CYStatement *CYForIn::Replace(CYContext &context) {
CYScope scope(true, context);
}
CYStatement *CYForIn::Replace(CYContext &context) {
CYScope scope(true, context);
+CYStatement *CYForInitialized::Replace(CYContext &context) {
+ CYAssignment *assignment(binding_->Replace(context, CYIdentifierVariable));
+ return $ CYBlock($$
+ ->* (assignment == NULL ? NULL : $ CYExpress(assignment))
+ ->* $ CYForIn(binding_->Target(context), iterable_, code_));
+}
+
- return $ CYForIn(declaration_->Target(context), set_, CYComprehension::Replace(context, statement));
+ return $ CYForIn(binding_->Target(context), iterable_, CYComprehension::Replace(context, statement));
}
CYStatement *CYForOf::Replace(CYContext &context) {
CYIdentifier *item(context.Unique()), *list(context.Unique());
return $ CYBlock($$
}
CYStatement *CYForOf::Replace(CYContext &context) {
CYIdentifier *item(context.Unique()), *list(context.Unique());
return $ CYBlock($$
- ->* initialiser_->Initialize(context, NULL)
- ->* $ CYLet(false, $L2($L(list, set_), $L(item)))
+ ->* initializer_->Initialize(context, NULL)
+ ->* $ CYLexical(false, $B2($B(list, iterable_), $B(item)))
- return $E($C0($F(NULL, $P1($L($I("$cys"))), $$
- ->* $E($ CYAssign($V(cys), set_))
- ->* $ CYForIn(declaration_->Target(context), $V(cys), $ CYBlock($$
- ->* $E($ CYAssign(declaration_->Target(context), $M($V(cys), declaration_->Target(context))))
+ return $ CYBlock($$
+ ->* $ CYLexical(false, $B1($B(cys, iterable_)))
+ ->* $ CYForIn(binding_->Target(context), $V(cys), $ CYBlock($$
+ ->* $E($ CYAssign(binding_->Target(context), $M($V(cys), binding_->Target(context))))
- _assert(declaration_->Replace(context, CYIdentifierVariable) == NULL);
- return declaration_->Target(context);
+ _assert(binding_->Replace(context, CYIdentifierVariable) == NULL);
+ return binding_->Target(context);
parameters_->Replace(context, code_);
context.ReplaceAll(code_);
parameters_->Replace(context, code_);
context.ReplaceAll(code_);
- return $ CYVar($L1($L($I(module_->part_->Word()), $C1($V("require"), module_->Replace(context, "/")))));
+ return $ CYVar($B1($B($I(module_->part_->Word()), $C1($V("require"), module_->Replace(context, "/")))));
return $N2($V("Functor"), $ CYFunctionExpression(NULL, parameters_->Parameters(context), code_), parameters_->TypeSignature(context, typed_->Replace(context)));
}
return $N2($V("Functor"), $ CYFunctionExpression(NULL, parameters_->Parameters(context), code_), parameters_->TypeSignature(context, typed_->Replace(context)));
}
-CYForInitializer *CYLet::Replace(CYContext &context) {
- if (CYExpression *expression = declarations_->Replace(context, CYIdentifierLexical))
+CYForInitializer *CYLexical::Replace(CYContext &context) {
+ if (CYExpression *expression = bindings_->Replace(context, CYIdentifierLexical))
properties_ = properties_->ReplaceAll(context, builder, $ CYThis(), false);
if (builder) {
properties_ = properties_->ReplaceAll(context, builder, $ CYThis(), false);
if (builder) {
- ), $S("call")), this, builder.declarations_->Argument(context));
+ ), $S("call")), this, builder.bindings_->Argument(context));
}
CYProperty *CYProperty::ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update) {
}
CYProperty *CYProperty::ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update) {
if (update)
Replace(context, builder, self, false);
if (next_ != NULL)
if (update)
Replace(context, builder, self, false);
if (next_ != NULL)
name = $V(unique);
}
Replace(context, builder, self, name, protect);
}
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());
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.bindings_
+ ->* $B1($B(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_))));
builder.statements_
->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("get"), $V(unique)));
}
builder.statements_
->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("get"), $V(unique)));
}
void CYPropertyMethod::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) {
CYIdentifier *unique(context.Unique());
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.bindings_
+ ->* $B1($B(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()))));
}
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());
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.bindings_
+ ->* $B1($B(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_))));
builder.statements_
->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("set"), $V(unique)));
}
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());
void CYPropertyValue::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) {
_assert(!protect);
CYIdentifier *unique(context.Unique());
- switch (kind) {
- case CYIdentifierArgument:
- case CYIdentifierCatch:
- case CYIdentifierMagic:
- _assert(false);
- default:
- break;
- }
-
- if (existing->kind_ == CYIdentifierGlobal)
+ if (kind == CYIdentifierGlobal);
+ else if (existing->kind_ == CYIdentifierGlobal || existing->kind_ == CYIdentifierMagic)
else if (existing->kind_ == CYIdentifierLexical || kind == CYIdentifierLexical)
_assert(false); // XXX: throw new SyntaxError()
else if (existing->kind_ == CYIdentifierLexical || kind == CYIdentifierLexical)
_assert(false); // XXX: throw new SyntaxError()
- return $E($ CYAssign($V(typed_->identifier_), typed_->Replace(context)));
+ CYIdentifier *identifier(typed_->identifier_);
+ typed_->identifier_ = NULL;
+ return $ CYLexical(false, $B1($B(identifier, $ CYTypeExpression(typed_))));
CYTarget *CYTypeModifier::Replace(CYContext &context, CYTarget *type) { $T(type)
return Replace_(context, type);
}
CYTarget *CYTypeModifier::Replace(CYContext &context, CYTarget *type) { $T(type)
return Replace_(context, type);
}