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

Unified Diff: dart/frog/leg/compiler.dart

Issue 9373043: Move helpers and interceptors to own library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 | dart/frog/leg/lib/core.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/compiler.dart
diff --git a/dart/frog/leg/compiler.dart b/dart/frog/leg/compiler.dart
index 57de705348fe6f582282cab5613c00754562a02b..5f1003540d71a67580d9e4366916c7332afcefb8 100644
--- a/dart/frog/leg/compiler.dart
+++ b/dart/frog/leg/compiler.dart
@@ -47,6 +47,8 @@ class Compiler implements DiagnosticListener {
CompilerTask measuredTask;
Element _currentElement;
LibraryElement coreLibrary;
+ LibraryElement coreImplLibrary;
+ LibraryElement jsHelperLibrary;
LibraryElement mainApp;
Element get currentElement() => _currentElement;
@@ -143,20 +145,25 @@ class Compiler implements DiagnosticListener {
return true;
}
- void scanCoreLibrary() {
- String fileName = io.join([legDirectory, 'lib', 'core.dart']);
+ LibraryElement scanBuiltinLibrary(String filename) {
+ String fileName = io.join([legDirectory, 'lib', filename]);
Uri cwd = new Uri(scheme: 'file', path: currentDirectory);
Uri uri = cwd.resolve(fileName);
- Script script = readScript(uri);
- coreLibrary = new LibraryElement(script);
- withCurrentElement(coreLibrary, () => scanner.scan(currentElement));
+ LibraryElement library = scanner.loadLibrary(uri, null);
// Make our special function a foreign kind.
- coreLibrary.define(new ForeignElement(
- const SourceString('JS'), coreLibrary), this);
- coreLibrary.define(new ForeignElement(
- const SourceString('UNINTERCEPTED'), coreLibrary), this);
- coreLibrary.define(new ForeignElement(
- const SourceString('JS_HAS_EQUALS'), coreLibrary), this);
+ library.define(new ForeignElement(
+ const SourceString('JS'), library), this);
+ library.define(new ForeignElement(
+ const SourceString('UNINTERCEPTED'), library), this);
+ library.define(new ForeignElement(
+ const SourceString('JS_HAS_EQUALS'), library), this);
ngeoffray 2012/02/10 08:51:44 We're defining those guys in all (core, coreimpl,
ahe 2012/02/14 12:55:26 It's not immediately obvious how to do so. I'll tr
+ return library;
+ }
+
+ void scanBuiltinLibraries() {
+ coreLibrary = scanBuiltinLibrary('core.dart');
+ coreImplLibrary = scanBuiltinLibrary('coreimpl.dart');
+ jsHelperLibrary = scanBuiltinLibrary('js_helper.dart');
// TODO(ngeoffray): Lazily add this method.
universe.invokedNames[NO_SUCH_METHOD] =
new Set<Invocation>.from(<Invocation>[new Invocation(2)]);
@@ -199,7 +206,7 @@ class Compiler implements DiagnosticListener {
}
void runCompiler(Script script) {
- scanCoreLibrary();
+ scanBuiltinLibraries();
mainApp = new LibraryElement(script);
Element element;
withCurrentElement(mainApp, () {
@@ -313,6 +320,8 @@ class Compiler implements DiagnosticListener {
String get legDirectory() {
unimplemented('Compiler.legDirectory');
}
+
+ Element findHelper(SourceString name) => jsHelperLibrary.find(name);
}
class CompilerTask {
« no previous file with comments | « no previous file | dart/frog/leg/lib/core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698