| 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 | 4 |
| 5 library mock_compiler; | 5 library mock_compiler; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:uri'; | 8 import 'dart:uri'; |
| 9 | 9 |
| 10 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; | 10 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 class Dynamic_ {} | 56 class Dynamic_ {} |
| 57 class LinkedHashMap {} | 57 class LinkedHashMap {} |
| 58 S() {} | 58 S() {} |
| 59 unwrapException(e) {} | 59 unwrapException(e) {} |
| 60 assertHelper(a){} | 60 assertHelper(a){} |
| 61 createRuntimeType(a) {} | 61 createRuntimeType(a) {} |
| 62 throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {} | 62 throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {} |
| 63 throwAbstractClassInstantiationError(className) {}'''; | 63 throwAbstractClassInstantiationError(className) {}'''; |
| 64 | 64 |
| 65 const String DEFAULT_INTERCEPTORSLIB = r''' | 65 const String DEFAULT_INTERCEPTORSLIB = r''' |
| 66 class JSArray { | 66 class JSArray implements List { |
| 67 var length; | 67 var length; |
| 68 operator[](index) {} | 68 operator[](index) {} |
| 69 operator[]=(index, value) {} | 69 operator[]=(index, value) {} |
| 70 var add; | 70 var add; |
| 71 } | 71 } |
| 72 class JSString { | 72 class JSString implements String { |
| 73 var length; | 73 var length; |
| 74 operator[](index) {} | 74 operator[](index) {} |
| 75 toString() {} | 75 toString() {} |
| 76 } | 76 } |
| 77 class JSNumber { | 77 class JSNumber implements num { |
| 78 // All these methods return a number to please type inferencing. | 78 // All these methods return a number to please type inferencing. |
| 79 operator-() => (this is JSInt) ? 42 : 42.0; | 79 operator-() => (this is JSInt) ? 42 : 42.0; |
| 80 operator +(other) => (this is JSInt) ? 42 : 42.0; | 80 operator +(other) => (this is JSInt) ? 42 : 42.0; |
| 81 operator -(other) => (this is JSInt) ? 42 : 42.0; | 81 operator -(other) => (this is JSInt) ? 42 : 42.0; |
| 82 operator ~/(other) => 42; | 82 operator ~/(other) => 42; |
| 83 operator /(other) => (this is JSInt) ? 42 : 42.0; | 83 operator /(other) => (this is JSInt) ? 42 : 42.0; |
| 84 operator *(other) => (this is JSInt) ? 42 : 42.0; | 84 operator *(other) => (this is JSInt) ? 42 : 42.0; |
| 85 operator %(other) => (this is JSInt) ? 42 : 42.0; | 85 operator %(other) => (this is JSInt) ? 42 : 42.0; |
| 86 operator <<(other) => 42; | 86 operator <<(other) => 42; |
| 87 operator >>(other) => 42; | 87 operator >>(other) => 42; |
| 88 operator |(other) => 42; | 88 operator |(other) => 42; |
| 89 operator &(other) => 42; | 89 operator &(other) => 42; |
| 90 operator ^(other) => 42; | 90 operator ^(other) => 42; |
| 91 | 91 |
| 92 operator >(other) => true; | 92 operator >(other) => true; |
| 93 operator >=(other) => true; | 93 operator >=(other) => true; |
| 94 operator <(other) => true; | 94 operator <(other) => true; |
| 95 operator <=(other) => true; | 95 operator <=(other) => true; |
| 96 operator ==(other) => true; | 96 operator ==(other) => true; |
| 97 } | 97 } |
| 98 class JSInt extends JSNumber { | 98 class JSInt extends JSNumber implements int { |
| 99 } | 99 } |
| 100 class JSDouble extends JSNumber { | 100 class JSDouble extends JSNumber implements double { |
| 101 } | 101 } |
| 102 class JSNull { | 102 class JSNull { |
| 103 } | 103 } |
| 104 class JSBool { | 104 class JSBool implements bool { |
| 105 } | 105 } |
| 106 class JSFunction { | 106 class JSFunction implements Function { |
| 107 } | 107 } |
| 108 class ObjectInterceptor { | 108 class ObjectInterceptor { |
| 109 } | 109 } |
| 110 getInterceptor(x) {}'''; | 110 getInterceptor(x) {}'''; |
| 111 | 111 |
| 112 const String DEFAULT_CORELIB = r''' | 112 const String DEFAULT_CORELIB = r''' |
| 113 print(var obj) {} | 113 print(var obj) {} |
| 114 abstract class num {} | 114 abstract class num {} |
| 115 abstract class int extends num { } | 115 abstract class int extends num { } |
| 116 abstract class double extends num { | 116 abstract class double extends num { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 sourceFiles = new Map<String, SourceFile>(), | 155 sourceFiles = new Map<String, SourceFile>(), |
| 156 super(enableTypeAssertions: enableTypeAssertions, | 156 super(enableTypeAssertions: enableTypeAssertions, |
| 157 enableMinification: enableMinification, | 157 enableMinification: enableMinification, |
| 158 enableConcreteTypeInference: enableConcreteTypeInference, | 158 enableConcreteTypeInference: enableConcreteTypeInference, |
| 159 maxConcreteTypeSize: maxConcreteTypeSize, | 159 maxConcreteTypeSize: maxConcreteTypeSize, |
| 160 analyzeAll: analyzeAll) { | 160 analyzeAll: analyzeAll) { |
| 161 coreLibrary = createLibrary("core", coreSource); | 161 coreLibrary = createLibrary("core", coreSource); |
| 162 // We need to set the assert method to avoid calls with a 'null' | 162 // We need to set the assert method to avoid calls with a 'null' |
| 163 // target being interpreted as a call to assert. | 163 // target being interpreted as a call to assert. |
| 164 jsHelperLibrary = createLibrary("helper", helperSource); | 164 jsHelperLibrary = createLibrary("helper", helperSource); |
| 165 importHelperLibrary(coreLibrary); | |
| 166 libraryLoader.importLibrary(jsHelperLibrary, coreLibrary, null); | |
| 167 | |
| 168 assertMethod = jsHelperLibrary.find(buildSourceString('assert')); | |
| 169 interceptorsLibrary = createLibrary("interceptors", interceptorsSource); | 165 interceptorsLibrary = createLibrary("interceptors", interceptorsSource); |
| 170 isolateHelperLibrary = createLibrary("isolate_helper", isolateHelperSource); | 166 isolateHelperLibrary = createLibrary("isolate_helper", isolateHelperSource); |
| 171 | 167 |
| 168 // Set up the library imports. |
| 169 importHelperLibrary(coreLibrary); |
| 170 libraryLoader.importLibrary(jsHelperLibrary, coreLibrary, null); |
| 171 libraryLoader.importLibrary(interceptorsLibrary, coreLibrary, null); |
| 172 libraryLoader.importLibrary(isolateHelperLibrary, coreLibrary, null); |
| 173 |
| 174 assertMethod = jsHelperLibrary.find(buildSourceString('assert')); |
| 175 |
| 172 mainApp = mockLibrary(this, ""); | 176 mainApp = mockLibrary(this, ""); |
| 173 initializeSpecialClasses(); | 177 initializeSpecialClasses(); |
| 174 // We need to make sure the Object class is resolved. When registering a | 178 // We need to make sure the Object class is resolved. When registering a |
| 175 // dynamic invocation the ArgumentTypesRegistry eventually iterates over | 179 // dynamic invocation the ArgumentTypesRegistry eventually iterates over |
| 176 // the interfaces of the Object class which would be 'null' if the class | 180 // the interfaces of the Object class which would be 'null' if the class |
| 177 // wasn't resolved. | 181 // wasn't resolved. |
| 178 objectClass.ensureResolved(this); | 182 objectClass.ensureResolved(this); |
| 179 | 183 |
| 180 // Our unit tests check code generation output that is affected by | 184 // Our unit tests check code generation output that is affected by |
| 181 // inlining support. | 185 // inlining support. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 363 } |
| 360 } | 364 } |
| 361 | 365 |
| 362 class MockDeferredLoadTask extends DeferredLoadTask { | 366 class MockDeferredLoadTask extends DeferredLoadTask { |
| 363 MockDeferredLoadTask(Compiler compiler) : super(compiler); | 367 MockDeferredLoadTask(Compiler compiler) : super(compiler); |
| 364 | 368 |
| 365 void registerMainApp(LibraryElement mainApp) { | 369 void registerMainApp(LibraryElement mainApp) { |
| 366 // Do nothing. | 370 // Do nothing. |
| 367 } | 371 } |
| 368 } | 372 } |
| OLD | NEW |