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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1564423002: Copy all fields of NullCheck (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../closure.dart' show 9 import '../../closure.dart' show
10 ClosureClassElement; 10 ClosureClassElement;
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 @override 1014 @override
1015 void visitYield(tree_ir.Yield node) { 1015 void visitYield(tree_ir.Yield node) {
1016 js.Expression value = visitExpression(node.input); 1016 js.Expression value = visitExpression(node.input);
1017 accumulator.add(new js.DartYield(value, node.hasStar)); 1017 accumulator.add(new js.DartYield(value, node.hasStar));
1018 visitStatement(node.next); 1018 visitStatement(node.next);
1019 } 1019 }
1020 1020
1021 @override 1021 @override
1022 void visitNullCheck(tree_ir.NullCheck node) { 1022 void visitNullCheck(tree_ir.NullCheck node) {
1023 js.Expression value = visitExpression(node.value); 1023 js.Expression value = visitExpression(node.value);
1024 js.Expression access = node.selector != null 1024 // TODO(sra): Try to use the selector even when [useSelector] is false. The
1025 // reason we use 'toString' is that it is always defined so avoids a slow
1026 // lookup (in V8) of an absent property. We could use the property for the
1027 // selector if we knew it was present. The property is present if the
1028 // associated method was not inlined away, or if there is a noSuchMethod
1029 // hook for that selector. We don't know these things here, but the decision
1030 // could be deferred by creating a deferred property that was resolved after
1031 // codegen.
1032 js.Expression access = node.selector != null && node.useSelector
1025 ? js.js('#.#', [value, glue.invocationName(node.selector)]) 1033 ? js.js('#.#', [value, glue.invocationName(node.selector)])
1026 : js.js('#.toString', [value]); 1034 : js.js('#.toString', [value]);
1027 if (node.condition != null) { 1035 if (node.condition != null) {
1028 js.Expression condition = visitExpression(node.condition); 1036 js.Expression condition = visitExpression(node.condition);
1029 js.Statement body = isNullReturn(node.next) 1037 js.Statement body = isNullReturn(node.next)
1030 ? new js.ExpressionStatement(access) 1038 ? new js.ExpressionStatement(access)
1031 : new js.Return(access); 1039 : new js.Return(access);
1032 accumulator.add(new js.If.noElse(condition, body)); 1040 accumulator.add(new js.If.noElse(condition, body));
1033 } else { 1041 } else {
1034 accumulator.add(new js.ExpressionStatement(access)); 1042 accumulator.add(new js.ExpressionStatement(access));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 void registerDefaultParameterValues(ExecutableElement element) { 1222 void registerDefaultParameterValues(ExecutableElement element) {
1215 if (element is! FunctionElement) return; 1223 if (element is! FunctionElement) return;
1216 FunctionElement function = element; 1224 FunctionElement function = element;
1217 if (function.isStatic) return; // Defaults are inlined at call sites. 1225 if (function.isStatic) return; // Defaults are inlined at call sites.
1218 function.functionSignature.forEachOptionalParameter((param) { 1226 function.functionSignature.forEachOptionalParameter((param) {
1219 ConstantValue constant = glue.getDefaultParameterValue(param); 1227 ConstantValue constant = glue.getDefaultParameterValue(param);
1220 registry.registerCompileTimeConstant(constant); 1228 registry.registerCompileTimeConstant(constant);
1221 }); 1229 });
1222 } 1230 }
1223 } 1231 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/inline.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698