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