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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter.full_emitter; 5 part of dart2js.js_emitter.full_emitter;
6 6
7 class ClassEmitter extends CodeEmitterHelper { 7 class ClassEmitter extends CodeEmitterHelper {
8 8
9 ClassStubGenerator get _stubGenerator => 9 ClassStubGenerator get _stubGenerator =>
10 new ClassStubGenerator(compiler, namer, backend); 10 new ClassStubGenerator(compiler, namer, backend);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // TODO(16168): The setter creator only looks at the getter-name. 149 // TODO(16168): The setter creator only looks at the getter-name.
150 // Even though the setter could avoid the interceptor convention we 150 // Even though the setter could avoid the interceptor convention we
151 // currently still need to add the additional argument. 151 // currently still need to add the additional argument.
152 if (field.needsInterceptedGetter || field.needsInterceptedSetter) { 152 if (field.needsInterceptedGetter || field.needsInterceptedSetter) {
153 emitter.interceptorEmitter.interceptorInvocationNames.add( 153 emitter.interceptorEmitter.interceptorInvocationNames.add(
154 namer.setterForElement(fieldElement)); 154 namer.setterForElement(fieldElement));
155 } 155 }
156 156
157 int code = field.getterFlags + (field.setterFlags << 2); 157 int code = field.getterFlags + (field.setterFlags << 2);
158 if (code == 0) { 158 if (code == 0) {
159 compiler.internalError(fieldElement, 159 reporter.internalError(fieldElement,
160 'Field code is 0 ($fieldElement).'); 160 'Field code is 0 ($fieldElement).');
161 } 161 }
162 fieldNameParts.add( 162 fieldNameParts.add(
163 js.stringPart(FIELD_CODE_CHARACTERS[code - FIRST_FIELD_CODE])); 163 js.stringPart(FIELD_CODE_CHARACTERS[code - FIRST_FIELD_CODE]));
164 } 164 }
165 // Fields can only be reflected if their declaring class is reflectable 165 // Fields can only be reflected if their declaring class is reflectable
166 // (as they are only accessible via [ClassMirror.declarations]). 166 // (as they are only accessible via [ClassMirror.declarations]).
167 // However, set/get operations can be performed on them, so they are 167 // However, set/get operations can be performed on them, so they are
168 // reflectable in some sense, which leads to [isAccessibleByReflection] 168 // reflectable in some sense, which leads to [isAccessibleByReflection]
169 // reporting `true`. 169 // reporting `true`.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 } 206 }
207 207
208 /// Emits getters/setters for fields if compiling in CSP mode. 208 /// Emits getters/setters for fields if compiling in CSP mode.
209 void emitClassGettersSettersForCSP(Class cls, ClassBuilder builder) { 209 void emitClassGettersSettersForCSP(Class cls, ClassBuilder builder) {
210 210
211 if (!compiler.useContentSecurityPolicy || cls.onlyForRti) return; 211 if (!compiler.useContentSecurityPolicy || cls.onlyForRti) return;
212 212
213 for (Field field in cls.fields) { 213 for (Field field in cls.fields) {
214 Element member = field.element; 214 Element member = field.element;
215 compiler.withCurrentElement(member, () { 215 reporter.withCurrentElement(member, () {
216 if (field.needsGetter) { 216 if (field.needsGetter) {
217 emitGetterForCSP(member, field.name, field.accessorName, builder); 217 emitGetterForCSP(member, field.name, field.accessorName, builder);
218 } 218 }
219 if (field.needsUncheckedSetter) { 219 if (field.needsUncheckedSetter) {
220 emitSetterForCSP(member, field.name, field.accessorName, builder); 220 emitSetterForCSP(member, field.name, field.accessorName, builder);
221 } 221 }
222 }); 222 });
223 } 223 }
224 } 224 }
225 225
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 : new Selector.setter( 427 : new Selector.setter(
428 new Name(member.name, member.library, isSetter: true)); 428 new Name(member.name, member.library, isSetter: true));
429 String reflectionName = emitter.getReflectionName(selector, name); 429 String reflectionName = emitter.getReflectionName(selector, name);
430 if (reflectionName != null) { 430 if (reflectionName != null) {
431 var reflectable = 431 var reflectable =
432 js(backend.isAccessibleByReflection(member) ? '1' : '0'); 432 js(backend.isAccessibleByReflection(member) ? '1' : '0');
433 builder.addPropertyByName('+$reflectionName', reflectable); 433 builder.addPropertyByName('+$reflectionName', reflectable);
434 } 434 }
435 } 435 }
436 } 436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698