| 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 import "package:async_helper/async_helper.dart"; | 11 import "package:async_helper/async_helper.dart"; |
| 12 | 12 |
| 13 import '../../sdk/lib/_internal/compiler/compiler.dart'; | 13 import '../../sdk/lib/_internal/compiler/compiler.dart'; |
| 14 | 14 |
| 15 Future<String> provider(Uri uri) { | 15 Future<String> provider(Uri uri) { |
| 16 String source; | 16 String source; |
| 17 if (uri.scheme == "main") { | 17 if (uri.scheme == "main") { |
| 18 source = "main() {}"; | 18 source = "main() {}"; |
| 19 } else if (uri.scheme == "lib") { | 19 } else if (uri.scheme == "lib") { |
| 20 if (uri.path.endsWith("/core.dart")) { | 20 if (uri.path.endsWith("/core.dart")) { |
| 21 source = """ | 21 source = """ |
| 22 library core; | 22 library core; |
| 23 class Object { | 23 class Object { |
| 24 Object(); | 24 Object(); |
| 25 // Note: JSNull below must reimplement all members. |
| 25 operator==(other) {} | 26 operator==(other) {} |
| 26 get hashCode => throw 'Object.hashCode not implemented.'; | 27 get hashCode => throw 'Object.hashCode not implemented.'; |
| 27 } | 28 } |
| 28 class Type {} | 29 class Type {} |
| 29 class bool {} | 30 class bool {} |
| 30 class num {} | 31 class num {} |
| 31 class int {} | 32 class int {} |
| 32 class double{} | 33 class double{} |
| 33 class String{} | 34 class String{} |
| 34 class Function{} | 35 class Function{} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 var toString; | 78 var toString; |
| 78 get length => 0; | 79 get length => 0; |
| 79 } | 80 } |
| 80 class JSFunction {} | 81 class JSFunction {} |
| 81 class JSInt {} | 82 class JSInt {} |
| 82 class JSPositiveInt {} | 83 class JSPositiveInt {} |
| 83 class JSUInt31 {} | 84 class JSUInt31 {} |
| 84 class JSUInt32 {} | 85 class JSUInt32 {} |
| 85 class JSDouble {} | 86 class JSDouble {} |
| 86 class JSNumber {} | 87 class JSNumber {} |
| 87 class JSNull {} | 88 class JSNull { |
| 89 bool operator ==(other) => identical(null, other); |
| 90 int get hashCode => 0; |
| 91 } |
| 88 class JSBool {} | 92 class JSBool {} |
| 89 getInterceptor(o){} | 93 getInterceptor(o){} |
| 90 getDispatchProperty(o) {} | 94 getDispatchProperty(o) {} |
| 91 setDispatchProperty(o, v) {} | 95 setDispatchProperty(o, v) {} |
| 92 var mapTypeToInterceptor;"""; | 96 var mapTypeToInterceptor;"""; |
| 93 } else if (uri.path.endsWith('js_helper.dart')) { | 97 } else if (uri.path.endsWith('js_helper.dart')) { |
| 94 source = 'library jshelper; class JSInvocationMirror {} ' | 98 source = 'library jshelper; class JSInvocationMirror {} ' |
| 95 'class ConstantMap {} class TypeImpl {} ' | 99 'class ConstantMap {} class TypeImpl {} ' |
| 96 'createRuntimeType(String name) => null;'; | 100 'createRuntimeType(String name) => null;'; |
| 97 } else if (uri.path.endsWith('isolate_helper.dart')) { | 101 } else if (uri.path.endsWith('isolate_helper.dart')) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 121 new Uri(scheme: 'package', path: '/'), | 125 new Uri(scheme: 'package', path: '/'), |
| 122 provider, handler); | 126 provider, handler); |
| 123 result.then((String code) { | 127 result.then((String code) { |
| 124 if (code == null) { | 128 if (code == null) { |
| 125 throw 'Compilation failed'; | 129 throw 'Compilation failed'; |
| 126 } | 130 } |
| 127 }, onError: (e) { | 131 }, onError: (e) { |
| 128 throw 'Compilation failed'; | 132 throw 'Compilation failed'; |
| 129 }).then(asyncSuccess); | 133 }).then(asyncSuccess); |
| 130 } | 134 } |
| OLD | NEW |