| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return new js.This(); | 338 return new js.This(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 @override | 341 @override |
| 342 js.Expression visitTypeOperator(tree_ir.TypeOperator node) { | 342 js.Expression visitTypeOperator(tree_ir.TypeOperator node) { |
| 343 return giveup(node); | 343 return giveup(node); |
| 344 // TODO: implement visitTypeOperator | 344 // TODO: implement visitTypeOperator |
| 345 } | 345 } |
| 346 | 346 |
| 347 @override | 347 @override |
| 348 js.Expression visitVariable(tree_ir.Variable node) { | 348 js.Expression visitVariableUse(tree_ir.VariableUse node) { |
| 349 return new js.VariableUse(getVariableName(node)); | 349 return buildVariableAccess(node.variable); |
| 350 } |
| 351 |
| 352 js.Expression buildVariableAccess(tree_ir.Variable variable) { |
| 353 return new js.VariableUse(getVariableName(variable)); |
| 350 } | 354 } |
| 351 | 355 |
| 352 @override | 356 @override |
| 353 void visitContinue(tree_ir.Continue node) { | 357 void visitContinue(tree_ir.Continue node) { |
| 354 tree_ir.Statement fallthrough = this.fallthrough; | 358 tree_ir.Statement fallthrough = this.fallthrough; |
| 355 if (node.target.binding == fallthrough) { | 359 if (node.target.binding == fallthrough) { |
| 356 // Fall through to continue target | 360 // Fall through to continue target |
| 357 } else if (fallthrough is tree_ir.Continue && | 361 } else if (fallthrough is tree_ir.Continue && |
| 358 fallthrough.target == node.target) { | 362 fallthrough.target == node.target) { |
| 359 // Fall through to equivalent continue | 363 // Fall through to equivalent continue |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 fallthrough = savedFallthrough; | 401 fallthrough = savedFallthrough; |
| 398 return result; | 402 return result; |
| 399 } | 403 } |
| 400 | 404 |
| 401 @override | 405 @override |
| 402 void visitAssign(tree_ir.Assign node) { | 406 void visitAssign(tree_ir.Assign node) { |
| 403 tree_ir.Expression value = node.definition; | 407 tree_ir.Expression value = node.definition; |
| 404 js.Expression definition = visitExpression(value); | 408 js.Expression definition = visitExpression(value); |
| 405 | 409 |
| 406 accumulator.add(new js.ExpressionStatement(new js.Assignment( | 410 accumulator.add(new js.ExpressionStatement(new js.Assignment( |
| 407 visitVariable(node.variable), | 411 buildVariableAccess(node.variable), |
| 408 definition))); | 412 definition))); |
| 409 visitStatement(node.next); | 413 visitStatement(node.next); |
| 410 } | 414 } |
| 411 | 415 |
| 412 @override | 416 @override |
| 413 void visitBreak(tree_ir.Break node) { | 417 void visitBreak(tree_ir.Break node) { |
| 414 tree_ir.Statement fallthrough = this.fallthrough; | 418 tree_ir.Statement fallthrough = this.fallthrough; |
| 415 if (node.target.binding.next == fallthrough) { | 419 if (node.target.binding.next == fallthrough) { |
| 416 // Fall through to break target | 420 // Fall through to break target |
| 417 } else if (fallthrough is tree_ir.Break && | 421 } else if (fallthrough is tree_ir.Break && |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 527 |
| 524 @override | 528 @override |
| 525 visitSuperInitializer(tree_ir.SuperInitializer node) { | 529 visitSuperInitializer(tree_ir.SuperInitializer node) { |
| 526 return errorUnsupportedNode(node); | 530 return errorUnsupportedNode(node); |
| 527 } | 531 } |
| 528 | 532 |
| 529 dynamic errorUnsupportedNode(tree_ir.DartSpecificNode node) { | 533 dynamic errorUnsupportedNode(tree_ir.DartSpecificNode node) { |
| 530 throw "Unsupported node in JS backend: $node"; | 534 throw "Unsupported node in JS backend: $node"; |
| 531 } | 535 } |
| 532 } | 536 } |
| OLD | NEW |