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

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

Issue 10108020: Fix bug 1991, variable resolution in string interpolation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months 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
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7076 matching lines...) Expand 10 before | Expand all | Expand 10 after
7087 // If the name cannot be resolved, turn it into an instance field access 7087 // If the name cannot be resolved, turn it into an instance field access
7088 // if we're compiling an instance method, or issue an error message 7088 // if we're compiling an instance method, or issue an error message
7089 // if we're compiling a static method. 7089 // if we're compiling a static method.
7090 AstNode* Parser::ResolveVarOrField(intptr_t ident_pos, const String& ident) { 7090 AstNode* Parser::ResolveVarOrField(intptr_t ident_pos, const String& ident) {
7091 TRACE_PARSER("ResolveVarOrField"); 7091 TRACE_PARSER("ResolveVarOrField");
7092 // First try to find the variable in the local scope (block scope or 7092 // First try to find the variable in the local scope (block scope or
7093 // class scope). 7093 // class scope).
7094 AstNode* var_or_field = NULL; 7094 AstNode* var_or_field = NULL;
7095 ResolveIdentInLocalScope(ident_pos, ident, &var_or_field); 7095 ResolveIdentInLocalScope(ident_pos, ident, &var_or_field);
7096 if (var_or_field == NULL) { 7096 if (var_or_field == NULL) {
7097 // Not found in the local scope, so try finding the variable in the 7097 // Check whether the identifier is a type parameter. Type parameters
7098 // library scope (current library and all libraries imported by it). 7098 // can never be used in primary expressions.
7099 const Class& scope_class = Class::Handle(TypeParametersScopeClass());
7100 if (!scope_class.IsNull()) {
7101 TypeParameter& type_param = TypeParameter::Handle(
7102 scope_class.LookupTypeParameter(ident, ident_pos));
7103 if (!type_param.IsNull()) {
7104 String& type_param_name = String::Handle(type_param.Name());
7105 ErrorMsg(ident_pos, "illegal use of type parameter %s",
7106 type_param_name.ToCString());
7107 }
7108 }
7109 // Not found in the local scope, and the name is not a type parameter.
7110 // Try finding the variable in the library scope (current library
7111 // and all libraries imported by it).
7099 QualIdent qual_ident; 7112 QualIdent qual_ident;
7100 qual_ident.lib_prefix = NULL; 7113 qual_ident.lib_prefix = NULL;
7101 qual_ident.ident_pos = ident_pos; 7114 qual_ident.ident_pos = ident_pos;
7102 qual_ident.ident = &(String::ZoneHandle(ident.raw())); 7115 qual_ident.ident = &(String::ZoneHandle(ident.raw()));
7103 var_or_field = ResolveIdentInLibraryScope(library_, 7116 var_or_field = ResolveIdentInLibraryScope(library_,
7104 qual_ident, 7117 qual_ident,
7105 kResolveIncludingImports); 7118 kResolveIncludingImports);
7106 } 7119 }
7107 if (var_or_field->IsPrimaryNode()) { 7120 if (var_or_field->IsPrimaryNode()) {
7108 PrimaryNode* primary = var_or_field->AsPrimaryNode(); 7121 PrimaryNode* primary = var_or_field->AsPrimaryNode();
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
8375 void Parser::SkipQualIdent() { 8388 void Parser::SkipQualIdent() {
8376 ASSERT(IsIdentifier()); 8389 ASSERT(IsIdentifier());
8377 ConsumeToken(); 8390 ConsumeToken();
8378 if (CurrentToken() == Token::kPERIOD) { 8391 if (CurrentToken() == Token::kPERIOD) {
8379 ConsumeToken(); // Consume the kPERIOD token. 8392 ConsumeToken(); // Consume the kPERIOD token.
8380 ExpectIdentifier("identifier expected after '.'"); 8393 ExpectIdentifier("identifier expected after '.'");
8381 } 8394 }
8382 } 8395 }
8383 8396
8384 } // namespace dart 8397 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698