Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2931153002: Support field initializers and static/top-level fields in compile_with_dill_test (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:js_runtime/shared/embedded_names.dart'; 5 import 'package:js_runtime/shared/embedded_names.dart';
6 import 'package:kernel/ast.dart' as ir; 6 import 'package:kernel/ast.dart' as ir;
7 7
8 import '../closure.dart'; 8 import '../closure.dart';
9 import '../common.dart'; 9 import '../common.dart';
10 import '../compiler.dart'; 10 import '../compiler.dart';
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 _compiler.backend.constants.evaluate(constant); 92 _compiler.backend.constants.evaluate(constant);
93 ConstantValue value = 93 ConstantValue value =
94 _compiler.backend.constants.getConstantValue(constant); 94 _compiler.backend.constants.getConstantValue(constant);
95 if (value == null && requireConstant) { 95 if (value == null && requireConstant) {
96 throw new UnsupportedError( 96 throw new UnsupportedError(
97 'No constant value for ${constant.toStructuredText()}'); 97 'No constant value for ${constant.toStructuredText()}');
98 } 98 }
99 return value; 99 return value;
100 } 100 }
101 101
102 @override
103 ConstantValue getFieldConstantValue(ir.Field field) {
104 FieldElement element = getField(field);
105 if (element.constant != null) {
106 return computeConstantValue(element.constant);
107 }
108 return null;
109 }
110
102 /// Called to find the corresponding Kernel element for a particular Element 111 /// Called to find the corresponding Kernel element for a particular Element
103 /// before traversing over it with a Kernel visitor. 112 /// before traversing over it with a Kernel visitor.
104 ir.Node getInitialKernelNode(MemberElement originTarget) { 113 ir.Node getInitialKernelNode(MemberElement originTarget) {
105 ir.Node target; 114 ir.Node target;
106 if (originTarget.isPatch) { 115 if (originTarget.isPatch) {
107 originTarget = originTarget.origin; 116 originTarget = originTarget.origin;
108 } 117 }
109 if (originTarget is MethodElement) { 118 if (originTarget is MethodElement) {
110 if (originTarget is ConstructorBodyElement) { 119 if (originTarget is ConstructorBodyElement) {
111 ConstructorBodyElement body = originTarget; 120 ConstructorBodyElement body = originTarget;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 @override 221 @override
213 Local getLocal(ir.VariableDeclaration variable) { 222 Local getLocal(ir.VariableDeclaration variable) {
214 // If this is a synthetic local, return the synthetic local 223 // If this is a synthetic local, return the synthetic local
215 if (variable.name == null) { 224 if (variable.name == null) {
216 return _syntheticLocals.putIfAbsent( 225 return _syntheticLocals.putIfAbsent(
217 variable, () => new SyntheticLocal("x", null, null)); 226 variable, () => new SyntheticLocal("x", null, null));
218 } 227 }
219 return getElement(variable) as LocalElement; 228 return getElement(variable) as LocalElement;
220 } 229 }
221 230
222 // Is the member a lazy initialized static or top-level member?
223 bool isLazyStatic(ir.Member member) {
224 if (member is ir.Field) {
225 FieldElement field = _nodeToElement[member];
226 return field.constant == null;
227 }
228 return false;
229 }
230
231 KernelJumpTarget getJumpTarget(ir.TreeNode node, 231 KernelJumpTarget getJumpTarget(ir.TreeNode node,
232 {bool isContinueTarget: false}) { 232 {bool isContinueTarget: false}) {
233 return _jumpTargets.putIfAbsent(node, () { 233 return _jumpTargets.putIfAbsent(node, () {
234 if (node is ir.LabeledStatement && _jumpTargets.containsKey(node.body)) { 234 if (node is ir.LabeledStatement && _jumpTargets.containsKey(node.body)) {
235 return _jumpTargets[node.body]; 235 return _jumpTargets[node.body];
236 } 236 }
237 return new KernelJumpTarget(node, this, 237 return new KernelJumpTarget(node, this,
238 makeContinueLabel: isContinueTarget); 238 makeContinueLabel: isContinueTarget);
239 }); 239 });
240 } 240 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { 635 TypeMask selectorTypeOf(Selector selector, TypeMask mask) {
636 return TypeMaskFactory.inferredTypeForSelector( 636 return TypeMaskFactory.inferredTypeForSelector(
637 selector, mask, _globalInferenceResults); 637 selector, mask, _globalInferenceResults);
638 } 638 }
639 639
640 TypeMask typeFromNativeBehavior( 640 TypeMask typeFromNativeBehavior(
641 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { 641 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) {
642 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); 642 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld);
643 } 643 }
644 } 644 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | tests/compiler/dart2js/kernel/compile_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698