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

Side by Side Diff: pkg/front_end/lib/src/fasta/builder/procedure_builder.dart

Issue 2995023002: Add debug names to scopes. (Closed)
Patch Set: Created 3 years, 4 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library fasta.procedure_builder; 5 library fasta.procedure_builder;
6 6
7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel 7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel
8 // outside the kernel-specific builders. This is simpler than creating 8 // outside the kernel-specific builders. This is simpler than creating
9 // additional enums. 9 // additional enums.
10 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; 10 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 /// This is the formal parameter scope as specified in the Dart Programming 68 /// This is the formal parameter scope as specified in the Dart Programming
69 /// Language Specifiction, 4th ed, section 9.2. 69 /// Language Specifiction, 4th ed, section 9.2.
70 Scope computeFormalParameterScope(Scope parent) { 70 Scope computeFormalParameterScope(Scope parent) {
71 if (formals == null) return parent; 71 if (formals == null) return parent;
72 Map<String, Builder> local = <String, Builder>{}; 72 Map<String, Builder> local = <String, Builder>{};
73 for (FormalParameterBuilder formal in formals) { 73 for (FormalParameterBuilder formal in formals) {
74 if (!isConstructor || !formal.hasThis) { 74 if (!isConstructor || !formal.hasThis) {
75 local[formal.name] = formal; 75 local[formal.name] = formal;
76 } 76 }
77 } 77 }
78 return new Scope(local, null, parent, isModifiable: false); 78 return new Scope(local, null, parent, "formal parameter",
79 isModifiable: false);
79 } 80 }
80 81
81 Scope computeFormalParameterInitializerScope(Scope parent) { 82 Scope computeFormalParameterInitializerScope(Scope parent) {
82 // From 83 // From
83 // [dartLangSpec.tex](../../../../../../docs/language/dartLangSpec.tex) at 84 // [dartLangSpec.tex](../../../../../../docs/language/dartLangSpec.tex) at
84 // revision 94b23d3b125e9d246e07a2b43b61740759a0dace: 85 // revision 94b23d3b125e9d246e07a2b43b61740759a0dace:
85 // 86 //
86 // When the formal parameter list of a non-redirecting generative 87 // When the formal parameter list of a non-redirecting generative
87 // constructor contains any initializing formals, a new scope is 88 // constructor contains any initializing formals, a new scope is
88 // introduced, the _formal parameter initializer scope_, which is the 89 // introduced, the _formal parameter initializer scope_, which is the
89 // current scope of the initializer list of the constructor, and which is 90 // current scope of the initializer list of the constructor, and which is
90 // enclosed in the scope where the constructor is declared. Each 91 // enclosed in the scope where the constructor is declared. Each
91 // initializing formal in the formal parameter list introduces a final 92 // initializing formal in the formal parameter list introduces a final
92 // local variable into the formal parameter initializer scope, but not into 93 // local variable into the formal parameter initializer scope, but not into
93 // the formal parameter scope; every other formal parameter introduces a 94 // the formal parameter scope; every other formal parameter introduces a
94 // local variable into both the formal parameter scope and the formal 95 // local variable into both the formal parameter scope and the formal
95 // parameter initializer scope. 96 // parameter initializer scope.
96 97
97 if (formals == null) return parent; 98 if (formals == null) return parent;
98 Map<String, Builder> local = <String, Builder>{}; 99 Map<String, Builder> local = <String, Builder>{};
99 for (FormalParameterBuilder formal in formals) { 100 for (FormalParameterBuilder formal in formals) {
100 local[formal.name] = formal.forFormalParameterInitializerScope(); 101 local[formal.name] = formal.forFormalParameterInitializerScope();
101 } 102 }
102 return new Scope(local, null, parent, isModifiable: false); 103 return new Scope(local, null, parent, "formal parameter initializer",
104 isModifiable: false);
103 } 105 }
104 106
105 /// This scope doesn't correspond to any scope specified in the Dart 107 /// This scope doesn't correspond to any scope specified in the Dart
106 /// Programming Language Specifiction, 4th ed. It's an unspecified extension 108 /// Programming Language Specifiction, 4th ed. It's an unspecified extension
107 /// to support generic methods. 109 /// to support generic methods.
108 Scope computeTypeParameterScope(Scope parent) { 110 Scope computeTypeParameterScope(Scope parent) {
109 if (typeVariables == null) return parent; 111 if (typeVariables == null) return parent;
110 Map<String, Builder> local = <String, Builder>{}; 112 Map<String, Builder> local = <String, Builder>{};
111 for (TypeVariableBuilder variable in typeVariables) { 113 for (TypeVariableBuilder variable in typeVariables) {
112 local[variable.name] = variable; 114 local[variable.name] = variable;
113 } 115 }
114 return new Scope(local, null, parent, isModifiable: false); 116 return new Scope(local, null, parent, "type parameter",
117 isModifiable: false);
115 } 118 }
116 119
117 FormalParameterBuilder getFormal(String name) { 120 FormalParameterBuilder getFormal(String name) {
118 for (FormalParameterBuilder formal in formals) { 121 for (FormalParameterBuilder formal in formals) {
119 if (formal.name == name) return formal; 122 if (formal.name == name) return formal;
120 } 123 }
121 return null; 124 return null;
122 } 125 }
123 } 126 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698