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

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

Issue 2684783003: Refactor ConstantSystem (Closed)
Patch Set: Updated cf. comments. Created 3 years, 10 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 '../common.dart'; 8 import '../common.dart';
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 GlobalTypeInferenceResults get _globalInferenceResults => 106 GlobalTypeInferenceResults get _globalInferenceResults =>
107 _compiler.globalInference.results; 107 _compiler.globalInference.results;
108 108
109 GlobalTypeInferenceElementResult _resultOf(Element e) => 109 GlobalTypeInferenceElementResult _resultOf(Element e) =>
110 _globalInferenceResults 110 _globalInferenceResults
111 .resultOf(e is ConstructorBodyElementX ? e.constructor : e); 111 .resultOf(e is ConstructorBodyElementX ? e.constructor : e);
112 112
113 ConstantValue getConstantForSymbol(ir.SymbolLiteral node) { 113 ConstantValue getConstantForSymbol(ir.SymbolLiteral node) {
114 if (kernel.syntheticNodes.contains(node)) { 114 if (kernel.syntheticNodes.contains(node)) {
115 return _backend.constantSystem.createSymbol(_compiler, node.value); 115 return _backend.constantSystem.createSymbol(
116 _compiler.commonElements, _backend.backendClasses, node.value);
116 } 117 }
117 ast.Node astNode = getNode(node); 118 ast.Node astNode = getNode(node);
118 ConstantValue constantValue = _backend.constants 119 ConstantValue constantValue = _backend.constants
119 .getConstantValueForNode(astNode, _resolvedAst.elements); 120 .getConstantValueForNode(astNode, _resolvedAst.elements);
120 assert(invariant(astNode, constantValue != null, 121 assert(invariant(astNode, constantValue != null,
121 message: 'No constant computed for $node')); 122 message: 'No constant computed for $node'));
122 return constantValue; 123 return constantValue;
123 } 124 }
124 125
125 // TODO(johnniwinther): Use the more precise functions below. 126 // TODO(johnniwinther): Use the more precise functions below.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // defaultExpression.accept(new Constantifier(this)); 305 // defaultExpression.accept(new Constantifier(this));
305 // assert(constantExpression != null); 306 // assert(constantExpression != null);
306 ConstantExpression constantExpression = 307 ConstantExpression constantExpression =
307 kernel.parameterInitializerNodeToConstant[defaultExpression]; 308 kernel.parameterInitializerNodeToConstant[defaultExpression];
308 if (constantExpression == null) return null; 309 if (constantExpression == null) return null;
309 return _backend.constants.getConstantValue(constantExpression); 310 return _backend.constants.getConstantValue(constantExpression);
310 } 311 }
311 312
312 ConstantValue getConstantForType(ir.DartType irType) { 313 ConstantValue getConstantForType(ir.DartType irType) {
313 ResolutionDartType type = getDartType(irType); 314 ResolutionDartType type = getDartType(irType);
314 return _backend.constantSystem.createType(_compiler, type.asRaw()); 315 return _backend.constantSystem.createType(
316 _compiler.commonElements, _backend.backendClasses, type.asRaw());
315 } 317 }
316 318
317 bool isIntercepted(ir.Node node) { 319 bool isIntercepted(ir.Node node) {
318 Selector selector = getSelector(node); 320 Selector selector = getSelector(node);
319 return _backend.interceptorData.isInterceptedSelector(selector); 321 return _backend.interceptorData.isInterceptedSelector(selector);
320 } 322 }
321 323
322 bool isInterceptedSelector(Selector selector) { 324 bool isInterceptedSelector(Selector selector) {
323 return _backend.interceptorData.isInterceptedSelector(selector); 325 return _backend.interceptorData.isInterceptedSelector(selector);
324 } 326 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 JumpTarget continueTarget = 828 JumpTarget continueTarget =
827 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); 829 astAdapter.getJumpTarget(switchCase, isContinueTarget: true);
828 assert(continueTarget is KernelJumpTarget); 830 assert(continueTarget is KernelJumpTarget);
829 targetIndexMap[continueTarget] = switchIndex; 831 targetIndexMap[continueTarget] = switchIndex;
830 assert(builder.jumpTargets[continueTarget] == null); 832 assert(builder.jumpTargets[continueTarget] == null);
831 builder.jumpTargets[continueTarget] = this; 833 builder.jumpTargets[continueTarget] = this;
832 switchIndex++; 834 switchIndex++;
833 } 835 }
834 } 836 }
835 } 837 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698