| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 parameter.is_final = true; | 2144 parameter.is_final = true; |
| 2145 } | 2145 } |
| 2146 } | 2146 } |
| 2147 if ((parameter.type == NULL) && (CurrentToken() == Token::kVOID)) { | 2147 if ((parameter.type == NULL) && (CurrentToken() == Token::kVOID)) { |
| 2148 ConsumeToken(); | 2148 ConsumeToken(); |
| 2149 // This must later be changed to a closure type if we recognize | 2149 // This must later be changed to a closure type if we recognize |
| 2150 // a closure/function type parameter. We check this at the end | 2150 // a closure/function type parameter. We check this at the end |
| 2151 // of ParseFormalParameter. | 2151 // of ParseFormalParameter. |
| 2152 parameter.type = &Object::void_type(); | 2152 parameter.type = &Object::void_type(); |
| 2153 } | 2153 } |
| 2154 if (parameter.type == NULL) { | 2154 if ((parameter.type == NULL) || IsFunctionTypeSymbol()) { |
| 2155 // At this point, we must see an identifier for the type or the | 2155 // At this point, we must see an identifier for the type or the |
| 2156 // function parameter. The identifier may be 'Function'. | 2156 // function parameter. The identifier may be 'Function'. |
| 2157 if (!IsIdentifier()) { | 2157 if (!IsIdentifier()) { |
| 2158 ReportError("parameter name or type expected"); | 2158 ReportError("parameter name or type expected"); |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 // Lookahead to determine whether the next tokens are a return type | 2161 // Lookahead to determine whether the next tokens are a return type |
| 2162 // followed by a parameter name. | 2162 // followed by a parameter name. |
| 2163 bool found_type = false; | 2163 bool found_type = false; |
| 2164 { | 2164 { |
| 2165 TokenPosScope saved_pos(this); | 2165 TokenPosScope saved_pos(this); |
| 2166 if (TryParseType(true)) { | 2166 if (TryParseType(true)) { |
| 2167 if (IsIdentifier() || (CurrentToken() == Token::kTHIS)) { | 2167 if (IsIdentifier() || (CurrentToken() == Token::kTHIS)) { |
| 2168 found_type = true; | 2168 found_type = true; |
| 2169 } | 2169 } |
| 2170 } | 2170 } |
| 2171 } | 2171 } |
| 2172 if (found_type) { | 2172 if (found_type) { |
| 2173 // The types of formal parameters are never ignored, even in unchecked | 2173 // The types of formal parameters are never ignored, even in unchecked |
| 2174 // mode, because they are part of the function type of closurized | 2174 // mode, because they are part of the function type of closurized |
| 2175 // functions appearing in type tests with typedefs. | 2175 // functions appearing in type tests with typedefs. |
| 2176 parameter.has_explicit_type = true; | 2176 parameter.has_explicit_type = true; |
| 2177 // It is too early to resolve the type here, since it can be a result | 2177 // It is too early to resolve the type here, since it can be a result |
| 2178 // type referring to a not yet declared function type parameter. | 2178 // type referring to a not yet declared function type parameter. |
| 2179 parameter.type = &AbstractType::ZoneHandle( | 2179 if (parameter.type == NULL) { |
| 2180 Z, ParseTypeOrFunctionType(true, ClassFinalizer::kDoNotResolve)); | 2180 parameter.type = &AbstractType::ZoneHandle( |
| 2181 Z, ParseTypeOrFunctionType(true, ClassFinalizer::kDoNotResolve)); |
| 2182 } else { |
| 2183 parameter.type = &AbstractType::ZoneHandle( |
| 2184 Z, |
| 2185 ParseFunctionType(*parameter.type, ClassFinalizer::kDoNotResolve)); |
| 2186 } |
| 2181 } else { | 2187 } else { |
| 2182 // If this is an initializing formal, its type will be set to the type | 2188 // If this is an initializing formal, its type will be set to the type |
| 2183 // of the respective field when the constructor is fully parsed. | 2189 // of the respective field when the constructor is fully parsed. |
| 2184 parameter.type = &Object::dynamic_type(); | 2190 parameter.type = &Object::dynamic_type(); |
| 2185 } | 2191 } |
| 2186 } | 2192 } |
| 2187 if (!this_seen && (CurrentToken() == Token::kTHIS)) { | 2193 if (!this_seen && (CurrentToken() == Token::kTHIS)) { |
| 2188 ConsumeToken(); | 2194 ConsumeToken(); |
| 2189 ExpectToken(Token::kPERIOD); | 2195 ExpectToken(Token::kPERIOD); |
| 2190 this_seen = true; | 2196 this_seen = true; |
| (...skipping 13230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15421 TokenPosition* start, | 15427 TokenPosition* start, |
| 15422 TokenPosition* end) { | 15428 TokenPosition* end) { |
| 15423 UNREACHABLE(); | 15429 UNREACHABLE(); |
| 15424 return false; | 15430 return false; |
| 15425 } | 15431 } |
| 15426 | 15432 |
| 15427 | 15433 |
| 15428 } // namespace dart | 15434 } // namespace dart |
| 15429 | 15435 |
| 15430 #endif // DART_PRECOMPILED_RUNTIME | 15436 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |