1.1 --- a/src/compiler/Parser.cpp Tue Dec 25 18:13:02 2012 -0800
1.2 +++ b/src/compiler/Parser.cpp Wed Dec 26 17:14:12 2012 -0800
1.3 @@ -1044,7 +1044,7 @@
1.4 case TOK_NEW:
1.5 {
1.6 TypeQualifiers quals = (kind == TOK_CONST)
1.7 - ? TypeQual_UnkConst
1.8 + ? TypeQual_Const
1.9 : TypeQual_None;
1.10 scanner_.scan();
1.11 if ((statement = vars(quals)) == NULL)
1.12 @@ -1253,7 +1253,10 @@
1.13
1.14 if (!match(TOK_RPAREN)) {
1.15 while (true) {
1.16 - bool isConst = match(TOK_CONST);
1.17 + TypeQualifiers quals = TypeQual_None;
1.18 + if (match(TOK_CONST))
1.19 + quals = TypeQualifiers(quals | TypeQual_Const);
1.20 +
1.21 bool ref = match(TOK_AMPERSAND);
1.22
1.23 SourcePosition begin = scanner_.begin();
1.24 @@ -1263,7 +1266,7 @@
1.25 return NULL;
1.26
1.27 if (!name) {
1.28 - if (isConst || ref) {
1.29 + if ((quals & TypeQual_Const) || ref) {
1.30 cc_.reportError(begin, Message_InvalidVarArgs);
1.31 return NULL;
1.32 }
1.33 @@ -1289,7 +1292,7 @@
1.34 return NULL;
1.35 }
1.36
1.37 - Parameter *parameter = new (pool_) Parameter(name, type, ref, isConst, dims, expr, begin);
1.38 + Parameter *parameter = new (pool_) Parameter(name, type, ref, quals, dims, expr, begin);
1.39 if (!parameters->append(parameter))
1.40 return NULL;
1.41
1.42 @@ -1335,42 +1338,11 @@
1.43 return DeclareIntrinsicType(zone, scope, name, primitive);
1.44 }
1.45
1.46 -bool
1.47 -Parser::setupIntrinsics()
1.48 -{
1.49 -#if 0
1.50 - if (!DeclareIntrinsicType(zone_, scope_, "Float", PrimitiveType_Float))
1.51 - return false;
1.52 - if (!DeclareIntrinsicType(zone_, scope_, "_", PrimitiveType_Int32))
1.53 - return false;
1.54 - if (!DeclareIntrinsicType(zone_, scope_, "bool", PrimitiveType_Bool))
1.55 - return false;
1.56 - if (!DeclareIntrinsicType(zone_, scope_, "String", PrimitiveType_Char))
1.57 - return false;
1.58 -
1.59 - Local<Type> unchecked(zone_, zone_->types()->getUnchecked());
1.60 - if (!DeclareIntrinsicType(zone_, scope_, "unchecked", unchecked))
1.61 - return false;
1.62 -
1.63 - Local<Type> voidType(zone_, zone_->types()->getVoid());
1.64 - if (!DeclareIntrinsicType(zone_, scope_, "void", voidType))
1.65 - return false;
1.66 -
1.67 - Local<Type> intType(zone_, zone_->types()->getPrimitive(PrimitiveType_Int32));
1.68 - if (!DeclareIntrinsicType(zone_, scope_, "int", intType))
1.69 - return false;
1.70 -#endif
1.71 - return true;
1.72 -}
1.73 -
1.74 ParseTree *
1.75 Parser::parse()
1.76 {
1.77 StatementList *statements = new (pool_) StatementList();
1.78
1.79 - if (!setupIntrinsics())
1.80 - return NULL;
1.81 -
1.82 for (;;) {
1.83 Statement *statement = NULL;
1.84
1.85 @@ -1412,7 +1384,7 @@
1.86 if (kind != TOK_LABEL)
1.87 scanner_.scan();
1.88 if (kind == TOK_PUBLIC && peek(TOK_CONST)) {
1.89 - if ((statement = var(TypeQual_UnkConst)) == NULL)
1.90 + if ((statement = var(TypeQual_Const)) == NULL)
1.91 return NULL;
1.92 if (!matchSemicolon())
1.93 return NULL;
1.94 @@ -1428,7 +1400,7 @@
1.95 case TOK_CONST:
1.96 case TOK_NEW:
1.97 {
1.98 - TypeQualifiers quals = (kind == TOK_NEW) ? TypeQual_UnkConst : TypeQual_None;
1.99 + TypeQualifiers quals = (kind == TOK_CONST) ? TypeQual_Const : TypeQual_None;
1.100 // Note: at global scope, we don't accept comma-delimited
1.101 // declarations yet, to see if we can get away with forcing
1.102 // a nicer top-level style.