| 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 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 DISALLOW_COPY_AND_ASSIGN(TryBlocks); | 230 DISALLOW_COPY_AND_ASSIGN(TryBlocks); |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 | 233 |
| 234 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) { | 234 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) { |
| 235 inlined_finally_nodes_.Add(node); | 235 inlined_finally_nodes_.Add(node); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 // For parsing a compilation unit. |
| 239 Parser::Parser(const Script& script, | 240 Parser::Parser(const Script& script, |
| 240 const Library& library) | 241 const Library& library) |
| 241 : script_(script), | 242 : script_(script), |
| 242 tokens_(TokenStream::Handle(script.tokens())), | 243 tokens_(TokenStream::Handle(script.tokens())), |
| 243 token_index_(0), | 244 token_index_(0), |
| 244 current_block_(NULL), | 245 current_block_(NULL), |
| 245 is_top_level_(false), | 246 is_top_level_(false), |
| 246 current_member_(NULL), | 247 current_member_(NULL), |
| 247 allow_function_literals_(true), | 248 allow_function_literals_(true), |
| 248 current_function_(Function::Handle()), | 249 current_function_(Function::Handle()), |
| 249 current_class_(Class::Handle()), | 250 current_class_(Class::Handle()), |
| 250 library_(library), | 251 library_(library), |
| 251 try_blocks_list_(NULL), | 252 try_blocks_list_(NULL), |
| 252 expression_temp_(NULL) { | 253 expression_temp_(NULL) { |
| 253 ASSERT(!tokens_.IsNull()); | 254 ASSERT(!tokens_.IsNull()); |
| 254 ASSERT(!library.IsNull()); | 255 ASSERT(!library.IsNull()); |
| 255 SetPosition(0); | 256 SetPosition(0); |
| 256 } | 257 } |
| 257 | 258 |
| 258 | 259 |
| 260 // For parsing a function. |
| 259 Parser::Parser(const Script& script, | 261 Parser::Parser(const Script& script, |
| 260 const Function& function, | 262 const Function& function, |
| 261 intptr_t token_index) | 263 intptr_t token_index) |
| 262 : script_(script), | 264 : script_(script), |
| 263 tokens_(TokenStream::Handle(script.tokens())), | 265 tokens_(TokenStream::Handle(script.tokens())), |
| 264 token_index_(0), | 266 token_index_(0), |
| 265 current_block_(NULL), | 267 current_block_(NULL), |
| 266 is_top_level_(false), | 268 is_top_level_(false), |
| 267 current_member_(NULL), | 269 current_member_(NULL), |
| 268 allow_function_literals_(true), | 270 allow_function_literals_(true), |
| 269 current_function_(function), | 271 current_function_(function), |
| 270 current_class_(Class::Handle(current_function_.owner())), | 272 current_class_(Class::Handle(current_function_.owner())), |
| 271 library_(Library::Handle(current_class_.library())), | 273 library_(Library::Handle(current_class_.library())), |
| 272 try_blocks_list_(NULL), | 274 try_blocks_list_(NULL), |
| 273 expression_temp_(NULL) { | 275 expression_temp_(NULL) { |
| 274 ASSERT(!tokens_.IsNull()); | 276 ASSERT(!tokens_.IsNull()); |
| 275 ASSERT(!function.IsNull()); | 277 ASSERT(!function.IsNull()); |
| 276 SetPosition(token_index); | 278 SetPosition(token_index); |
| 279 if (FLAG_enable_type_checks) { |
| 280 EnsureExpressionTemp(); |
| 281 } |
| 277 } | 282 } |
| 278 | 283 |
| 279 | 284 |
| 280 bool Parser::SetAllowFunctionLiterals(bool value) { | 285 bool Parser::SetAllowFunctionLiterals(bool value) { |
| 281 bool current_value = allow_function_literals_; | 286 bool current_value = allow_function_literals_; |
| 282 allow_function_literals_ = value; | 287 allow_function_literals_ = value; |
| 283 return current_value; | 288 return current_value; |
| 284 } | 289 } |
| 285 | 290 |
| 286 | 291 |
| (...skipping 8176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8463 void Parser::SkipQualIdent() { | 8468 void Parser::SkipQualIdent() { |
| 8464 ASSERT(IsIdentifier()); | 8469 ASSERT(IsIdentifier()); |
| 8465 ConsumeToken(); | 8470 ConsumeToken(); |
| 8466 if (CurrentToken() == Token::kPERIOD) { | 8471 if (CurrentToken() == Token::kPERIOD) { |
| 8467 ConsumeToken(); // Consume the kPERIOD token. | 8472 ConsumeToken(); // Consume the kPERIOD token. |
| 8468 ExpectIdentifier("identifier expected after '.'"); | 8473 ExpectIdentifier("identifier expected after '.'"); |
| 8469 } | 8474 } |
| 8470 } | 8475 } |
| 8471 | 8476 |
| 8472 } // namespace dart | 8477 } // namespace dart |
| OLD | NEW |