diff -r e3c851a14f16 -r 18f3010a358c src/compiler/Parser.cpp --- a/src/compiler/Parser.cpp Tue Dec 25 18:13:02 2012 -0800 +++ b/src/compiler/Parser.cpp Wed Dec 26 17:14:12 2012 -0800 @@ -1044,7 +1044,7 @@ case TOK_NEW: { TypeQualifiers quals = (kind == TOK_CONST) - ? TypeQual_UnkConst + ? TypeQual_Const : TypeQual_None; scanner_.scan(); if ((statement = vars(quals)) == NULL) @@ -1253,7 +1253,10 @@ if (!match(TOK_RPAREN)) { while (true) { - bool isConst = match(TOK_CONST); + TypeQualifiers quals = TypeQual_None; + if (match(TOK_CONST)) + quals = TypeQualifiers(quals | TypeQual_Const); + bool ref = match(TOK_AMPERSAND); SourcePosition begin = scanner_.begin(); @@ -1263,7 +1266,7 @@ return NULL; if (!name) { - if (isConst || ref) { + if ((quals & TypeQual_Const) || ref) { cc_.reportError(begin, Message_InvalidVarArgs); return NULL; } @@ -1289,7 +1292,7 @@ return NULL; } - Parameter *parameter = new (pool_) Parameter(name, type, ref, isConst, dims, expr, begin); + Parameter *parameter = new (pool_) Parameter(name, type, ref, quals, dims, expr, begin); if (!parameters->append(parameter)) return NULL; @@ -1335,42 +1338,11 @@ return DeclareIntrinsicType(zone, scope, name, primitive); } -bool -Parser::setupIntrinsics() -{ -#if 0 - if (!DeclareIntrinsicType(zone_, scope_, "Float", PrimitiveType_Float)) - return false; - if (!DeclareIntrinsicType(zone_, scope_, "_", PrimitiveType_Int32)) - return false; - if (!DeclareIntrinsicType(zone_, scope_, "bool", PrimitiveType_Bool)) - return false; - if (!DeclareIntrinsicType(zone_, scope_, "String", PrimitiveType_Char)) - return false; - - Local unchecked(zone_, zone_->types()->getUnchecked()); - if (!DeclareIntrinsicType(zone_, scope_, "unchecked", unchecked)) - return false; - - Local voidType(zone_, zone_->types()->getVoid()); - if (!DeclareIntrinsicType(zone_, scope_, "void", voidType)) - return false; - - Local intType(zone_, zone_->types()->getPrimitive(PrimitiveType_Int32)); - if (!DeclareIntrinsicType(zone_, scope_, "int", intType)) - return false; -#endif - return true; -} - ParseTree * Parser::parse() { StatementList *statements = new (pool_) StatementList(); - if (!setupIntrinsics()) - return NULL; - for (;;) { Statement *statement = NULL; @@ -1412,7 +1384,7 @@ if (kind != TOK_LABEL) scanner_.scan(); if (kind == TOK_PUBLIC && peek(TOK_CONST)) { - if ((statement = var(TypeQual_UnkConst)) == NULL) + if ((statement = var(TypeQual_Const)) == NULL) return NULL; if (!matchSemicolon()) return NULL; @@ -1428,7 +1400,7 @@ case TOK_CONST: case TOK_NEW: { - TypeQualifiers quals = (kind == TOK_NEW) ? TypeQual_UnkConst : TypeQual_None; + TypeQualifiers quals = (kind == TOK_CONST) ? TypeQual_Const : TypeQual_None; // Note: at global scope, we don't accept comma-delimited // declarations yet, to see if we can get away with forcing // a nicer top-level style.