Rename TypeOfExpr / TypeOfInst to MetatypeExpr / MetatypeInst.

Introduce a '.metatype' form in the syntax and do some basic
type-checking that I probably haven't done right.  Change
IR-generation for that and GetMetatypeExpr to use code that
actually honors the dynamic type of an expression.

Swift SVN r3053
This commit is contained in:
John McCall
2012-10-24 07:54:23 +00:00
parent a6a2ab92b3
commit 2f8f05615e
24 changed files with 189 additions and 75 deletions

View File

@@ -233,6 +233,7 @@ NullablePtr<Expr> Parser::parseExprNew() {
/// expr-postfix:
/// expr-primary
/// expr-dot
/// expr-metatype
/// expr-subscript
/// expr-call
/// expr-postfix operator-postfix
@@ -316,6 +317,12 @@ NullablePtr<Expr> Parser::parseExprPostfix(Diag<> ID) {
SourceLoc TokLoc = Tok.getLoc();
if (consumeIf(tok::period)) {
if (Tok.is(tok::kw_metatype)) {
SourceLoc metatypeLoc = consumeToken(tok::kw_metatype);
Result = new (Context) MetatypeExpr(Result.get(), metatypeLoc, Type());
continue;
}
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::dollarident)) {
diagnose(Tok, diag::expected_field_name);
return 0;