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

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

Issue 2514833003: Fix dart2js/analyze_unused_dart2js_test. (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
9 import '../common/names.dart'; 9 import '../common/names.dart';
10 import '../common/tasks.dart' show CompilerTask; 10 import '../common/tasks.dart' show CompilerTask;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 buildConstructor(target); 118 buildConstructor(target);
119 } 119 }
120 assert(graph.isValid()); 120 assert(graph.isValid());
121 return graph; 121 return graph;
122 } 122 }
123 123
124 void buildField(ir.Field field) { 124 void buildField(ir.Field field) {
125 openFunction(); 125 openFunction();
126 if (field.initializer != null) { 126 if (field.initializer != null) {
127 field.initializer.accept(this); 127 field.initializer.accept(this);
128 HInstruction fieldValue = pop();
129 HInstruction checkInstruction = typeBuilder.potentiallyCheckOrTrustType(
130 fieldValue, astAdapter.getDartType(field.type));
131 stack.add(checkInstruction);
128 } else { 132 } else {
129 stack.add(graph.addConstantNull(compiler)); 133 stack.add(graph.addConstantNull(compiler));
130 } 134 }
131 HInstruction value = pop(); 135 HInstruction value = pop();
132 closeAndGotoExit(new HReturn(value, null)); 136 closeAndGotoExit(new HReturn(value, null));
133 closeFunction(); 137 closeFunction();
134 } 138 }
135 139
136 /// Pops the most recent instruction from the stack and 'boolifies' it. 140 /// Pops the most recent instruction from the stack and 'boolifies' it.
137 /// 141 ///
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 _visitLocalSetter(variableSet.variable, value); 923 _visitLocalSetter(variableSet.variable, value);
920 } 924 }
921 925
922 @override 926 @override
923 void visitVariableDeclaration(ir.VariableDeclaration declaration) { 927 void visitVariableDeclaration(ir.VariableDeclaration declaration) {
924 Local local = astAdapter.getLocal(declaration); 928 Local local = astAdapter.getLocal(declaration);
925 if (declaration.initializer == null) { 929 if (declaration.initializer == null) {
926 HInstruction initialValue = graph.addConstantNull(compiler); 930 HInstruction initialValue = graph.addConstantNull(compiler);
927 localsHandler.updateLocal(local, initialValue); 931 localsHandler.updateLocal(local, initialValue);
928 } else { 932 } else {
929 // TODO(het): handle case where the variable is top-level or static
930 declaration.initializer.accept(this); 933 declaration.initializer.accept(this);
931 HInstruction initialValue = pop(); 934 HInstruction initialValue = pop();
932 935
933 _visitLocalSetter(declaration, initialValue); 936 _visitLocalSetter(declaration, initialValue);
934 937
935 // Ignore value 938 // Ignore value
936 pop(); 939 pop();
937 } 940 }
938 } 941 }
939 942
940 void _visitLocalSetter(ir.VariableDeclaration variable, HInstruction value) { 943 void _visitLocalSetter(ir.VariableDeclaration variable, HInstruction value) {
941 // TODO(het): handle case where the variable is top-level or static
942 LocalElement local = astAdapter.getElement(variable); 944 LocalElement local = astAdapter.getElement(variable);
943 945
944 // Give the value a name if it doesn't have one already. 946 // Give the value a name if it doesn't have one already.
945 if (value.sourceElement == null) { 947 if (value.sourceElement == null) {
946 value.sourceElement = local; 948 value.sourceElement = local;
947 } 949 }
948 950
949 stack.add(value); 951 stack.add(value);
950 localsHandler.updateLocal( 952 localsHandler.updateLocal(
951 local, 953 local,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 push(new HNot(popBoolified(), backend.boolType)); 1125 push(new HNot(popBoolified(), backend.boolType));
1124 } 1126 }
1125 1127
1126 @override 1128 @override
1127 void visitStringConcatenation(ir.StringConcatenation stringConcat) { 1129 void visitStringConcatenation(ir.StringConcatenation stringConcat) {
1128 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); 1130 KernelStringBuilder stringBuilder = new KernelStringBuilder(this);
1129 stringConcat.accept(stringBuilder); 1131 stringConcat.accept(stringBuilder);
1130 stack.add(stringBuilder.result); 1132 stack.add(stringBuilder.result);
1131 } 1133 }
1132 } 1134 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698