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 // 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 'dart:collection' show HashMap, HashSet; | 5 import 'dart:collection' show HashMap, HashSet; |
6 import 'dart:math' show min, max; | 6 import 'dart:math' show min, max; |
7 | 7 |
8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; | 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; |
(...skipping 23 matching lines...) Expand all Loading... | |
34 show BuildUnit, CompilerOptions, JSModuleFile, ModuleFormat; | 34 show BuildUnit, CompilerOptions, JSModuleFile, ModuleFormat; |
35 import 'element_helpers.dart'; | 35 import 'element_helpers.dart'; |
36 import 'element_loader.dart' show ElementLoader; | 36 import 'element_loader.dart' show ElementLoader; |
37 import 'extension_types.dart' show ExtensionTypeSet; | 37 import 'extension_types.dart' show ExtensionTypeSet; |
38 import 'js_field_storage.dart' show checkForPropertyOverride, getSuperclasses; | 38 import 'js_field_storage.dart' show checkForPropertyOverride, getSuperclasses; |
39 import 'js_interop.dart'; | 39 import 'js_interop.dart'; |
40 import 'js_metalet.dart' as JS; | 40 import 'js_metalet.dart' as JS; |
41 import 'js_names.dart' as JS; | 41 import 'js_names.dart' as JS; |
42 import 'js_typeref_codegen.dart' show JsTypeRefCodegen; | 42 import 'js_typeref_codegen.dart' show JsTypeRefCodegen; |
43 import 'module_builder.dart' | 43 import 'module_builder.dart' |
44 show LegacyModuleBuilder, NodeModuleBuilder, pathToJSIdentifier; | 44 show |
45 CommonJSModuleBuilder, | |
46 RequireJSModuleBuilder, | |
nweiz
2016/08/16 22:14:53
For what it's worth, despite their names, CommonJS
Jennifer Messerly
2016/08/24 22:39:51
yeah, I was kind of going back and forth there, as
| |
47 LegacyModuleBuilder, | |
48 pathToJSIdentifier; | |
45 import 'nullable_type_inference.dart' show NullableTypeInference; | 49 import 'nullable_type_inference.dart' show NullableTypeInference; |
46 import 'reify_coercions.dart' show CoercionReifier; | 50 import 'reify_coercions.dart' show CoercionReifier; |
47 import 'side_effect_analysis.dart' show ConstFieldVisitor, isStateless; | 51 import 'side_effect_analysis.dart' show ConstFieldVisitor, isStateless; |
48 import 'source_map_printer.dart' show SourceMapPrintingContext; | 52 import 'source_map_printer.dart' show SourceMapPrintingContext; |
49 import 'type_utilities.dart'; | 53 import 'type_utilities.dart'; |
50 | 54 |
51 class CodeGenerator extends GeneralizingAstVisitor | 55 class CodeGenerator extends GeneralizingAstVisitor |
52 with ClosureAnnotator, JsTypeRefCodegen, NullableTypeInference { | 56 with ClosureAnnotator, JsTypeRefCodegen, NullableTypeInference { |
53 final AnalysisContext context; | 57 final AnalysisContext context; |
54 final CompilerOptions options; | 58 final CompilerOptions options; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 // Add the module's code (produced by visiting compilation units, above) | 287 // Add the module's code (produced by visiting compilation units, above) |
284 _copyAndFlattenBlocks(items, _moduleItems); | 288 _copyAndFlattenBlocks(items, _moduleItems); |
285 | 289 |
286 // Build the module. | 290 // Build the module. |
287 var module = new JS.Program(items, name: _buildUnit.name); | 291 var module = new JS.Program(items, name: _buildUnit.name); |
288 | 292 |
289 // Optional: lower module format. Otherwise just return it. | 293 // Optional: lower module format. Otherwise just return it. |
290 switch (options.moduleFormat) { | 294 switch (options.moduleFormat) { |
291 case ModuleFormat.legacy: | 295 case ModuleFormat.legacy: |
292 return new LegacyModuleBuilder().build(module); | 296 return new LegacyModuleBuilder().build(module); |
293 case ModuleFormat.node: | 297 case ModuleFormat.commonjs: |
294 return new NodeModuleBuilder().build(module); | 298 return new CommonJSModuleBuilder().build(module); |
299 case ModuleFormat.requirejs: | |
300 return new RequireJSModuleBuilder().build(module); | |
295 case ModuleFormat.es6: | 301 case ModuleFormat.es6: |
296 return module; | 302 return module; |
297 } | 303 } |
298 return null; // unreachable. It is here to suppress a bogus Analyzer message | 304 return null; // unreachable. It is here to suppress a bogus Analyzer message |
299 } | 305 } |
300 | 306 |
301 List<String> _getJSName(Element e) { | 307 List<String> _getJSName(Element e) { |
302 if (findAnnotation(e.library, isPublicJSAnnotation) == null) { | 308 if (findAnnotation(e.library, isPublicJSAnnotation) == null) { |
303 return null; | 309 return null; |
304 } | 310 } |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1743 var property = new JS.Property(memberName, type); | 1749 var property = new JS.Property(memberName, type); |
1744 tCtors.add(property); | 1750 tCtors.add(property); |
1745 } | 1751 } |
1746 | 1752 |
1747 JS.Property build(String name, List<JS.Property> elements) { | 1753 JS.Property build(String name, List<JS.Property> elements) { |
1748 var o = | 1754 var o = |
1749 new JS.ObjectInitializer(elements, multiline: elements.length > 1); | 1755 new JS.ObjectInitializer(elements, multiline: elements.length > 1); |
1750 var e = js.call('() => #', o); | 1756 var e = js.call('() => #', o); |
1751 return new JS.Property(_propertyName(name), e); | 1757 return new JS.Property(_propertyName(name), e); |
1752 } | 1758 } |
1759 | |
1753 var sigFields = <JS.Property>[]; | 1760 var sigFields = <JS.Property>[]; |
1754 if (!tCtors.isEmpty) sigFields.add(build('constructors', tCtors)); | 1761 if (!tCtors.isEmpty) sigFields.add(build('constructors', tCtors)); |
1755 if (!tMethods.isEmpty) sigFields.add(build('methods', tMethods)); | 1762 if (!tMethods.isEmpty) sigFields.add(build('methods', tMethods)); |
1756 if (!tStatics.isEmpty) { | 1763 if (!tStatics.isEmpty) { |
1757 assert(!sNames.isEmpty); | 1764 assert(!sNames.isEmpty); |
1758 var aNames = new JS.Property( | 1765 var aNames = new JS.Property( |
1759 _propertyName('names'), new JS.ArrayInitializer(sNames)); | 1766 _propertyName('names'), new JS.ArrayInitializer(sNames)); |
1760 sigFields.add(build('statics', tStatics)); | 1767 sigFields.add(build('statics', tStatics)); |
1761 sigFields.add(aNames); | 1768 sigFields.add(aNames); |
1762 } | 1769 } |
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3242 var element = node.methodName.staticElement; | 3249 var element = node.methodName.staticElement; |
3243 bool isStatic = element is ExecutableElement && element.isStatic; | 3250 bool isStatic = element is ExecutableElement && element.isStatic; |
3244 var memberName = _emitMemberName(name, type: type, isStatic: isStatic); | 3251 var memberName = _emitMemberName(name, type: type, isStatic: isStatic); |
3245 | 3252 |
3246 JS.Expression jsTarget = _visit(target); | 3253 JS.Expression jsTarget = _visit(target); |
3247 if (isDynamicInvoke(target) || isDynamicInvoke(node.methodName)) { | 3254 if (isDynamicInvoke(target) || isDynamicInvoke(node.methodName)) { |
3248 if (_inWhitelistCode(target)) { | 3255 if (_inWhitelistCode(target)) { |
3249 var vars = <JS.MetaLetVariable, JS.Expression>{}; | 3256 var vars = <JS.MetaLetVariable, JS.Expression>{}; |
3250 var l = _visit(_bindValue(vars, 'l', target)); | 3257 var l = _visit(_bindValue(vars, 'l', target)); |
3251 jsTarget = new JS.MetaLet(vars, [ | 3258 jsTarget = new JS.MetaLet(vars, [ |
3252 js.call('(#[(#[dart._extensionType]) ? dartx[#] : #])', | 3259 js.call('(#[(#[dart._extensionType]) ? dartx[#] : #])', [ |
3253 [l, l, memberName, memberName,]) | 3260 l, |
3261 l, | |
3262 memberName, | |
3263 memberName, | |
3264 ]) | |
3254 ]); | 3265 ]); |
3255 if (typeArgs != null) jsTarget = new JS.Call(jsTarget, typeArgs); | 3266 if (typeArgs != null) jsTarget = new JS.Call(jsTarget, typeArgs); |
3256 return new JS.Call(jsTarget, args); | 3267 return new JS.Call(jsTarget, args); |
3257 } | 3268 } |
3258 if (typeArgs != null) { | 3269 if (typeArgs != null) { |
3259 return js.call('dart.dgsend(#, #, #, #)', | 3270 return js.call('dart.dgsend(#, #, #, #)', |
3260 [jsTarget, new JS.ArrayInitializer(typeArgs), memberName, args]); | 3271 [jsTarget, new JS.ArrayInitializer(typeArgs), memberName, args]); |
3261 } else { | 3272 } else { |
3262 return js.call('dart.dsend(#, #, #)', [jsTarget, memberName, args]); | 3273 return js.call('dart.dsend(#, #, #)', [jsTarget, memberName, args]); |
3263 } | 3274 } |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3781 if (name != null) { | 3792 if (name != null) { |
3782 ctor = new JS.PropertyAccess(ctor, _propertyName(name.name)); | 3793 ctor = new JS.PropertyAccess(ctor, _propertyName(name.name)); |
3783 } | 3794 } |
3784 } else { | 3795 } else { |
3785 ctor = _emitConstructorName(element, type, name); | 3796 ctor = _emitConstructorName(element, type, name); |
3786 isFactory = element.isFactory; | 3797 isFactory = element.isFactory; |
3787 } | 3798 } |
3788 var args = _visit(argumentList) as List<JS.Expression>; | 3799 var args = _visit(argumentList) as List<JS.Expression>; |
3789 return isFactory ? new JS.Call(ctor, args) : new JS.New(ctor, args); | 3800 return isFactory ? new JS.Call(ctor, args) : new JS.New(ctor, args); |
3790 } | 3801 } |
3802 | |
3791 if (element != null && _isObjectLiteral(element.enclosingElement)) { | 3803 if (element != null && _isObjectLiteral(element.enclosingElement)) { |
3792 return _emitObjectLiteral(argumentList); | 3804 return _emitObjectLiteral(argumentList); |
3793 } | 3805 } |
3794 if (isConst) return _emitConst(emitNew); | 3806 if (isConst) return _emitConst(emitNew); |
3795 return emitNew(); | 3807 return emitNew(); |
3796 } | 3808 } |
3797 | 3809 |
3798 bool _isObjectLiteral(ClassElement classElem) { | 3810 bool _isObjectLiteral(ClassElement classElem) { |
3799 return findAnnotation(classElem, isPublicJSAnnotation) != null && | 3811 return findAnnotation(classElem, isPublicJSAnnotation) != null && |
3800 findAnnotation(classElem, isJSAnonymousAnnotation) != null; | 3812 findAnnotation(classElem, isJSAnonymousAnnotation) != null; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4022 } | 4034 } |
4023 int finishIdentifier(SimpleIdentifier identifier) { | 4035 int finishIdentifier(SimpleIdentifier identifier) { |
4024 Element staticElement = identifier.staticElement; | 4036 Element staticElement = identifier.staticElement; |
4025 if (staticElement is PropertyAccessorElement && staticElement.isGetter) { | 4037 if (staticElement is PropertyAccessorElement && staticElement.isGetter) { |
4026 PropertyInducingElement variable = staticElement.variable; | 4038 PropertyInducingElement variable = staticElement.variable; |
4027 int value = variable?.constantValue?.toIntValue(); | 4039 int value = variable?.constantValue?.toIntValue(); |
4028 if (value != null && value >= low && value <= high) return value; | 4040 if (value != null && value >= low && value <= high) return value; |
4029 } | 4041 } |
4030 return null; | 4042 return null; |
4031 } | 4043 } |
4044 | |
4032 if (expr is SimpleIdentifier) { | 4045 if (expr is SimpleIdentifier) { |
4033 return finishIdentifier(expr); | 4046 return finishIdentifier(expr); |
4034 } else if (expr is PrefixedIdentifier && !expr.isDeferred) { | 4047 } else if (expr is PrefixedIdentifier && !expr.isDeferred) { |
4035 return finishIdentifier(expr.identifier); | 4048 return finishIdentifier(expr.identifier); |
4036 } | 4049 } |
4037 return null; | 4050 return null; |
4038 } | 4051 } |
4039 | 4052 |
4040 bool _isDefinitelyNonNegative(Expression expr) { | 4053 bool _isDefinitelyNonNegative(Expression expr) { |
4041 expr = expr.unParenthesized; | 4054 expr = expr.unParenthesized; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4109 } | 4122 } |
4110 return MAX; | 4123 return MAX; |
4111 default: | 4124 default: |
4112 return MAX; | 4125 return MAX; |
4113 } | 4126 } |
4114 } | 4127 } |
4115 int value = _asIntInRange(expr, 0, 0x7fffffff); | 4128 int value = _asIntInRange(expr, 0, 0x7fffffff); |
4116 if (value != null) return value.bitLength; | 4129 if (value != null) return value.bitLength; |
4117 return MAX; | 4130 return MAX; |
4118 } | 4131 } |
4132 | |
4119 return bitWidth(expr, 0) < 32; | 4133 return bitWidth(expr, 0) < 32; |
4120 } | 4134 } |
4121 | 4135 |
4122 /// If the type [t] is [int] or [double], or a type parameter | 4136 /// If the type [t] is [int] or [double], or a type parameter |
4123 /// bounded by [int], [double] or [num] returns [num]. | 4137 /// bounded by [int], [double] or [num] returns [num]. |
4124 /// Otherwise returns [t]. | 4138 /// Otherwise returns [t]. |
4125 DartType _canonicalizeNumTypes(DartType t) { | 4139 DartType _canonicalizeNumTypes(DartType t) { |
4126 var numType = types.numType; | 4140 var numType = types.numType; |
4127 if (rules.isSubtypeOf(t, numType)) return numType; | 4141 if (rules.isSubtypeOf(t, numType)) return numType; |
4128 return t; | 4142 return t; |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4899 visitNullLiteral(NullLiteral node) => new JS.LiteralNull(); | 4913 visitNullLiteral(NullLiteral node) => new JS.LiteralNull(); |
4900 | 4914 |
4901 @override | 4915 @override |
4902 visitSymbolLiteral(SymbolLiteral node) { | 4916 visitSymbolLiteral(SymbolLiteral node) { |
4903 JS.Expression emitSymbol() { | 4917 JS.Expression emitSymbol() { |
4904 // TODO(vsm): When we canonicalize, we need to treat private symbols | 4918 // TODO(vsm): When we canonicalize, we need to treat private symbols |
4905 // correctly. | 4919 // correctly. |
4906 var name = js.string(node.components.join('.'), "'"); | 4920 var name = js.string(node.components.join('.'), "'"); |
4907 return js.call('#.new(#)', [_emitType(types.symbolType), name]); | 4921 return js.call('#.new(#)', [_emitType(types.symbolType), name]); |
4908 } | 4922 } |
4923 | |
4909 return _emitConst(emitSymbol); | 4924 return _emitConst(emitSymbol); |
4910 } | 4925 } |
4911 | 4926 |
4912 @override | 4927 @override |
4913 visitListLiteral(ListLiteral node) { | 4928 visitListLiteral(ListLiteral node) { |
4914 var isConst = node.constKeyword != null; | 4929 var isConst = node.constKeyword != null; |
4915 JS.Expression emitList() { | 4930 JS.Expression emitList() { |
4916 JS.Expression list = new JS.ArrayInitializer( | 4931 JS.Expression list = new JS.ArrayInitializer( |
4917 _visitList(node.elements) as List<JS.Expression>); | 4932 _visitList(node.elements) as List<JS.Expression>); |
4918 ParameterizedType type = node.staticType; | 4933 ParameterizedType type = node.staticType; |
4919 var elementType = type.typeArguments.single; | 4934 var elementType = type.typeArguments.single; |
4920 // TODO(jmesserly): analyzer will usually infer `List<Object>` because | 4935 // TODO(jmesserly): analyzer will usually infer `List<Object>` because |
4921 // that is the least upper bound of the element types. So we rarely | 4936 // that is the least upper bound of the element types. So we rarely |
4922 // generate a plain `List<dynamic>` anymore. | 4937 // generate a plain `List<dynamic>` anymore. |
4923 if (!elementType.isDynamic || isConst) { | 4938 if (!elementType.isDynamic || isConst) { |
4924 // dart.list helper internally depends on _interceptors.JSArray. | 4939 // dart.list helper internally depends on _interceptors.JSArray. |
4925 _declareBeforeUse(_jsArray); | 4940 _declareBeforeUse(_jsArray); |
4926 if (isConst) { | 4941 if (isConst) { |
4927 var typeRep = _emitType(elementType); | 4942 var typeRep = _emitType(elementType); |
4928 list = js.call('dart.constList(#, #)', [list, typeRep]); | 4943 list = js.call('dart.constList(#, #)', [list, typeRep]); |
4929 } else { | 4944 } else { |
4930 // Call `new JSArray<E>.of(list)` | 4945 // Call `new JSArray<E>.of(list)` |
4931 var jsArrayType = _jsArray.type.instantiate(type.typeArguments); | 4946 var jsArrayType = _jsArray.type.instantiate(type.typeArguments); |
4932 list = js.call('#.of(#)', [_emitType(jsArrayType), list]); | 4947 list = js.call('#.of(#)', [_emitType(jsArrayType), list]); |
4933 } | 4948 } |
4934 } | 4949 } |
4935 return list; | 4950 return list; |
4936 } | 4951 } |
4952 | |
4937 if (isConst) return _cacheConst(emitList); | 4953 if (isConst) return _cacheConst(emitList); |
4938 return emitList(); | 4954 return emitList(); |
4939 } | 4955 } |
4940 | 4956 |
4941 @override | 4957 @override |
4942 visitMapLiteral(MapLiteral node) { | 4958 visitMapLiteral(MapLiteral node) { |
4943 // TODO(jmesserly): we can likely make these faster. | 4959 // TODO(jmesserly): we can likely make these faster. |
4944 JS.Expression emitMap() { | 4960 JS.Expression emitMap() { |
4945 var entries = node.entries; | 4961 var entries = node.entries; |
4946 var mapArguments = null; | 4962 var mapArguments = null; |
(...skipping 18 matching lines...) Expand all Loading... | |
4965 values.add(_visit(e.value)); | 4981 values.add(_visit(e.value)); |
4966 } | 4982 } |
4967 mapArguments = new JS.ArrayInitializer(values); | 4983 mapArguments = new JS.ArrayInitializer(values); |
4968 } | 4984 } |
4969 var types = <JS.Expression>[]; | 4985 var types = <JS.Expression>[]; |
4970 if (reifyTypeArgs) { | 4986 if (reifyTypeArgs) { |
4971 types.addAll(typeArgs.map((e) => _emitType(e))); | 4987 types.addAll(typeArgs.map((e) => _emitType(e))); |
4972 } | 4988 } |
4973 return js.call('dart.map(#, #)', [mapArguments, types]); | 4989 return js.call('dart.map(#, #)', [mapArguments, types]); |
4974 } | 4990 } |
4991 | |
4975 if (node.constKeyword != null) return _emitConst(emitMap); | 4992 if (node.constKeyword != null) return _emitConst(emitMap); |
4976 return emitMap(); | 4993 return emitMap(); |
4977 } | 4994 } |
4978 | 4995 |
4979 @override | 4996 @override |
4980 JS.LiteralString visitSimpleStringLiteral(SimpleStringLiteral node) => | 4997 JS.LiteralString visitSimpleStringLiteral(SimpleStringLiteral node) => |
4981 js.escapedString(node.value, node.isSingleQuoted ? "'" : '"'); | 4998 js.escapedString(node.value, node.isSingleQuoted ? "'" : '"'); |
4982 | 4999 |
4983 @override | 5000 @override |
4984 JS.Expression visitAdjacentStrings(AdjacentStrings node) => | 5001 JS.Expression visitAdjacentStrings(AdjacentStrings node) => |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5041 | 5058 |
5042 /// Generates an expression for a boolean conversion context (if, while, &&, | 5059 /// Generates an expression for a boolean conversion context (if, while, &&, |
5043 /// etc.), where conversions and null checks are implemented via `dart.test` | 5060 /// etc.), where conversions and null checks are implemented via `dart.test` |
5044 /// to give a more helpful message. | 5061 /// to give a more helpful message. |
5045 // TODO(sra): When nullablility is available earlier, it would be cleaner to | 5062 // TODO(sra): When nullablility is available earlier, it would be cleaner to |
5046 // build an input AST where the boolean conversion is a single AST node. | 5063 // build an input AST where the boolean conversion is a single AST node. |
5047 JS.Expression _visitTest(Expression node) { | 5064 JS.Expression _visitTest(Expression node) { |
5048 JS.Expression finish(JS.Expression result) { | 5065 JS.Expression finish(JS.Expression result) { |
5049 return annotate(result, node); | 5066 return annotate(result, node); |
5050 } | 5067 } |
5068 | |
5051 if (node is PrefixExpression && node.operator.lexeme == '!') { | 5069 if (node is PrefixExpression && node.operator.lexeme == '!') { |
5052 return finish(js.call('!#', _visitTest(node.operand))); | 5070 return finish(js.call('!#', _visitTest(node.operand))); |
5053 } | 5071 } |
5054 if (node is ParenthesizedExpression) { | 5072 if (node is ParenthesizedExpression) { |
5055 return finish(_visitTest(node.expression)); | 5073 return finish(_visitTest(node.expression)); |
5056 } | 5074 } |
5057 if (node is BinaryExpression) { | 5075 if (node is BinaryExpression) { |
5058 JS.Expression shortCircuit(String code) { | 5076 JS.Expression shortCircuit(String code) { |
5059 return finish(js.call(code, | 5077 return finish(js.call(code, |
5060 [_visitTest(node.leftOperand), _visitTest(node.rightOperand)])); | 5078 [_visitTest(node.leftOperand), _visitTest(node.rightOperand)])); |
5061 } | 5079 } |
5080 | |
5062 var op = node.operator.type.lexeme; | 5081 var op = node.operator.type.lexeme; |
5063 if (op == '&&') return shortCircuit('# && #'); | 5082 if (op == '&&') return shortCircuit('# && #'); |
5064 if (op == '||') return shortCircuit('# || #'); | 5083 if (op == '||') return shortCircuit('# || #'); |
5065 } | 5084 } |
5066 if (isReifiedCoercion(node)) { | 5085 if (isReifiedCoercion(node)) { |
5067 AsExpression asNode = node; | 5086 AsExpression asNode = node; |
5068 assert(asNode.staticType == types.boolType); | 5087 assert(asNode.staticType == types.boolType); |
5069 return js.call('dart.test(#)', _visit(asNode.expression)); | 5088 return js.call('dart.test(#)', _visit(asNode.expression)); |
5070 } | 5089 } |
5071 JS.Expression result = _visit(node); | 5090 JS.Expression result = _visit(node); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5270 // is exactly Future/Stream/Iterable. Handle the subtype case. | 5289 // is exactly Future/Stream/Iterable. Handle the subtype case. |
5271 return DynamicTypeImpl.instance; | 5290 return DynamicTypeImpl.instance; |
5272 } | 5291 } |
5273 } | 5292 } |
5274 | 5293 |
5275 /// Maps whitelisted files to a list of whitelisted methods | 5294 /// Maps whitelisted files to a list of whitelisted methods |
5276 /// within the file. | 5295 /// within the file. |
5277 /// | 5296 /// |
5278 /// If the value is null, the entire file is whitelisted. | 5297 /// If the value is null, the entire file is whitelisted. |
5279 static Map<String, List<String>> _uncheckedWhitelist = { | 5298 static Map<String, List<String>> _uncheckedWhitelist = { |
5280 'dom_renderer.dart': ['moveNodesAfterSibling',], | 5299 'dom_renderer.dart': [ |
5300 'moveNodesAfterSibling', | |
nweiz
2016/08/16 22:14:53
Nittiest of nits: for consistency, either remove t
Jennifer Messerly
2016/08/24 22:39:51
definitely. Yeah I honestly have no idea what this
| |
5301 ], | |
5281 'template_ref.dart': ['createEmbeddedView'], | 5302 'template_ref.dart': ['createEmbeddedView'], |
5282 'ng_class.dart': ['_applyIterableChanges'], | 5303 'ng_class.dart': ['_applyIterableChanges'], |
5283 'ng_for.dart': ['_bulkRemove', '_bulkInsert'], | 5304 'ng_for.dart': ['_bulkRemove', '_bulkInsert'], |
5284 'view_container_ref.dart': ['createEmbeddedView'], | 5305 'view_container_ref.dart': ['createEmbeddedView'], |
5285 'default_iterable_differ.dart': null, | 5306 'default_iterable_differ.dart': null, |
5286 }; | 5307 }; |
5287 | 5308 |
5288 static Set<String> _uncheckedWhitelistCalls = new Set() | 5309 static Set<String> _uncheckedWhitelistCalls = new Set() |
5289 ..add('ng_zone_impl.dart') | 5310 ..add('ng_zone_impl.dart') |
5290 ..add('stack_zone_specification.dart') | 5311 ..add('stack_zone_specification.dart') |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5367 } | 5388 } |
5368 | 5389 |
5369 bool isLibraryPrefix(Expression node) => | 5390 bool isLibraryPrefix(Expression node) => |
5370 node is SimpleIdentifier && node.staticElement is PrefixElement; | 5391 node is SimpleIdentifier && node.staticElement is PrefixElement; |
5371 | 5392 |
5372 LibraryElement _getLibrary(AnalysisContext c, String uri) => | 5393 LibraryElement _getLibrary(AnalysisContext c, String uri) => |
5373 c.computeLibraryElement(c.sourceFactory.forUri(uri)); | 5394 c.computeLibraryElement(c.sourceFactory.forUri(uri)); |
5374 | 5395 |
5375 bool _isDartRuntime(LibraryElement l) => | 5396 bool _isDartRuntime(LibraryElement l) => |
5376 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | 5397 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
OLD | NEW |