| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library dart2js.js_backend.helpers; |
| 6 |
| 7 import '../common/resolution.dart' show |
| 8 Resolution; |
| 9 import '../compiler.dart' show |
| 10 Compiler; |
| 11 import '../elements/elements.dart' show |
| 12 ClassElement, |
| 13 Element, |
| 14 LibraryElement, |
| 15 MethodElement; |
| 16 |
| 17 import 'js_backend.dart'; |
| 18 |
| 19 /// Helper classes and functions for the JavaScript backend. |
| 20 class BackendHelpers { |
| 21 final Compiler compiler; |
| 22 |
| 23 Element cachedCheckConcurrentModificationError; |
| 24 |
| 25 BackendHelpers(this.compiler); |
| 26 |
| 27 JavaScriptBackend get backend => compiler.backend; |
| 28 |
| 29 Resolution get resolution => backend.resolution; |
| 30 |
| 31 MethodElement assertTest; |
| 32 MethodElement assertThrow; |
| 33 MethodElement assertHelper; |
| 34 |
| 35 Element findHelper(String name) => backend.findHelper(name); |
| 36 Element findAsyncHelper(String name) => backend.findAsyncHelper(name); |
| 37 Element findInterceptor(String name) => backend.findInterceptor(name); |
| 38 |
| 39 Element find(LibraryElement library, String name) { |
| 40 return backend.find(library, name); |
| 41 } |
| 42 |
| 43 Element get exceptionUnwrapper { |
| 44 return findHelper('unwrapException'); |
| 45 } |
| 46 |
| 47 Element get throwRuntimeError { |
| 48 return findHelper('throwRuntimeError'); |
| 49 } |
| 50 |
| 51 Element get throwTypeError { |
| 52 return findHelper('throwTypeError'); |
| 53 } |
| 54 |
| 55 Element get throwAbstractClassInstantiationError { |
| 56 return findHelper('throwAbstractClassInstantiationError'); |
| 57 } |
| 58 |
| 59 Element get checkConcurrentModificationError { |
| 60 if (cachedCheckConcurrentModificationError == null) { |
| 61 cachedCheckConcurrentModificationError = |
| 62 findHelper('checkConcurrentModificationError'); |
| 63 } |
| 64 return cachedCheckConcurrentModificationError; |
| 65 } |
| 66 |
| 67 Element get throwConcurrentModificationError { |
| 68 return findHelper('throwConcurrentModificationError'); |
| 69 } |
| 70 |
| 71 Element get throwIndexOutOfBoundsError { |
| 72 return findHelper('ioore'); |
| 73 } |
| 74 |
| 75 Element get stringInterpolationHelper { |
| 76 return findHelper('S'); |
| 77 } |
| 78 |
| 79 Element get wrapExceptionHelper { |
| 80 return findHelper(r'wrapException'); |
| 81 } |
| 82 |
| 83 Element get throwExpressionHelper { |
| 84 return findHelper('throwExpression'); |
| 85 } |
| 86 |
| 87 Element get closureConverter { |
| 88 return findHelper('convertDartClosureToJS'); |
| 89 } |
| 90 |
| 91 Element get traceFromException { |
| 92 return findHelper('getTraceFromException'); |
| 93 } |
| 94 |
| 95 Element get setRuntimeTypeInfo { |
| 96 return findHelper('setRuntimeTypeInfo'); |
| 97 } |
| 98 |
| 99 Element get getRuntimeTypeInfo { |
| 100 return findHelper('getRuntimeTypeInfo'); |
| 101 } |
| 102 |
| 103 Element get getTypeArgumentByIndex { |
| 104 return findHelper('getTypeArgumentByIndex'); |
| 105 } |
| 106 |
| 107 Element get copyTypeArguments { |
| 108 return findHelper('copyTypeArguments'); |
| 109 } |
| 110 |
| 111 Element get computeSignature { |
| 112 return findHelper('computeSignature'); |
| 113 } |
| 114 |
| 115 Element get getRuntimeTypeArguments { |
| 116 return findHelper('getRuntimeTypeArguments'); |
| 117 } |
| 118 |
| 119 Element get getRuntimeTypeArgument { |
| 120 return findHelper('getRuntimeTypeArgument'); |
| 121 } |
| 122 |
| 123 Element get runtimeTypeToString { |
| 124 return findHelper('runtimeTypeToString'); |
| 125 } |
| 126 |
| 127 Element get assertIsSubtype { |
| 128 return findHelper('assertIsSubtype'); |
| 129 } |
| 130 |
| 131 Element get checkSubtype { |
| 132 return findHelper('checkSubtype'); |
| 133 } |
| 134 |
| 135 Element get assertSubtype { |
| 136 return findHelper('assertSubtype'); |
| 137 } |
| 138 |
| 139 Element get subtypeCast { |
| 140 return findHelper('subtypeCast'); |
| 141 } |
| 142 |
| 143 Element get checkSubtypeOfRuntimeType { |
| 144 return findHelper('checkSubtypeOfRuntimeType'); |
| 145 } |
| 146 |
| 147 Element get assertSubtypeOfRuntimeType { |
| 148 return findHelper('assertSubtypeOfRuntimeType'); |
| 149 } |
| 150 |
| 151 Element get subtypeOfRuntimeTypeCast { |
| 152 return findHelper('subtypeOfRuntimeTypeCast'); |
| 153 } |
| 154 |
| 155 Element get checkDeferredIsLoaded { |
| 156 return findHelper('checkDeferredIsLoaded'); |
| 157 } |
| 158 |
| 159 Element get throwNoSuchMethod { |
| 160 return findHelper('throwNoSuchMethod'); |
| 161 } |
| 162 |
| 163 Element get createRuntimeType { |
| 164 return findHelper('createRuntimeType'); |
| 165 } |
| 166 |
| 167 Element get fallThroughError { |
| 168 return findHelper("getFallThroughError"); |
| 169 } |
| 170 |
| 171 Element get createInvocationMirror { |
| 172 return findHelper(Compiler.CREATE_INVOCATION_MIRROR); |
| 173 } |
| 174 |
| 175 Element get cyclicThrowHelper { |
| 176 return findHelper("throwCyclicInit"); |
| 177 } |
| 178 |
| 179 Element get asyncHelper { |
| 180 return findAsyncHelper("_asyncHelper"); |
| 181 } |
| 182 |
| 183 Element get wrapBody { |
| 184 return findAsyncHelper("_wrapJsFunctionForAsync"); |
| 185 } |
| 186 |
| 187 Element get yieldStar { |
| 188 ClassElement classElement = findAsyncHelper("_IterationMarker"); |
| 189 classElement.ensureResolved(resolution); |
| 190 return classElement.lookupLocalMember("yieldStar"); |
| 191 } |
| 192 |
| 193 Element get yieldSingle { |
| 194 ClassElement classElement = findAsyncHelper("_IterationMarker"); |
| 195 classElement.ensureResolved(resolution); |
| 196 return classElement.lookupLocalMember("yieldSingle"); |
| 197 } |
| 198 |
| 199 Element get syncStarUncaughtError { |
| 200 ClassElement classElement = findAsyncHelper("_IterationMarker"); |
| 201 classElement.ensureResolved(resolution); |
| 202 return classElement.lookupLocalMember("uncaughtError"); |
| 203 } |
| 204 |
| 205 Element get asyncStarHelper { |
| 206 return findAsyncHelper("_asyncStarHelper"); |
| 207 } |
| 208 |
| 209 Element get streamOfController { |
| 210 return findAsyncHelper("_streamOfController"); |
| 211 } |
| 212 |
| 213 Element get endOfIteration { |
| 214 ClassElement classElement = findAsyncHelper("_IterationMarker"); |
| 215 classElement.ensureResolved(resolution); |
| 216 return classElement.lookupLocalMember("endOfIteration"); |
| 217 } |
| 218 |
| 219 Element get syncStarIterable { |
| 220 ClassElement classElement = findAsyncHelper("_SyncStarIterable"); |
| 221 classElement.ensureResolved(resolution); |
| 222 return classElement; |
| 223 } |
| 224 |
| 225 Element get syncStarIterableConstructor { |
| 226 ClassElement classElement = syncStarIterable; |
| 227 classElement.ensureResolved(resolution); |
| 228 return classElement.lookupConstructor(""); |
| 229 } |
| 230 |
| 231 Element get syncCompleterConstructor { |
| 232 ClassElement classElement = find(compiler.asyncLibrary, "Completer"); |
| 233 classElement.ensureResolved(resolution); |
| 234 return classElement.lookupConstructor("sync"); |
| 235 } |
| 236 |
| 237 Element get asyncStarController { |
| 238 ClassElement classElement = |
| 239 findAsyncHelper("_AsyncStarStreamController"); |
| 240 classElement.ensureResolved(resolution); |
| 241 return classElement; |
| 242 } |
| 243 |
| 244 Element get asyncStarControllerConstructor { |
| 245 ClassElement classElement = asyncStarController; |
| 246 return classElement.lookupConstructor(""); |
| 247 } |
| 248 |
| 249 Element get streamIteratorConstructor { |
| 250 ClassElement classElement = find(compiler.asyncLibrary, "StreamIterator"); |
| 251 classElement.ensureResolved(resolution); |
| 252 return classElement.lookupConstructor(""); |
| 253 } |
| 254 |
| 255 MethodElement get functionTypeTestMetaHelper { |
| 256 return findHelper('functionTypeTestMetaHelper'); |
| 257 } |
| 258 |
| 259 MethodElement get defineProperty { |
| 260 return findHelper('defineProperty'); |
| 261 } |
| 262 } |
| OLD | NEW |