| OLD | NEW |
| 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library fletchc.fletch_backend; | 5 library fletchc.fletch_backend; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:collection' show | 10 import 'dart:collection' show |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 <FieldElement, FletchFunctionBuilder>{}; | 184 <FieldElement, FletchFunctionBuilder>{}; |
| 185 | 185 |
| 186 final Map<int, int> getters = <int, int>{}; | 186 final Map<int, int> getters = <int, int>{}; |
| 187 final Map<int, int> setters = <int, int>{}; | 187 final Map<int, int> setters = <int, int>{}; |
| 188 | 188 |
| 189 // TODO(ahe): This should be moved to [FletchSystem]. | 189 // TODO(ahe): This should be moved to [FletchSystem]. |
| 190 Map<FletchClassBuilder, FletchFunctionBuilder> tearoffFunctions; | 190 Map<FletchClassBuilder, FletchFunctionBuilder> tearoffFunctions; |
| 191 | 191 |
| 192 LibraryElement fletchSystemLibrary; | 192 LibraryElement fletchSystemLibrary; |
| 193 LibraryElement fletchFFILibrary; | 193 LibraryElement fletchFFILibrary; |
| 194 LibraryElement fletchIOSystemLibrary; | |
| 195 LibraryElement collectionLibrary; | 194 LibraryElement collectionLibrary; |
| 196 LibraryElement mathLibrary; | 195 LibraryElement mathLibrary; |
| 197 LibraryElement asyncLibrary; | 196 LibraryElement asyncLibrary; |
| 198 LibraryElement fletchLibrary; | 197 LibraryElement fletchLibrary; |
| 199 | 198 |
| 200 FunctionElement fletchSystemEntry; | 199 FunctionElement fletchSystemEntry; |
| 201 | 200 |
| 202 FunctionElement fletchExternalInvokeMain; | 201 FunctionElement fletchExternalInvokeMain; |
| 203 | 202 |
| 204 FunctionElement fletchExternalYield; | 203 FunctionElement fletchExternalYield; |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 ..bind(skipGetter) | 1115 ..bind(skipGetter) |
| 1117 ..invokeMethod(fletchSelector, 1) | 1116 ..invokeMethod(fletchSelector, 1) |
| 1118 ..exitNoSuchMethod() | 1117 ..exitNoSuchMethod() |
| 1119 ..methodEnd(); | 1118 ..methodEnd(); |
| 1120 } | 1119 } |
| 1121 | 1120 |
| 1122 bool isNative(Element element) { | 1121 bool isNative(Element element) { |
| 1123 if (element is FunctionElement) { | 1122 if (element is FunctionElement) { |
| 1124 for (var metadata in element.metadata) { | 1123 for (var metadata in element.metadata) { |
| 1125 // TODO(ahe): This code should ensure that @native resolves to precisely | 1124 // TODO(ahe): This code should ensure that @native resolves to precisely |
| 1126 // the native variable in fletch:system. | 1125 // the native variable in dart:fletch._system. |
| 1127 if (metadata.constant == null) continue; | 1126 if (metadata.constant == null) continue; |
| 1128 ConstantValue value = context.getConstantValue(metadata.constant); | 1127 ConstantValue value = context.getConstantValue(metadata.constant); |
| 1129 if (!value.isString) continue; | 1128 if (!value.isString) continue; |
| 1130 StringConstantValue stringValue = value; | 1129 StringConstantValue stringValue = value; |
| 1131 if (stringValue.toDartString().slowToString() != 'native') continue; | 1130 if (stringValue.toDartString().slowToString() != 'native') continue; |
| 1132 return true; | 1131 return true; |
| 1133 } | 1132 } |
| 1134 } | 1133 } |
| 1135 return false; | 1134 return false; |
| 1136 } | 1135 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 compiler.reportWarning( | 1344 compiler.reportWarning( |
| 1346 node, | 1345 node, |
| 1347 MessageKind.GENERIC, | 1346 MessageKind.GENERIC, |
| 1348 {'text': "Deferred loading is not supported."}); | 1347 {'text': "Deferred loading is not supported."}); |
| 1349 return false; | 1348 return false; |
| 1350 } | 1349 } |
| 1351 | 1350 |
| 1352 bool get supportsReflection => false; | 1351 bool get supportsReflection => false; |
| 1353 | 1352 |
| 1354 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { | 1353 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { |
| 1355 if (Uri.parse('dart:_fletch_system') == library.canonicalUri) { | 1354 if (Uri.parse('dart:fletch._system') == library.canonicalUri) { |
| 1356 fletchSystemLibrary = library; | 1355 fletchSystemLibrary = library; |
| 1357 } else if (Uri.parse('dart:fletch.ffi') == library.canonicalUri) { | 1356 } else if (Uri.parse('dart:fletch.ffi') == library.canonicalUri) { |
| 1358 fletchFFILibrary = library; | 1357 fletchFFILibrary = library; |
| 1359 } else if (Uri.parse('dart:system') == library.canonicalUri) { | |
| 1360 fletchIOSystemLibrary = library; | |
| 1361 } else if (Uri.parse('dart:collection') == library.canonicalUri) { | 1358 } else if (Uri.parse('dart:collection') == library.canonicalUri) { |
| 1362 collectionLibrary = library; | 1359 collectionLibrary = library; |
| 1363 } else if (Uri.parse('dart:math') == library.canonicalUri) { | 1360 } else if (Uri.parse('dart:math') == library.canonicalUri) { |
| 1364 mathLibrary = library; | 1361 mathLibrary = library; |
| 1365 } else if (Uri.parse('dart:async') == library.canonicalUri) { | 1362 } else if (Uri.parse('dart:async') == library.canonicalUri) { |
| 1366 asyncLibrary = library; | 1363 asyncLibrary = library; |
| 1367 } else if (Uri.parse('dart:fletch') == library.canonicalUri) { | 1364 } else if (Uri.parse('dart:fletch') == library.canonicalUri) { |
| 1368 fletchLibrary = library; | 1365 fletchLibrary = library; |
| 1369 } | 1366 } |
| 1370 | 1367 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 if (element is ExecutableElement) { | 1666 if (element is ExecutableElement) { |
| 1670 return element.memberContext != element; | 1667 return element.memberContext != element; |
| 1671 } | 1668 } |
| 1672 return false; | 1669 return false; |
| 1673 } | 1670 } |
| 1674 | 1671 |
| 1675 Name memberName(AstElement element) { | 1672 Name memberName(AstElement element) { |
| 1676 if (isLocalFunction(element)) return null; | 1673 if (isLocalFunction(element)) return null; |
| 1677 MemberElement member = element; | 1674 MemberElement member = element; |
| 1678 return member.memberName; | 1675 return member.memberName; |
| 1679 } | 1676 } |
| OLD | NEW |