| OLD | NEW |
| 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 '../../tree_ir/tree_ir_nodes.dart' as tree_ir; | 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 js.Expression visitConcatenateStrings(tree_ir.ConcatenateStrings node) { | 137 js.Expression visitConcatenateStrings(tree_ir.ConcatenateStrings node) { |
| 138 js.Expression addStrings(js.Expression left, js.Expression right) { | 138 js.Expression addStrings(js.Expression left, js.Expression right) { |
| 139 return new js.Binary('+', left, right); | 139 return new js.Binary('+', left, right); |
| 140 } | 140 } |
| 141 | 141 |
| 142 js.Expression toString(tree_ir.Expression input) { | 142 js.Expression toString(tree_ir.Expression input) { |
| 143 bool useDirectly = input is tree_ir.Constant && | 143 bool useDirectly = input is tree_ir.Constant && |
| 144 (input.expression.value.isString || | 144 (input.expression.value.isString || |
| 145 input.expression.value.isInt || | 145 input.expression.value.isInt || |
| 146 input.expression.value.isBool); | 146 input.expression.value.isBool); |
| 147 js.Expression value = visit(input); | 147 js.Expression value = visitExpression(input); |
| 148 if (useDirectly) { | 148 if (useDirectly) { |
| 149 return value; | 149 return value; |
| 150 } else { | 150 } else { |
| 151 Element convertToString = glue.getStringConversion(); | 151 Element convertToString = glue.getStringConversion(); |
| 152 registry.registerStaticUse(convertToString); | 152 registry.registerStaticUse(convertToString); |
| 153 js.Expression access = glue.staticFunctionAccess(convertToString); | 153 js.Expression access = glue.staticFunctionAccess(convertToString); |
| 154 return (new js.Call(access, <js.Expression>[value])); | 154 return (new js.Call(access, <js.Expression>[value])); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 void visitSetField(tree_ir.SetField node) { | 535 void visitSetField(tree_ir.SetField node) { |
| 536 js.PropertyAccess field = | 536 js.PropertyAccess field = |
| 537 new js.PropertyAccess.field( | 537 new js.PropertyAccess.field( |
| 538 visitExpression(node.object), | 538 visitExpression(node.object), |
| 539 glue.instanceFieldPropertyName(node.field)); | 539 glue.instanceFieldPropertyName(node.field)); |
| 540 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); | 540 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); |
| 541 accumulator.add(new js.ExpressionStatement(asn)); | 541 accumulator.add(new js.ExpressionStatement(asn)); |
| 542 visitStatement(node.next); | 542 visitStatement(node.next); |
| 543 } | 543 } |
| 544 } | 544 } |
| OLD | NEW |