| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common_elements.dart'; | 7 import '../common_elements.dart'; |
| 8 import '../compiler.dart'; | 8 import '../compiler.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return true; | 298 return true; |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 return false; | 301 return false; |
| 302 } | 302 } |
| 303 | 303 |
| 304 void _retainMetadataOf(Element element) { | 304 void _retainMetadataOf(Element element) { |
| 305 for (MetadataAnnotation metadata in element.metadata) { | 305 for (MetadataAnnotation metadata in element.metadata) { |
| 306 metadata.ensureResolved(_compiler.resolution); | 306 metadata.ensureResolved(_compiler.resolution); |
| 307 ConstantValue constant = _constants.getConstantValueForMetadata(metadata); | 307 ConstantValue constant = _constants.getConstantValueForMetadata(metadata); |
| 308 _constants.addCompileTimeConstantForEmission(constant); | 308 CodegenWorldBuilder worldBuilder = _compiler.codegenWorldBuilder; |
| 309 worldBuilder.addCompileTimeConstantForEmission(constant); |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 | 312 |
| 312 bool invokedReflectively(Element element) { | 313 bool invokedReflectively(Element element) { |
| 313 if (element.isParameter) { | 314 if (element.isParameter) { |
| 314 ParameterElement parameter = element; | 315 ParameterElement parameter = element; |
| 315 if (invokedReflectively(parameter.functionDeclaration)) return true; | 316 if (invokedReflectively(parameter.functionDeclaration)) return true; |
| 316 } | 317 } |
| 317 | 318 |
| 318 if (element.isField) { | 319 if (element.isField) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 if (metaTargets != null) { | 370 if (metaTargets != null) { |
| 370 for (var element in metaTargets) { | 371 for (var element in metaTargets) { |
| 371 if (element is ClassEntity) { | 372 if (element is ClassEntity) { |
| 372 metaTargetsUsed.add(element); | 373 metaTargetsUsed.add(element); |
| 373 } | 374 } |
| 374 } | 375 } |
| 375 } | 376 } |
| 376 } | 377 } |
| 377 | 378 |
| 378 @override | 379 @override |
| 379 bool isClassAccessibleByReflection(ClassElement element) { | 380 bool isClassAccessibleByReflection(ClassEntity element) { |
| 380 return _classesNeededForReflection.contains(_getDartClass(element)); | 381 return _classesNeededForReflection.contains(_getDartClass(element)); |
| 381 } | 382 } |
| 382 | 383 |
| 383 @override | 384 @override |
| 384 bool isTypedefAccessibleByReflection(TypedefElement element) { | 385 bool isTypedefAccessibleByReflection(TypedefElement element) { |
| 385 return _typedefsNeededForReflection.contains(element); | 386 return _typedefsNeededForReflection.contains(element); |
| 386 } | 387 } |
| 387 | 388 |
| 388 bool isAccessibleByReflection(Element element) { | 389 bool isAccessibleByReflection(Element element) { |
| 389 if (element.isLibrary) { | 390 if (element.isLibrary) { |
| 390 return false; | 391 return false; |
| 391 } else if (element.isClass) { | 392 } else if (element.isClass) { |
| 392 return isClassAccessibleByReflection(element); | 393 ClassElement cls = element; |
| 394 return isClassAccessibleByReflection(cls); |
| 393 } else if (element.isTypedef) { | 395 } else if (element.isTypedef) { |
| 394 return isTypedefAccessibleByReflection(element); | 396 return isTypedefAccessibleByReflection(element); |
| 395 } else { | 397 } else { |
| 396 MemberElement member = element; | 398 MemberElement member = element; |
| 397 return isMemberAccessibleByReflection(member); | 399 return isMemberAccessibleByReflection(member); |
| 398 } | 400 } |
| 399 } | 401 } |
| 400 | 402 |
| 401 ClassElement _getDartClass(ClassElement cls) { | 403 ClassEntity _getDartClass(ClassEntity cls) { |
| 402 if (cls == _commonElements.jsIntClass) { | 404 if (cls == _commonElements.jsIntClass) { |
| 403 return _commonElements.intClass; | 405 return _commonElements.intClass; |
| 404 } else if (cls == _commonElements.jsBoolClass) { | 406 } else if (cls == _commonElements.jsBoolClass) { |
| 405 return _commonElements.boolClass; | 407 return _commonElements.boolClass; |
| 406 } else if (cls == _commonElements.jsNumberClass) { | 408 } else if (cls == _commonElements.jsNumberClass) { |
| 407 return _commonElements.numClass; | 409 return _commonElements.numClass; |
| 408 } else if (cls == _commonElements.jsDoubleClass) { | 410 } else if (cls == _commonElements.jsDoubleClass) { |
| 409 return _commonElements.doubleClass; | 411 return _commonElements.doubleClass; |
| 410 } else if (cls == _commonElements.jsStringClass) { | 412 } else if (cls == _commonElements.jsStringClass) { |
| 411 return _commonElements.stringClass; | 413 return _commonElements.stringClass; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 697 } |
| 696 | 698 |
| 697 /// Called when `const Symbol(name)` is seen. | 699 /// Called when `const Symbol(name)` is seen. |
| 698 void registerConstSymbol(String name) { | 700 void registerConstSymbol(String name) { |
| 699 symbolsUsed.add(name); | 701 symbolsUsed.add(name); |
| 700 if (name.endsWith('=')) { | 702 if (name.endsWith('=')) { |
| 701 symbolsUsed.add(name.substring(0, name.length - 1)); | 703 symbolsUsed.add(name.substring(0, name.length - 1)); |
| 702 } | 704 } |
| 703 } | 705 } |
| 704 } | 706 } |
| OLD | NEW |