OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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:math' as math; | 5 import 'dart:math' as math; |
6 import '../common.dart'; | 6 import '../common.dart'; |
7 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 7 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
8 import '../common/tasks.dart' show CompilerTask; | 8 import '../common/tasks.dart' show CompilerTask; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../constants/constant_system.dart'; | 10 import '../constants/constant_system.dart'; |
(...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2065 // Use !0 for true, !1 for false. | 2065 // Use !0 for true, !1 for false. |
2066 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")) | 2066 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")) |
2067 .withSourceInformation(sourceInformation); | 2067 .withSourceInformation(sourceInformation); |
2068 } else { | 2068 } else { |
2069 return new js.LiteralBool(value).withSourceInformation(sourceInformation); | 2069 return new js.LiteralBool(value).withSourceInformation(sourceInformation); |
2070 } | 2070 } |
2071 } | 2071 } |
2072 | 2072 |
2073 void generateConstant( | 2073 void generateConstant( |
2074 ConstantValue constant, SourceInformation sourceInformation) { | 2074 ConstantValue constant, SourceInformation sourceInformation) { |
2075 if (constant.isFunction) { | |
2076 FunctionConstantValue function = constant; | |
2077 registry.registerStaticUse(new StaticUse.staticTearOff(function.element)); | |
Siggi Cherem (dart-lang)
2017/03/14 05:48:40
I saw the changes below in the listener, but is th
Johnni Winther
2017/03/15 13:47:05
Yes.
| |
2078 } | |
2079 if (constant.isType) { | |
2080 // If the type is a web component, we need to ensure the constructors are | |
2081 // available to 'upgrade' the native object. | |
2082 TypeConstantValue type = constant; | |
2083 if (type.representedType.isInterfaceType) { | |
2084 InterfaceType representedType = type.representedType; | |
2085 registry.registerTypeConstant(representedType.element); | |
2086 } | |
2087 } | |
2088 js.Expression expression = backend.emitter.constantReference(constant); | 2075 js.Expression expression = backend.emitter.constantReference(constant); |
2089 if (!constant.isDummy) { | 2076 if (!constant.isDummy) { |
2090 // TODO(johnniwinther): Support source information on synthetic constants. | 2077 // TODO(johnniwinther): Support source information on synthetic constants. |
2091 expression = expression.withSourceInformation(sourceInformation); | 2078 expression = expression.withSourceInformation(sourceInformation); |
2092 } | 2079 } |
2093 push(expression); | 2080 push(expression); |
2094 } | 2081 } |
2095 | 2082 |
2096 visitConstant(HConstant node) { | 2083 visitConstant(HConstant node) { |
2097 assert(isGenerateAtUseSite(node)); | 2084 assert(isGenerateAtUseSite(node)); |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3128 registry.registerStaticUse(new StaticUse.staticInvoke( | 3115 registry.registerStaticUse(new StaticUse.staticInvoke( |
3129 helper, new CallStructure.unnamed(argumentCount))); | 3116 helper, new CallStructure.unnamed(argumentCount))); |
3130 return backend.emitter.staticFunctionAccess(helper); | 3117 return backend.emitter.staticFunctionAccess(helper); |
3131 } | 3118 } |
3132 | 3119 |
3133 @override | 3120 @override |
3134 void visitRef(HRef node) { | 3121 void visitRef(HRef node) { |
3135 visit(node.value); | 3122 visit(node.value); |
3136 } | 3123 } |
3137 } | 3124 } |
OLD | NEW |