| 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 8910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8921 return new LiteralNode(test_pos, Bool::ZoneHandle(Bool::True())); | 8921 return new LiteralNode(test_pos, Bool::ZoneHandle(Bool::True())); |
| 8922 } | 8922 } |
| 8923 char name[64]; | 8923 char name[64]; |
| 8924 OS::SNPrint(name, 64, "%s_%d", | 8924 OS::SNPrint(name, 64, "%s_%d", |
| 8925 Symbols::Name(Symbols::kSavedArgDescVarPrefix), | 8925 Symbols::Name(Symbols::kSavedArgDescVarPrefix), |
| 8926 owner_function.token_pos()); | 8926 owner_function.token_pos()); |
| 8927 const String& saved_args_desc_name = String::ZoneHandle(Symbols::New(name)); | 8927 const String& saved_args_desc_name = String::ZoneHandle(Symbols::New(name)); |
| 8928 LocalVariable* saved_args_desc_var = LookupLocalScope(saved_args_desc_name); | 8928 LocalVariable* saved_args_desc_var = LookupLocalScope(saved_args_desc_name); |
| 8929 if (saved_args_desc_var == NULL) { | 8929 if (saved_args_desc_var == NULL) { |
| 8930 ASSERT(owner_scope != NULL); | 8930 ASSERT(owner_scope != NULL); |
| 8931 ASSERT(owner_function.raw() == current_function().raw()); | |
| 8932 // We currently generate code for 'owner_function', otherwise the variable | |
| 8933 // would have been created when compiling the enclosing function of the | |
| 8934 // currently being compiled local function. | |
| 8935 saved_args_desc_var = | 8931 saved_args_desc_var = |
| 8936 new LocalVariable(owner_function.token_pos(), | 8932 new LocalVariable(owner_function.token_pos(), |
| 8937 saved_args_desc_name, | 8933 saved_args_desc_name, |
| 8938 Type::ZoneHandle(Type::ListInterface())); | 8934 Type::ZoneHandle(Type::ListInterface())); |
| 8939 saved_args_desc_var->set_is_final(); | 8935 saved_args_desc_var->set_is_final(); |
| 8940 // The saved arguments descriptor variable must be added just after the | 8936 // The saved arguments descriptor variable must be added just after the |
| 8941 // formal parameters. This simplifies the 2-step saving of a captured | 8937 // formal parameters. This simplifies the 2-step saving of a captured |
| 8942 // arguments descriptor. | 8938 // arguments descriptor. |
| 8943 // At this time, the owner scope should only contain formal parameters. | 8939 // At this time, the owner scope should only contain formal parameters. |
| 8944 ASSERT(owner_scope->num_variables() == owner_function.NumberOfParameters()); | 8940 ASSERT(owner_scope->num_variables() == owner_function.NumberOfParameters()); |
| 8945 bool success = owner_scope->AddVariable(saved_args_desc_var); | 8941 bool success = owner_scope->AddVariable(saved_args_desc_var); |
| 8946 ASSERT(success); | 8942 ASSERT(success); |
| 8947 // Capture the saved argument descriptor variable if necessary. | 8943 // Capture the saved argument descriptor variable if necessary. |
| 8948 if (current_function().raw() != innermost_function().raw()) { | 8944 LocalVariable* local = LookupLocalScope(saved_args_desc_name); |
| 8949 LocalVariable* local = LookupLocalScope(saved_args_desc_name); | 8945 ASSERT(local == saved_args_desc_var); |
| 8950 ASSERT(local == saved_args_desc_var); | |
| 8951 ASSERT(local->is_captured()); | |
| 8952 } | |
| 8953 } else { | |
| 8954 // If we currently generate code for a local function of the owner function, | |
| 8955 // the saved arguments descriptor variable must have been captured by the | |
| 8956 // above lookup. | |
| 8957 ASSERT((owner_function.raw() == current_function().raw()) || | |
| 8958 saved_args_desc_var->is_captured()); | |
| 8959 } | 8946 } |
| 8947 // If we currently generate code for the local function of an enclosing owner |
| 8948 // function, the saved arguments descriptor variable must have been captured |
| 8949 // by the above lookup. |
| 8950 ASSERT((owner_function.raw() == innermost_function().raw()) || |
| 8951 saved_args_desc_var->is_captured()); |
| 8960 const String& param_name = String::ZoneHandle(Symbols::New(*ident)); | 8952 const String& param_name = String::ZoneHandle(Symbols::New(*ident)); |
| 8961 return new ArgumentDefinitionTestNode( | 8953 return new ArgumentDefinitionTestNode( |
| 8962 test_pos, param_index, param_name, saved_args_desc_var); | 8954 test_pos, param_index, param_name, saved_args_desc_var); |
| 8963 } | 8955 } |
| 8964 | 8956 |
| 8965 | 8957 |
| 8966 AstNode* Parser::ParsePrimary() { | 8958 AstNode* Parser::ParsePrimary() { |
| 8967 TRACE_PARSER("ParsePrimary"); | 8959 TRACE_PARSER("ParsePrimary"); |
| 8968 ASSERT(!is_top_level_); | 8960 ASSERT(!is_top_level_); |
| 8969 AstNode* primary = NULL; | 8961 AstNode* primary = NULL; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9377 void Parser::SkipQualIdent() { | 9369 void Parser::SkipQualIdent() { |
| 9378 ASSERT(IsIdentifier()); | 9370 ASSERT(IsIdentifier()); |
| 9379 ConsumeToken(); | 9371 ConsumeToken(); |
| 9380 if (CurrentToken() == Token::kPERIOD) { | 9372 if (CurrentToken() == Token::kPERIOD) { |
| 9381 ConsumeToken(); // Consume the kPERIOD token. | 9373 ConsumeToken(); // Consume the kPERIOD token. |
| 9382 ExpectIdentifier("identifier expected after '.'"); | 9374 ExpectIdentifier("identifier expected after '.'"); |
| 9383 } | 9375 } |
| 9384 } | 9376 } |
| 9385 | 9377 |
| 9386 } // namespace dart | 9378 } // namespace dart |
| OLD | NEW |