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

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

Issue 1149323008: Revert "dart2js: Do not emit type metadata for fields declared in non-reflectable classes." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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) 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; 5 part of dart2js.js_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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 int code = field.getterFlags + (field.setterFlags << 2); 156 int code = field.getterFlags + (field.setterFlags << 2);
157 if (code == 0) { 157 if (code == 0) {
158 compiler.internalError(fieldElement, 158 compiler.internalError(fieldElement,
159 'Field code is 0 ($fieldElement).'); 159 'Field code is 0 ($fieldElement).');
160 } else { 160 } else {
161 fieldCode = FIELD_CODE_CHARACTERS[code - FIRST_FIELD_CODE]; 161 fieldCode = FIELD_CODE_CHARACTERS[code - FIRST_FIELD_CODE];
162 } 162 }
163 } 163 }
164 // Fields can only be reflected if their declaring class is reflectable 164 if (backend.isAccessibleByReflection(fieldElement)) {
165 // (as they are only accessible via [ClassMirror.declarations]).
166 // However, set/get operations can be performed on them, so they are
167 // reflectable in some sense, which leads to [isAccessibleByReflection]
168 // reporting `true`.
169 if (backend.isAccessibleByReflection(fieldElement) &&
170 (fieldElement.isTopLevel ||
171 backend.isAccessibleByReflection(fieldElement.enclosingClass))) {
172 DartType type = fieldElement.type; 165 DartType type = fieldElement.type;
173 reflectionMarker = '-${task.metadataCollector.reifyType(type)}'; 166 reflectionMarker = '-${task.metadataCollector.reifyType(type)}';
174 } 167 }
175 String builtFieldname = '$fieldName$fieldCode$reflectionMarker'; 168 String builtFieldname = '$fieldName$fieldCode$reflectionMarker';
176 builder.addField(builtFieldname); 169 builder.addField(builtFieldname);
177 // Add 1 because adding a field to the class also requires a comma 170 // Add 1 because adding a field to the class also requires a comma
178 compiler.dumpInfoTask.recordFieldNameSize(fieldElement, 171 compiler.dumpInfoTask.recordFieldNameSize(fieldElement,
179 builtFieldname.length + 1); 172 builtFieldname.length + 1);
180 fieldsAdded = true; 173 fieldsAdded = true;
181 } 174 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 ? new Selector.getter(member.name, member.library) 546 ? new Selector.getter(member.name, member.library)
554 : new Selector.setter(member.name, member.library); 547 : new Selector.setter(member.name, member.library);
555 String reflectionName = emitter.getReflectionName(selector, name); 548 String reflectionName = emitter.getReflectionName(selector, name);
556 if (reflectionName != null) { 549 if (reflectionName != null) {
557 var reflectable = 550 var reflectable =
558 js(backend.isAccessibleByReflection(member) ? '1' : '0'); 551 js(backend.isAccessibleByReflection(member) ? '1' : '0');
559 builder.addProperty('+$reflectionName', reflectable); 552 builder.addProperty('+$reflectionName', reflectable);
560 } 553 }
561 } 554 }
562 } 555 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698