Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 throw 'No case implemented to handle $target'; | 145 throw 'No case implemented to handle $target'; |
| 146 } | 146 } |
| 147 assert(graph.isValid()); | 147 assert(graph.isValid()); |
| 148 return graph; | 148 return graph; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void buildField(ir.Field field) { | 151 void buildField(ir.Field field) { |
| 152 openFunction(); | 152 openFunction(); |
| 153 if (field.initializer != null) { | 153 if (field.initializer != null) { |
| 154 field.initializer.accept(this); | 154 field.initializer.accept(this); |
| 155 HInstruction fieldValue = pop(); | |
| 156 HInstruction checkInstruction = typeBuilder.potentiallyCheckOrTrustType( | |
| 157 fieldValue, astAdapter.getDartType(field.type)); | |
| 158 stack.add(checkInstruction); | |
| 155 } else { | 159 } else { |
| 156 stack.add(graph.addConstantNull(compiler)); | 160 stack.add(graph.addConstantNull(compiler)); |
| 157 } | 161 } |
| 158 HInstruction value = pop(); | 162 HInstruction value = pop(); |
| 159 closeAndGotoExit(new HReturn(value, null)); | 163 closeAndGotoExit(new HReturn(value, null)); |
| 160 closeFunction(); | 164 closeFunction(); |
| 161 } | 165 } |
| 162 | 166 |
| 163 /// Pops the most recent instruction from the stack and 'boolifies' it. | 167 /// Pops the most recent instruction from the stack and 'boolifies' it. |
| 164 /// | 168 /// |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1043 _visitLocalSetter(variableSet.variable, value); | 1047 _visitLocalSetter(variableSet.variable, value); |
| 1044 } | 1048 } |
| 1045 | 1049 |
| 1046 @override | 1050 @override |
| 1047 void visitVariableDeclaration(ir.VariableDeclaration declaration) { | 1051 void visitVariableDeclaration(ir.VariableDeclaration declaration) { |
| 1048 Local local = astAdapter.getLocal(declaration); | 1052 Local local = astAdapter.getLocal(declaration); |
| 1049 if (declaration.initializer == null) { | 1053 if (declaration.initializer == null) { |
| 1050 HInstruction initialValue = graph.addConstantNull(compiler); | 1054 HInstruction initialValue = graph.addConstantNull(compiler); |
| 1051 localsHandler.updateLocal(local, initialValue); | 1055 localsHandler.updateLocal(local, initialValue); |
| 1052 } else { | 1056 } else { |
| 1053 // TODO(het): handle case where the variable is top-level or static | |
| 1054 declaration.initializer.accept(this); | 1057 declaration.initializer.accept(this); |
| 1055 HInstruction initialValue = pop(); | 1058 HInstruction initialValue = pop(); |
| 1056 | 1059 |
| 1057 _visitLocalSetter(declaration, initialValue); | 1060 _visitLocalSetter(declaration, initialValue); |
|
Siggi Cherem (dart-lang)
2016/12/07 17:38:00
do we also need the potentiallyCheckOrTrustType on
Emily Fortuna
2016/12/07 18:08:13
we already do. See line 1076!
| |
| 1058 | 1061 |
| 1059 // Ignore value | 1062 // Ignore value |
| 1060 pop(); | 1063 pop(); |
| 1061 } | 1064 } |
| 1062 } | 1065 } |
| 1063 | 1066 |
| 1064 void _visitLocalSetter(ir.VariableDeclaration variable, HInstruction value) { | 1067 void _visitLocalSetter(ir.VariableDeclaration variable, HInstruction value) { |
| 1065 // TODO(het): handle case where the variable is top-level or static | |
| 1066 LocalElement local = astAdapter.getElement(variable); | 1068 LocalElement local = astAdapter.getElement(variable); |
| 1067 | 1069 |
| 1068 // Give the value a name if it doesn't have one already. | 1070 // Give the value a name if it doesn't have one already. |
| 1069 if (value.sourceElement == null) { | 1071 if (value.sourceElement == null) { |
| 1070 value.sourceElement = local; | 1072 value.sourceElement = local; |
| 1071 } | 1073 } |
| 1072 | 1074 |
| 1073 stack.add(value); | 1075 stack.add(value); |
| 1074 localsHandler.updateLocal( | 1076 localsHandler.updateLocal( |
| 1075 local, | 1077 local, |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1847 push(new HNot(popBoolified(), backend.boolType)); | 1849 push(new HNot(popBoolified(), backend.boolType)); |
| 1848 } | 1850 } |
| 1849 | 1851 |
| 1850 @override | 1852 @override |
| 1851 void visitStringConcatenation(ir.StringConcatenation stringConcat) { | 1853 void visitStringConcatenation(ir.StringConcatenation stringConcat) { |
| 1852 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); | 1854 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); |
| 1853 stringConcat.accept(stringBuilder); | 1855 stringConcat.accept(stringBuilder); |
| 1854 stack.add(stringBuilder.result); | 1856 stack.add(stringBuilder.result); |
| 1855 } | 1857 } |
| 1856 } | 1858 } |
| OLD | NEW |