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

Unified Diff: lib/src/codegen/js_field_storage.dart

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/codegen/js_interop.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_field_storage.dart
diff --git a/lib/src/codegen/js_field_storage.dart b/lib/src/codegen/js_field_storage.dart
deleted file mode 100644
index 88de7584d06e808c49827c0122d7ae7325909c32..0000000000000000000000000000000000000000
--- a/lib/src/codegen/js_field_storage.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:collection' show HashMap, HashSet;
-import 'package:analyzer/dart/ast/ast.dart' show Identifier;
-import 'package:analyzer/dart/element/element.dart';
-
-import 'js_codegen.dart' show ExtensionTypeSet;
-
-/// We use a storage slot for fields that override or can be overridden by
-/// getter/setter pairs.
-HashSet<FieldElement> findFieldsNeedingStorage(
- Iterable<CompilationUnitElement> units, ExtensionTypeSet extensionTypes) {
- var overrides = new HashSet<FieldElement>();
- for (var unit in units) {
- for (var cls in unit.types) {
- var superclasses = getSuperclasses(cls);
- for (var field in cls.fields) {
- if (!field.isSynthetic && !overrides.contains(field)) {
- checkForPropertyOverride(
- field, superclasses, overrides, extensionTypes);
- }
- }
- }
- }
-
- return overrides;
-}
-
-void checkForPropertyOverride(
- FieldElement field,
- List<ClassElement> superclasses,
- HashSet<FieldElement> overrides,
- ExtensionTypeSet extensionTypes) {
- assert(!field.isSynthetic);
-
- var library = field.library;
-
- bool found = false;
- for (var superclass in superclasses) {
- var superprop = getProperty(superclass, library, field.name);
- if (superprop != null) {
- // If we find an abstract getter/setter pair, stop the search.
- var getter = superprop.getter;
- var setter = superprop.setter;
- if (!extensionTypes.contains(superclass) &&
- (getter == null || getter.isAbstract) &&
- (setter == null || setter.isAbstract)) {
- break;
- }
-
- found = true;
- // Record that the super property is overridden.
- if (superprop.library == library) overrides.add(superprop);
- }
- }
-
- // If this we found a super property, then this property overrides it.
- if (found) overrides.add(field);
-}
-
-FieldElement getProperty(
- ClassElement cls, LibraryElement fromLibrary, String name) {
- // Properties from a different library are not accessible.
- if (Identifier.isPrivateName(name) && cls.library != fromLibrary) {
- return null;
- }
- for (var accessor in cls.accessors) {
- var prop = accessor.variable;
- if (prop.name == name) return prop;
- }
- return null;
-}
-
-List<ClassElement> getSuperclasses(ClassElement cls) {
- var result = <ClassElement>[];
- var visited = new HashSet<ClassElement>();
- while (cls != null && visited.add(cls)) {
- for (var mixinType in cls.mixins.reversed) {
- var mixin = mixinType.element;
- if (mixin != null) result.add(mixin);
- }
- var supertype = cls.supertype;
- if (supertype == null) break;
-
- cls = supertype.element;
- result.add(cls);
- }
- return result;
-}
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/codegen/js_interop.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698