OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // VMOptions= | 4 // VMOptions= |
5 // VMOptions=--print-object-histogram | 5 // VMOptions=--print-object-histogram |
6 | 6 |
7 // Smoke test of the dart2js compiler API. | 7 // Smoke test of the dart2js compiler API. |
8 library dummy_compiler; | 8 library dummy_compiler; |
9 | 9 |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 getDispatchProperty(o) {} | 78 getDispatchProperty(o) {} |
79 setDispatchProperty(o, v) {} | 79 setDispatchProperty(o, v) {} |
80 var mapTypeToInterceptor;"""; | 80 var mapTypeToInterceptor;"""; |
81 } else if (uri.path.endsWith('js_helper.dart')) { | 81 } else if (uri.path.endsWith('js_helper.dart')) { |
82 source = 'library jshelper; class JSInvocationMirror {} ' | 82 source = 'library jshelper; class JSInvocationMirror {} ' |
83 'class ConstantMap {} class TypeImpl {} ' | 83 'class ConstantMap {} class TypeImpl {} ' |
84 'createRuntimeType(String name) => null;'; | 84 'createRuntimeType(String name) => null;'; |
85 } else if (uri.path.endsWith('isolate_helper.dart')) { | 85 } else if (uri.path.endsWith('isolate_helper.dart')) { |
86 source = 'library isolatehelper; class _WorkerStub {}'; | 86 source = 'library isolatehelper; class _WorkerStub {}'; |
87 } else { | 87 } else { |
88 source = "library lib;"; | 88 source = "library lib${uri.path.replaceAll('/', '.')};"; |
89 } | 89 } |
90 } else { | 90 } else { |
91 throw "unexpected URI $uri"; | 91 throw "unexpected URI $uri"; |
92 } | 92 } |
93 return new Future.value(source); | 93 return new Future.value(source); |
94 } | 94 } |
95 | 95 |
96 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 96 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
97 if (uri == null) { | 97 if (uri == null) { |
98 print('$kind: $message'); | 98 print('$kind: $message'); |
99 } else { | 99 } else { |
100 print('$uri:$begin:$end: $kind: $message'); | 100 print('$uri:$begin:$end: $kind: $message'); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 main() { | 104 main() { |
105 Future<String> result = | 105 Future<String> result = |
106 compile(new Uri(scheme: 'main'), | 106 compile(new Uri(scheme: 'main'), |
107 new Uri(scheme: 'lib', path: '/'), | 107 new Uri(scheme: 'lib', path: '/'), |
108 new Uri(scheme: 'package', path: '/'), | 108 new Uri(scheme: 'package', path: '/'), |
109 provider, handler); | 109 provider, handler); |
110 result.then((String code) { | 110 result.then((String code) { |
111 if (code == null) { | 111 if (code == null) { |
112 throw 'Compilation failed'; | 112 throw 'Compilation failed'; |
113 } | 113 } |
114 }, onError: (e) { | 114 }, onError: (e) { |
115 throw 'Compilation failed'; | 115 throw 'Compilation failed'; |
116 }); | 116 }); |
117 } | 117 } |
OLD | NEW |