| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** The one true [World]. */ | 5 /** The one true [World]. */ |
| 6 World world; | 6 World world; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Should be called exactly once to setup singleton world. | 9 * Should be called exactly once to setup singleton world. |
| 10 * Can use world.reset() to reinitialize. | 10 * Can use world.reset() to reinitialize. |
| 11 */ | 11 */ |
| 12 void initializeWorld(FileSystem files) { | 12 void initializeWorld(FileSystem files) { |
| 13 assert(world == null); | 13 assert(world == null); |
| 14 world = new World(files); | 14 world = new World(files); |
| 15 world.init(); | 15 world.init(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Compiles the [target] dart file using the given [corelib]. | 19 * Compiles the [target] dart file using the given [corelib]. |
| 20 */ | 20 */ |
| 21 bool compile(String homedir, List<String> args, FileSystem files) { | 21 bool compile(String homedir, List<String> args, FileSystem files) { |
| 22 parseOptions(homedir, args); | 22 parseOptions(homedir, args, files); |
| 23 initializeWorld(files); | 23 initializeWorld(files); |
| 24 | 24 |
| 25 var success = world.compile(); | 25 var success = world.compile(); |
| 26 if (options.outfile != null) { | 26 if (options.outfile != null) { |
| 27 if (success) { | 27 if (success) { |
| 28 var code = world.getGeneratedCode(); | 28 var code = world.getGeneratedCode(); |
| 29 if (!options.outfile.endsWith('.js')) { | 29 if (!options.outfile.endsWith('.js')) { |
| 30 // Add in #! to invoke node.js on files with non-js extensions | 30 // Add in #! to invoke node.js on files with non-js extensions |
| 31 code = '#!/usr/bin/env node\n' + code; | 31 code = '#!/usr/bin/env node\n' + code; |
| 32 } | 32 } |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 withTiming(String name, f()) { | 422 withTiming(String name, f()) { |
| 423 final sw = new StopWatch(); | 423 final sw = new StopWatch(); |
| 424 sw.start(); | 424 sw.start(); |
| 425 var result = f(); | 425 var result = f(); |
| 426 sw.stop(); | 426 sw.stop(); |
| 427 info('$name in ${sw.elapsedInMs()}msec'); | 427 info('$name in ${sw.elapsedInMs()}msec'); |
| 428 return result; | 428 return result; |
| 429 } | 429 } |
| 430 } | 430 } |
| OLD | NEW |