Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: runtime/vm/parser.cc

Issue 11442010: Introduce a class encapsulating arguments descriptor arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (num_opt_params == 0) { 158 if (num_opt_params == 0) {
159 // Parameter i will be at fp[1 + num_params - i] and local variable 159 // Parameter i will be at fp[1 + num_params - i] and local variable
160 // j will be at fp[kFirstLocalSlotIndex - j]. 160 // j will be at fp[kFirstLocalSlotIndex - j].
161 ASSERT(GetSavedArgumentsDescriptorVar() == NULL); 161 ASSERT(GetSavedArgumentsDescriptorVar() == NULL);
162 first_parameter_index_ = 1 + num_params; 162 first_parameter_index_ = 1 + num_params;
163 first_stack_local_index_ = kFirstLocalSlotIndex; 163 first_stack_local_index_ = kFirstLocalSlotIndex;
164 num_copied_params_ = 0; 164 num_copied_params_ = 0;
165 } else { 165 } else {
166 // Parameter i will be at fp[kFirstLocalSlotIndex - i] and local variable 166 // Parameter i will be at fp[kFirstLocalSlotIndex - i] and local variable
167 // j will be at fp[kFirstLocalSlotIndex - num_params - j]. 167 // j will be at fp[kFirstLocalSlotIndex - num_params - j].
168 // The saved argument descriptor variable must be allocated similarly to 168 // The saved arguments descriptor variable must be allocated similarly to
169 // a parameter, so that it gets both a frame slot and a context slot when 169 // a parameter, so that it gets both a frame slot and a context slot when
170 // captured. 170 // captured.
171 if (GetSavedArgumentsDescriptorVar() != NULL) { 171 if (GetSavedArgumentsDescriptorVar() != NULL) {
172 num_params += 1; 172 num_params += 1;
173 } 173 }
174 first_parameter_index_ = kFirstLocalSlotIndex; 174 first_parameter_index_ = kFirstLocalSlotIndex;
175 first_stack_local_index_ = first_parameter_index_ - num_params; 175 first_stack_local_index_ = first_parameter_index_ - num_params;
176 num_copied_params_ = num_params; 176 num_copied_params_ = num_params;
177 } 177 }
178 178
(...skipping 6914 matching lines...) Expand 10 before | Expand all | Expand 10 after
7093 GrowableObjectArray::Handle(GrowableObjectArray::New()); 7093 GrowableObjectArray::Handle(GrowableObjectArray::New());
7094 bool named_argument_seen = false; 7094 bool named_argument_seen = false;
7095 if (LookaheadToken(1) != Token::kRPAREN) { 7095 if (LookaheadToken(1) != Token::kRPAREN) {
7096 String& arg_name = String::Handle(); 7096 String& arg_name = String::Handle();
7097 do { 7097 do {
7098 ASSERT((CurrentToken() == Token::kLPAREN) || 7098 ASSERT((CurrentToken() == Token::kLPAREN) ||
7099 (CurrentToken() == Token::kCOMMA)); 7099 (CurrentToken() == Token::kCOMMA));
7100 ConsumeToken(); 7100 ConsumeToken();
7101 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) { 7101 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) {
7102 named_argument_seen = true; 7102 named_argument_seen = true;
7103 // The canonicalization of the argument descriptor array built in the 7103 // The canonicalization of the arguments descriptor array built in
7104 // code generator requires that the names are symbols, i.e. 7104 // the code generator requires that the names are symbols, i.e.
7105 // canonicalized strings. 7105 // canonicalized strings.
7106 ASSERT(CurrentLiteral()->IsSymbol()); 7106 ASSERT(CurrentLiteral()->IsSymbol());
7107 for (int i = 0; i < names.Length(); i++) { 7107 for (int i = 0; i < names.Length(); i++) {
7108 arg_name ^= names.At(i); 7108 arg_name ^= names.At(i);
7109 if (CurrentLiteral()->Equals(arg_name)) { 7109 if (CurrentLiteral()->Equals(arg_name)) {
7110 ErrorMsg("duplicate named argument"); 7110 ErrorMsg("duplicate named argument");
7111 } 7111 }
7112 } 7112 }
7113 names.Add(*CurrentLiteral()); 7113 names.Add(*CurrentLiteral());
7114 ConsumeToken(); // ident. 7114 ConsumeToken(); // ident.
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
9245 saved_args_desc_name, 9245 saved_args_desc_name,
9246 Type::ZoneHandle(Type::ArrayType())); 9246 Type::ZoneHandle(Type::ArrayType()));
9247 saved_args_desc_var->set_is_final(); 9247 saved_args_desc_var->set_is_final();
9248 // The saved arguments descriptor variable must be added just after the 9248 // The saved arguments descriptor variable must be added just after the
9249 // formal parameters. This simplifies the 2-step saving of a captured 9249 // formal parameters. This simplifies the 2-step saving of a captured
9250 // arguments descriptor. 9250 // arguments descriptor.
9251 // At this time, the owner scope should only contain formal parameters. 9251 // At this time, the owner scope should only contain formal parameters.
9252 ASSERT(owner_scope->num_variables() == owner_function.NumParameters()); 9252 ASSERT(owner_scope->num_variables() == owner_function.NumParameters());
9253 bool success = owner_scope->AddVariable(saved_args_desc_var); 9253 bool success = owner_scope->AddVariable(saved_args_desc_var);
9254 ASSERT(success); 9254 ASSERT(success);
9255 // Capture the saved argument descriptor variable if necessary. 9255 // Capture the saved arguments descriptor variable if necessary.
9256 LocalVariable* local = LookupLocalScope(saved_args_desc_name); 9256 LocalVariable* local = LookupLocalScope(saved_args_desc_name);
9257 ASSERT(local == saved_args_desc_var); 9257 ASSERT(local == saved_args_desc_var);
9258 } 9258 }
9259 // If we currently generate code for the local function of an enclosing owner 9259 // If we currently generate code for the local function of an enclosing owner
9260 // function, the saved arguments descriptor variable must have been captured 9260 // function, the saved arguments descriptor variable must have been captured
9261 // by the above lookup. 9261 // by the above lookup.
9262 ASSERT((owner_function.raw() == innermost_function().raw()) || 9262 ASSERT((owner_function.raw() == innermost_function().raw()) ||
9263 saved_args_desc_var->is_captured()); 9263 saved_args_desc_var->is_captured());
9264 const String& param_name = String::ZoneHandle(Symbols::New(*ident)); 9264 const String& param_name = String::ZoneHandle(Symbols::New(*ident));
9265 return new ArgumentDefinitionTestNode( 9265 return new ArgumentDefinitionTestNode(
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
9706 void Parser::SkipQualIdent() { 9706 void Parser::SkipQualIdent() {
9707 ASSERT(IsIdentifier()); 9707 ASSERT(IsIdentifier());
9708 ConsumeToken(); 9708 ConsumeToken();
9709 if (CurrentToken() == Token::kPERIOD) { 9709 if (CurrentToken() == Token::kPERIOD) {
9710 ConsumeToken(); // Consume the kPERIOD token. 9710 ConsumeToken(); // Consume the kPERIOD token.
9711 ExpectIdentifier("identifier expected after '.'"); 9711 ExpectIdentifier("identifier expected after '.'");
9712 } 9712 }
9713 } 9713 }
9714 9714
9715 } // namespace dart 9715 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698