Chromium Code Reviews| 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 { |