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

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

Issue 2791263005: Split MirrorsData methods and MirrorsDataImpl data by element kind. (Closed)
Patch Set: Updated cf. comments. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
index c4f75757f2a7f378eb0765821c989dc3e45f2ab2..1e41000ef123e93a06de7fd4e628ab7631b752a1 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
@@ -9,7 +9,7 @@ import '../../common/names.dart' show Names;
import '../../elements/resolution_types.dart' show ResolutionDartType;
import '../../deferred_load.dart' show OutputUnit;
import '../../elements/elements.dart'
- show ClassElement, Element, FieldElement, MemberElement, Name;
+ show ClassElement, FieldElement, MemberElement, Name;
import '../../js/js.dart' as jsAst;
import '../../js/js.dart' show js;
import '../../js_backend/js_backend.dart' show CompoundName, Namer;
@@ -140,7 +140,7 @@ class ClassEmitter extends CodeEmitterHelper {
bool needsFieldsForConstructor = !emitStatics && !classIsNative;
if (needsFieldsForConstructor || needsAccessor) {
var metadata =
- task.metadataCollector.buildMetadataFunction(fieldElement);
+ task.metadataCollector.buildFieldMetadataFunction(fieldElement);
if (metadata != null) {
hasMetadata = true;
} else {
@@ -187,11 +187,11 @@ class ClassEmitter extends CodeEmitterHelper {
// However, set/get operations can be performed on them, so they are
// reflectable in some sense, which leads to [isAccessibleByReflection]
// reporting `true`.
- if (backend.mirrorsData.isAccessibleByReflection(fieldElement)) {
+ if (backend.mirrorsData.isMemberAccessibleByReflection(fieldElement)) {
fieldNameParts.add(new jsAst.LiteralString('-'));
if (fieldElement.isTopLevel ||
backend.mirrorsData
- .isAccessibleByReflection(fieldElement.enclosingClass)) {
+ .isClassAccessibleByReflection(fieldElement.enclosingClass)) {
ResolutionDartType type = fieldElement.type;
fieldNameParts.add(task.metadataCollector.reifyType(type));
}
@@ -304,12 +304,13 @@ class ClassEmitter extends CodeEmitterHelper {
ClassElement classElement = cls.element;
jsAst.Name className = cls.name;
- var metadata = task.metadataCollector.buildMetadataFunction(classElement);
+ var metadata =
+ task.metadataCollector.buildClassMetadataFunction(classElement);
if (metadata != null) {
classBuilder.addPropertyByName("@", metadata);
}
- if (backend.mirrorsData.isAccessibleByReflection(classElement)) {
+ if (backend.mirrorsData.isClassAccessibleByReflection(classElement)) {
List<ResolutionDartType> typeVars = classElement.typeVariables;
Iterable typeVariableProperties =
emitter.typeVariableCodegenAnalysis.typeVariablesOf(classElement);
@@ -356,7 +357,7 @@ class ClassEmitter extends CodeEmitterHelper {
String reflectionName = emitter.getReflectionName(classElement, className);
if (reflectionName != null) {
- if (!backend.mirrorsData.isAccessibleByReflection(classElement) ||
+ if (!backend.mirrorsData.isClassAccessibleByReflection(classElement) ||
cls.onlyForRti) {
// TODO(herhut): Fix use of reflection name here.
enclosingBuilder.addPropertyByName("+$reflectionName", js.number(0));
@@ -376,7 +377,7 @@ class ClassEmitter extends CodeEmitterHelper {
}
void recordMangledField(
- Element member, jsAst.Name accessorName, String memberName) {
+ FieldElement member, jsAst.Name accessorName, String memberName) {
if (!backend.mirrorsData.shouldRetainGetter(member)) return;
String previousName;
if (member.isInstanceMember) {
@@ -403,7 +404,7 @@ class ClassEmitter extends CodeEmitterHelper {
emitter
.cspPrecompiledFunctionFor(outputUnit)
.add(js('#.prototype.# = #', [className, getterName, function]));
- if (backend.mirrorsData.isAccessibleByReflection(member)) {
+ if (backend.mirrorsData.isMemberAccessibleByReflection(member)) {
emitter.cspPrecompiledFunctionFor(outputUnit).add(js(
'#.prototype.#.${namer.reflectableField} = 1',
[className, getterName]));
@@ -423,7 +424,7 @@ class ClassEmitter extends CodeEmitterHelper {
emitter
.cspPrecompiledFunctionFor(outputUnit)
.add(js('#.prototype.# = #', [className, setterName, function]));
- if (backend.mirrorsData.isAccessibleByReflection(member)) {
+ if (backend.mirrorsData.isMemberAccessibleByReflection(member)) {
emitter.cspPrecompiledFunctionFor(outputUnit).add(js(
'#.prototype.#.${namer.reflectableField} = 1',
[className, setterName]));
@@ -431,7 +432,7 @@ class ClassEmitter extends CodeEmitterHelper {
}
void generateReflectionDataForFieldGetterOrSetter(
- Element member, jsAst.Name name, ClassBuilder builder,
+ MemberElement member, jsAst.Name name, ClassBuilder builder,
{bool isGetter}) {
Selector selector = isGetter
? new Selector.getter(new Name(member.name, member.library))
@@ -439,8 +440,10 @@ class ClassEmitter extends CodeEmitterHelper {
new Name(member.name, member.library, isSetter: true));
String reflectionName = emitter.getReflectionName(selector, name);
if (reflectionName != null) {
- var reflectable =
- js(backend.mirrorsData.isAccessibleByReflection(member) ? '1' : '0');
+ var reflectable = js(
+ backend.mirrorsData.isMemberAccessibleByReflection(member)
+ ? '1'
+ : '0');
builder.addPropertyByName('+$reflectionName', reflectable);
}
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/type_variable_handler.dart ('k') | pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698