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

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

Issue 10832203: Refactor Library/CompilationUnit and how we define local Scope. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Last test fixes, passes co19. 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
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 9853fa87d9eb8e195969797c190b654d2c844ff9..37b3d9d7cc019c0f9b5d47714bd24eca0462dfb7 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -445,7 +445,7 @@ class Compiler implements DiagnosticListener {
// take advantage of this as core and coreimpl import js_helper
// and see Dynamic this way.
withCurrentElement(dynamicClass, () {
- library.define(dynamicClass, this);
+ library.addToScope(dynamicClass, this);
});
}
}
@@ -524,19 +524,20 @@ class Compiler implements DiagnosticListener {
}
void applyLibraryPatch(LibraryElement original, LibraryElement patch) {
- Link<Element> patches = patch.topLevelElements;
- applyContainerPatch(original, patches, original.findLocal);
+ Link<Element> patches = patch.localMembers;
+ applyContainerPatch(original, patches);
// Copy imports from patch to original library.
Map<String, LibraryElement> delayedPatches = <LibraryElement>{};
- Uri patchBase = patch.script.uri;
+ Uri patchBase = patch.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);
+ scanner.importLibrary(original, importedLibrary, tag,
+ patch.entryCompilationUnit);
if (resolved.scheme == "dart") {
delayedPatches[resolved.path] = importedLibrary;
}
@@ -553,11 +554,11 @@ class Compiler implements DiagnosticListener {
});
}
- void applyContainerPatch(ContainerElement original, Link<Element> patches,
- Element lookup(SourceString name)) {
+ void applyContainerPatch(ScopeContainerElement original,
+ Link<Element> patches) {
while (!patches.isEmpty()) {
Element patchElement = patches.head;
- Element originalElement = lookup(patchElement.name);
+ Element originalElement = original.localLookup(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
@@ -578,7 +579,7 @@ class Compiler implements DiagnosticListener {
this);
if (originalField === null && patchField.setter !== null) {
// It exists now, so find it for the setter patching.
- originalField = lookup(patchElement.name);
+ originalField = original.localLookup(patchElement.name);
}
} else {
patchMember(originalField.getter, patchField.getter);
@@ -689,13 +690,8 @@ class Compiler implements DiagnosticListener {
ClassNode node = original.parseNode(this);
// Parse patch class with "patch" parser.
ClassNode patchNode = patchParser.parsePatchClassNode(patch);
- 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);
+ Link<Element> patches = patch.localMembers;
+ applyContainerPatch(original, patches);
}
/**
@@ -706,17 +702,17 @@ class Compiler implements DiagnosticListener {
/** Define the JS helper functions in the given library. */
void addForeignFunctions(LibraryElement library) {
- library.define(new ForeignElement(
+ library.addToScope(new ForeignElement(
const SourceString('JS'), library), this);
- library.define(new ForeignElement(
+ library.addToScope(new ForeignElement(
const SourceString('UNINTERCEPTED'), library), this);
- library.define(new ForeignElement(
+ library.addToScope(new ForeignElement(
const SourceString('JS_HAS_EQUALS'), library), this);
- library.define(new ForeignElement(
+ library.addToScope(new ForeignElement(
const SourceString('JS_CURRENT_ISOLATE'), library), this);
- library.define(new ForeignElement(
+ library.addToScope(new ForeignElement(
const SourceString('JS_CALL_IN_ISOLATE'), library), this);
- library.define(new ForeignElement(
+ library.addToScope(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') | lib/compiler/implementation/elements/elements.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698