Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 
| 2 | 2 | 
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a | 
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. | 
| 5 | 5 | 
| 6 import 'dart:collection' show HashMap, HashSet; | 6 import 'dart:collection' show HashMap, HashSet; | 
| 7 import 'dart:math' show min, max; | 7 import 'dart:math' show min, max; | 
| 8 | 8 | 
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; | 
| (...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1830 // See if we have a "call" with a statically known function type: | 1830 // See if we have a "call" with a statically known function type: | 
| 1831 // | 1831 // | 
| 1832 // - if it's a method, then it does because all methods do, | 1832 // - if it's a method, then it does because all methods do, | 
| 1833 // - if it's a getter, check the return type. | 1833 // - if it's a getter, check the return type. | 
| 1834 // | 1834 // | 
| 1835 // Other cases like a getter returning dynamic/Object/Function will be | 1835 // Other cases like a getter returning dynamic/Object/Function will be | 
| 1836 // handled at runtime by the dynamic call mechanism. So we only | 1836 // handled at runtime by the dynamic call mechanism. So we only | 
| 1837 // concern ourselves with statically known function types. | 1837 // concern ourselves with statically known function types. | 
| 1838 // | 1838 // | 
| 1839 // For the same reason, we can ignore "noSuchMethod". | 1839 // For the same reason, we can ignore "noSuchMethod". | 
| 1840 // call-implemented-by-nSM will be dispatched by dcall at runtime. | 1840 // call-implemented-by-nSM will be dispatched by dcall at runtime. | 
| 
 
vsm
2017/07/14 14:19:56
Remove or update the two lines above?
 
Jennifer Messerly
2017/07/14 18:40:20
they're still accurate but i'll try and clarify:
 
 | |
| 1841 bool isCallable = classElem.lookUpMethod('call', null) != null || | 1841 // For classes that implement a callable interface with nSM, we'll find | 
| 1842 classElem.lookUpGetter('call', null)?.returnType is FunctionType; | 1842 // the "call" when we search the type for inherited "call" members. | 
| 1843 var callMethod = classElem.type.lookUpInheritedGetterOrMethod('call'); | |
| 1844 bool isCallable = callMethod is PropertyAccessorElement | |
| 1845 ? callMethod.returnType is FunctionType | |
| 1846 : callMethod != null; | |
| 1843 | 1847 | 
| 1844 var body = <JS.Statement>[]; | 1848 var body = <JS.Statement>[]; | 
| 1845 void addConstructor(ConstructorElement element, JS.Expression jsCtor) { | 1849 void addConstructor(ConstructorElement element, JS.Expression jsCtor) { | 
| 1846 var ctorName = _constructorName(element); | 1850 var ctorName = _constructorName(element); | 
| 1847 if (JS.invalidStaticFieldName(element.name)) { | 1851 if (JS.invalidStaticFieldName(element.name)) { | 
| 1848 jsCtor = | 1852 jsCtor = | 
| 1849 _callHelper('defineValue(#, #, #)', [className, ctorName, jsCtor]); | 1853 _callHelper('defineValue(#, #, #)', [className, ctorName, jsCtor]); | 
| 1850 } else { | 1854 } else { | 
| 1851 jsCtor = js.call('#.# = #', [className, ctorName, jsCtor]); | 1855 jsCtor = js.call('#.# = #', [className, ctorName, jsCtor]); | 
| 1852 } | 1856 } | 
| (...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5975 if (targetIdentifier.staticElement is! PrefixElement) return false; | 5979 if (targetIdentifier.staticElement is! PrefixElement) return false; | 
| 5976 var prefix = targetIdentifier.staticElement as PrefixElement; | 5980 var prefix = targetIdentifier.staticElement as PrefixElement; | 
| 5977 | 5981 | 
| 5978 // The library the prefix is referring to must come from a deferred import. | 5982 // The library the prefix is referring to must come from a deferred import. | 
| 5979 var containingLibrary = resolutionMap | 5983 var containingLibrary = resolutionMap | 
| 5980 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) | 5984 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) | 
| 5981 .library; | 5985 .library; | 
| 5982 var imports = containingLibrary.getImportsWithPrefix(prefix); | 5986 var imports = containingLibrary.getImportsWithPrefix(prefix); | 
| 5983 return imports.length == 1 && imports[0].isDeferred; | 5987 return imports.length == 1 && imports[0].isDeferred; | 
| 5984 } | 5988 } | 
| OLD | NEW |