| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 /** The entry point for the command-line version analyzer2dart. */ | |
| 6 library analyzer2dart.cmdline; | |
| 7 | |
| 8 import 'dart:io'; | |
| 9 | |
| 10 import 'package:analyzer/file_system/physical_file_system.dart'; | |
| 11 import 'package:analyzer/src/generated/element.dart'; | |
| 12 import 'package:analyzer/src/generated/sdk.dart'; | |
| 13 import 'package:analyzer/src/generated/sdk_io.dart'; | |
| 14 import 'package:analyzer/src/generated/source_io.dart'; | |
| 15 import 'package:compiler/src/source_file_provider.dart'; | |
| 16 | |
| 17 import '../lib/src/closed_world.dart'; | |
| 18 import '../lib/src/driver.dart'; | |
| 19 import '../lib/src/converted_world.dart'; | |
| 20 import '../lib/src/dart_backend.dart'; | |
| 21 | |
| 22 void main(List<String> args) { | |
| 23 // TODO(paulberry): hacky | |
| 24 String path = args[0]; | |
| 25 | |
| 26 PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE; | |
| 27 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; | |
| 28 // TODO(johnniwinther): Support user specified output Uri. | |
| 29 // TODO(johnniwinther): Integrate messaging. | |
| 30 RandomAccessFileOutputProvider outputProvider = | |
| 31 new RandomAccessFileOutputProvider( | |
| 32 Uri.base.resolve('out.dart'), | |
| 33 Uri.base.resolve('out.dart.map'), | |
| 34 onInfo: (message) => print(message), | |
| 35 onFailure: (message) { | |
| 36 print(message); | |
| 37 exit(1); | |
| 38 }); | |
| 39 | |
| 40 Driver analyzer2Dart = new Driver(provider, sdk, outputProvider); | |
| 41 | |
| 42 // Tell the analysis server about the root | |
| 43 Source source = analyzer2Dart.setRoot(path); | |
| 44 | |
| 45 // Get the library element associated with the source. | |
| 46 FunctionElement entryPointElement = analyzer2Dart.resolveEntryPoint(source); | |
| 47 | |
| 48 // TODO(brianwilkerson,paulberry,johnniwinther): Perform tree-growing by | |
| 49 // visiting the ast and feeding the dependencies into a work queue (enqueuer). | |
| 50 ClosedWorld world = analyzer2Dart.computeWorld(entryPointElement); | |
| 51 | |
| 52 // TODO(brianwilkerson,paulberry,johnniwinther): Convert the ast into cps by | |
| 53 // visiting the ast and invoking the ir builder. | |
| 54 // TODO(johnniwinther): Convert the analyzer element model into the dart2js | |
| 55 // element model to fit the needs of the cps encoding above. | |
| 56 ConvertedWorld convertedWorld = convertWorld(world); | |
| 57 | |
| 58 // TODO(johnniwinther): Feed the cps ir into the new dart2dart backend to | |
| 59 // generate dart file(s). | |
| 60 compileToDart(analyzer2Dart, convertedWorld); | |
| 61 } | |
| 62 | |
| OLD | NEW |