| 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'; |
| 11 | 11 |
| 12 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 12 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
| 13 | 13 |
| 14 Future<String> provider(Uri uri) { | 14 Future<String> provider(Uri uri) { |
| 15 String source; | 15 String source; |
| 16 if (uri.scheme == "main") { | 16 if (uri.scheme == "main") { |
| 17 source = "main() {}"; | 17 source = "main() {}"; |
| 18 } else if (uri.scheme == "lib") { | 18 } else if (uri.scheme == "lib") { |
| 19 if (uri.path.endsWith("/core.dart")) { | 19 if (uri.path.endsWith("/core.dart")) { |
| 20 source = """library core; | 20 source = """ |
| 21 class Object { | 21 library core; |
| 22 operator==(other) {} | 22 class Object { |
| 23 } | 23 operator==(other) {} |
| 24 class Type {} | 24 get hashCode => throw 'Object.hashCode not implemented.'; |
| 25 class bool {} | 25 } |
| 26 class num {} | 26 class Type {} |
| 27 class int {} | 27 class bool {} |
| 28 class double{} | 28 class num {} |
| 29 class String{} | 29 class int {} |
| 30 class Function{} | 30 class double{} |
| 31 class List {} | 31 class String{} |
| 32 class Map {} | 32 class Function{} |
| 33 class Closure {} | 33 class List {} |
| 34 class BoundClosure {} | 34 class Map {} |
| 35 class Dynamic_ {} | 35 class Closure {} |
| 36 class Null {} | 36 class BoundClosure {} |
| 37 class StackTrace {} | 37 class Dynamic_ {} |
| 38 class LinkedHashMap {} | 38 class Null {} |
| 39 identical(a, b) => true; | 39 class StackTrace {} |
| 40 getRuntimeTypeInfo(o) {} | 40 class LinkedHashMap {} |
| 41 setRuntimeTypeInfo(o, i) {} | 41 identical(a, b) => true; |
| 42 eqNull(a) {} | 42 getRuntimeTypeInfo(o) {} |
| 43 eqNullB(a) {}"""; | 43 setRuntimeTypeInfo(o, i) {} |
| 44 eqNull(a) {} |
| 45 eqNullB(a) {}"""; |
| 44 } else if (uri.path.endsWith('_patch.dart')) { | 46 } else if (uri.path.endsWith('_patch.dart')) { |
| 45 source = ''; | 47 source = ''; |
| 46 } else if (uri.path.endsWith('interceptors.dart')) { | 48 } else if (uri.path.endsWith('interceptors.dart')) { |
| 47 source = """class Interceptor { | 49 source = """ |
| 48 operator==(other) {} | 50 class Interceptor { |
| 49 } | 51 operator==(other) {} |
| 50 class JSIndexable { | 52 get hashCode => throw 'Interceptor.hashCode not implemented.'; |
| 51 get length; | 53 } |
| 52 } | 54 class JSIndexable { |
| 53 class JSMutableIndexable {} | 55 get length; |
| 54 class JSArray implements JSIndexable { | 56 } |
| 55 var removeLast; | 57 class JSMutableIndexable {} |
| 56 var add; | 58 class JSArray implements JSIndexable { |
| 57 } | 59 var removeLast; |
| 58 class JSMutableArray extends JSArray {} | 60 var add; |
| 59 class JSFixedArray extends JSMutableArray {} | 61 } |
| 60 class JSExtendableArray extends JSMutableArray {} | 62 class JSMutableArray extends JSArray {} |
| 61 class JSString implements JSIndexable { | 63 class JSFixedArray extends JSMutableArray {} |
| 62 var split; | 64 class JSExtendableArray extends JSMutableArray {} |
| 63 var concat; | 65 class JSString implements JSIndexable { |
| 64 var toString; | 66 var split; |
| 65 } | 67 var concat; |
| 66 class JSFunction {} | 68 var toString; |
| 67 class JSInt {} | 69 } |
| 68 class JSDouble {} | 70 class JSFunction {} |
| 69 class JSNumber {} | 71 class JSInt {} |
| 70 class JSNull {} | 72 class JSDouble {} |
| 71 class JSBool {} | 73 class JSNumber {} |
| 72 getInterceptor(o){} | 74 class JSNull {} |
| 73 getDispatchProperty(o) {} | 75 class JSBool {} |
| 74 setDispatchProperty(o, v) {}"""; | 76 getInterceptor(o){} |
| 77 getDispatchProperty(o) {} |
| 78 setDispatchProperty(o, v) {}"""; |
| 75 } else if (uri.path.endsWith('js_helper.dart')) { | 79 } else if (uri.path.endsWith('js_helper.dart')) { |
| 76 source = 'library jshelper; class JSInvocationMirror {} ' | 80 source = 'library jshelper; class JSInvocationMirror {} ' |
| 77 'class ConstantMap {} class TypeImpl {}'; | 81 'class ConstantMap {} class TypeImpl {}'; |
| 78 } else if (uri.path.endsWith('isolate_helper.dart')) { | 82 } else if (uri.path.endsWith('isolate_helper.dart')) { |
| 79 source = 'library isolatehelper; class _WorkerStub {}'; | 83 source = 'library isolatehelper; class _WorkerStub {}'; |
| 80 } else { | 84 } else { |
| 81 source = "library lib;"; | 85 source = "library lib;"; |
| 82 } | 86 } |
| 83 } else { | 87 } else { |
| 84 throw "unexpected URI $uri"; | 88 throw "unexpected URI $uri"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 101 new Uri(scheme: 'package', path: '/'), | 105 new Uri(scheme: 'package', path: '/'), |
| 102 provider, handler); | 106 provider, handler); |
| 103 result.then((String code) { | 107 result.then((String code) { |
| 104 if (code == null) { | 108 if (code == null) { |
| 105 throw 'Compilation failed'; | 109 throw 'Compilation failed'; |
| 106 } | 110 } |
| 107 }, onError: (e) { | 111 }, onError: (e) { |
| 108 throw 'Compilation failed'; | 112 throw 'Compilation failed'; |
| 109 }); | 113 }); |
| 110 } | 114 } |
| OLD | NEW |