return this;
}
+CYTarget *CYAttemptMember::Replace(CYContext &context) {
+ CYIdentifier *value(context.Unique());
+
+ return $C1($F(NULL, $P1($B(value)), $$
+ ->* $ CYReturn($ CYCondition($V(value), $M($V(value), property_), $V(value)))
+ ), object_);
+}
+
CYStatement *CYBlock::Return() {
CYImplicitReturn(code_);
return this;
}
CYTarget *CYCall::Replace(CYContext &context) {
+ // XXX: this also is a horrible hack but I'm still a month over schedule :(
+ if (CYAttemptMember *member = dynamic_cast<CYAttemptMember *>(function_)) {
+ CYIdentifier *value(context.Unique());
+
+ return $C1($F(NULL, $P1($B(value)), $$
+ ->* $ CYReturn($ CYCondition($V(value), $C($M($V(value), member->property_), arguments_), $V(value)))
+ ), member->object_);
+ }
+
context.Replace(function_);
arguments_->Replace(context);
return this;
}
CYTarget *CYExternalExpression::Replace(CYContext &context) {
- return $C1(type_->Replace(context), $C2($V("dlsym"), $V("RTLD_DEFAULT"), name_->PropertyName(context)));
+ CYExpression *expression(name_->Number(context));
+ if (expression == NULL)
+ expression = $C2($V("dlsym"), $V("RTLD_DEFAULT"), name_->PropertyName(context));
+ return $C1(type_->Replace(context), expression);
}
CYNumber *CYFalse::Number(CYContext &context) {
else if (existing->kind_ == CYIdentifierGlobal || existing->kind_ == CYIdentifierMagic)
existing->kind_ = kind;
else if (existing->kind_ == CYIdentifierLexical || kind == CYIdentifierLexical)
- _assert(false); // XXX: throw new SyntaxError()
+ _assert(false);
+ else if (transparent_ && existing->kind_ == CYIdentifierArgument && kind == CYIdentifierVariable)
+ _assert(false);
+ // XXX: throw new SyntaxError() instead of these asserts
return existing;
}
CYForEach (i, internal_) {
_assert(i->identifier_->next_ == i->identifier_);
switch (i->kind_) {
- case CYIdentifierArgument: {
- _assert(!transparent_);
- } break;
-
case CYIdentifierLexical: {
if (!damaged_) {
CYIdentifier *replace(context.Unique());
return $C2($M($M($M($V("String"), $S("prototype")), $S("concat")), $S("apply")), $S(""), $ CYArray($ CYElementValue(string_, spans_->Replace(context))));
}
+CYString *CYTemplate::String(CYContext &context) {
+ // XXX: implement this over local concat
+ if (spans_ != NULL)
+ return NULL;
+ return string_;
+}
+
CYTarget *CYThis::Replace(CYContext &context) {
if (context.this_ != NULL)
return $V(context.this_->Identifier(context));
return typed_->Replace(context);
}
+CYTarget *CYTypeFloating::Replace(CYContext &context) {
+ switch (length_) {
+ case 0: return $V("float");
+ case 1: return $V("double");
+ case 2: return $V("longdouble");
+ default: _assert(false);
+ }
+}
+
CYTarget *CYTypeInt128::Replace(CYContext &context) {
return $V(signing_ == CYTypeUnsigned ? "uint128" : "int128");
}