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

Unified Diff: lib/compiler/implementation/compiler.dart

Issue 10824275: Revert "Refactor Library/CompilationUnit and how we define local Scope." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 823f55983f74436cd8853af39455228f180d53d1..69234fe7f8c32557ec96fb69ee1ee7501d6430ed 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -291,7 +291,7 @@ class Compiler implements DiagnosticListener {
// take advantage of this as core and coreimpl import js_helper
// and see Dynamic this way.
withCurrentElement(dynamicClass, () {
- library.addToScope(dynamicClass, this);
+ library.define(dynamicClass, this);
});
}
}
@@ -370,20 +370,19 @@ class Compiler implements DiagnosticListener {
}
void applyLibraryPatch(LibraryElement original, LibraryElement patch) {
- Link<Element> patches = patch.localMembers;
- applyContainerPatch(original, patches);
+ Link<Element> patches = patch.topLevelElements;
+ applyContainerPatch(original, patches, original.findLocal);
// Copy imports from patch to original library.
Map<String, LibraryElement> delayedPatches = <LibraryElement>{};
- Uri patchBase = patch.uri;
+ Uri patchBase = patch.script.uri;
for (ScriptTag tag in patch.tags.reverse()) {
if (tag.isImport()) {
StringNode argument = tag.argument;
Uri resolved = patchBase.resolve(argument.dartString.slowToString());
LibraryElement importedLibrary =
scanner.loadLibrary(resolved, argument);
- scanner.importLibrary(original, importedLibrary, tag,
- patch.entryCompilationUnit);
+ scanner.importLibrary(original, importedLibrary, tag, patch);
if (resolved.scheme == "dart") {
delayedPatches[resolved.path] = importedLibrary;
}
@@ -400,11 +399,11 @@ class Compiler implements DiagnosticListener {
});
}
- void applyContainerPatch(ScopeContainerElement original,
- Link<Element> patches) {
+ void applyContainerPatch(ContainerElement original, Link<Element> patches,
+ Element lookup(SourceString name)) {
while (!patches.isEmpty()) {
Element patchElement = patches.head;
- Element originalElement = original.localLookup(patchElement.name);
+ Element originalElement = lookup(patchElement.name);
if (patchElement.isAccessor()) {
// Skip accessors. An accessor always has an abstract field,
// representing the accessor in the lookup scope. We can thus skip the
@@ -425,7 +424,7 @@ class Compiler implements DiagnosticListener {
this);
if (originalField === null && patchField.setter !== null) {
// It exists now, so find it for the setter patching.
- originalField = original.localLookup(patchElement.name);
+ originalField = lookup(patchElement.name);
}
} else {
patchMember(originalField.getter, patchField.getter);
@@ -536,8 +535,13 @@ class Compiler implements DiagnosticListener {
ClassNode node = original.parseNode(this);
// Parse patch class with "patch" parser.
ClassNode patchNode = patchParser.parsePatchClassNode(patch);
- Link<Element> patches = patch.localMembers;
- applyContainerPatch(original, patches);
+ Link<Element> patches = patch.members;
+ Element lookupMemberOrConstructor(SourceString name) {
+ Element result = original.lookupLocalMember(name);
+ if (result !== null) return result;
+ return original.lookupConstructor(name);
+ }
+ applyContainerPatch(original, patches, lookupMemberOrConstructor);
}
/**
@@ -548,17 +552,17 @@ class Compiler implements DiagnosticListener {
/** Define the JS helper functions in the given library. */
void addForeignFunctions(LibraryElement library) {
- library.addToScope(new ForeignElement(
+ library.define(new ForeignElement(
const SourceString('JS'), library), this);
- library.addToScope(new ForeignElement(
+ library.define(new ForeignElement(
const SourceString('UNINTERCEPTED'), library), this);
- library.addToScope(new ForeignElement(
+ library.define(new ForeignElement(
const SourceString('JS_HAS_EQUALS'), library), this);
- library.addToScope(new ForeignElement(
+ library.define(new ForeignElement(
const SourceString('JS_CURRENT_ISOLATE'), library), this);
- library.addToScope(new ForeignElement(
+ library.define(new ForeignElement(
const SourceString('JS_CALL_IN_ISOLATE'), library), this);
- library.addToScope(new ForeignElement(
+ library.define(new ForeignElement(
const SourceString('DART_CLOSURE_TO_JS'), library), this);
}
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698