std::stringbuf out;
CYOptions options;
CYOutput output(out, options);
- (new(pool) CYEncodedType(Decode(pool, internal->type_)))->Output(output, CYNoFlags);
+ (new(pool) CYTypeExpression(Decode(pool, internal->type_)))->Output(output, CYNoFlags);
return CYCastJSValue(context, CYJSString(out.str().c_str()));
} CYCatch(NULL) }
}
CYTarget *CYObjCBlock::Replace(CYContext &context) {
- return $C1($ CYEncodedType(($ CYTypedIdentifier(*typed_))->Modify($ CYTypeBlockWith(parameters_))), $ CYFunctionExpression(NULL, parameters_->Parameters(context), code_));
+ return $C1($ CYTypeExpression(($ CYTypedIdentifier(*typed_))->Modify($ CYTypeBlockWith(parameters_))), $ CYFunctionExpression(NULL, parameters_->Parameters(context), code_));
}
CYStatement *CYProtocol::Replace(CYContext &context) const { $T(NULL)
out << "typedef" << ' ' << *typed_;
}
+void CYTypeExpression::Output(CYOutput &out, CYFlags flags) const {
+ out << '(' << "typedef" << ' ' << *typed_ << ')';
+}
+
void CYLexical::Output(CYOutput &out, CYFlags flags) const {
out << "let" << ' ';
bindings_->Output(out, flags); // XXX: flags
Statement__
: "typedef" NewLineNot TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($typed); }
;
+
+PrimaryExpression
+ : "(" LexOf "typedef" NewLineOpt TypedIdentifier[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); } ")" { $$ = CYNew CYTypeExpression($typed); }
+ ;
/* }}} */
/* Cycript (C): extern "C" {{{ */
IdentifierNoOf
}
CYStatement *CYTypeDefinition::Replace(CYContext &context) {
- 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 *CYTypeError::Replace(CYContext &context) {
return NULL;
}
+CYTarget *CYTypeExpression::Replace(CYContext &context) {
+ return typed_->Replace(context);
+}
+
CYTarget *CYTypeModifier::Replace(CYContext &context, CYTarget *type) { $T(type)
return Replace_(context, type);
}
virtual void Output(CYOutput &out, CYFlags flags) const;
};
+struct CYTypeExpression :
+ CYTarget
+{
+ CYTypedIdentifier *typed_;
+
+ CYTypeExpression(CYTypedIdentifier *typed) :
+ typed_(typed)
+ {
+ }
+
+ CYPrecedence(0)
+
+ virtual CYTarget *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
struct CYTypeDefinition :
CYStatement
{