| 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 dart2js.ir_nodes_sexpr; | 5 library dart2js.ir_nodes_sexpr; |
| 6 | 6 |
| 7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
| 8 import '../util/util.dart'; | 8 import '../util/util.dart'; |
| 9 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
| 10 | 10 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 String visitConcatenateStrings(ConcatenateStrings node) { | 231 String visitConcatenateStrings(ConcatenateStrings node) { |
| 232 String cont = access(node.continuation); | 232 String cont = access(node.continuation); |
| 233 String args = node.arguments.map(access).join(' '); | 233 String args = node.arguments.map(access).join(' '); |
| 234 return '$indentation(ConcatenateStrings ($args) $cont)'; | 234 return '$indentation(ConcatenateStrings ($args) $cont)'; |
| 235 } | 235 } |
| 236 | 236 |
| 237 String visitInvokeContinuation(InvokeContinuation node) { | 237 String visitInvokeContinuation(InvokeContinuation node) { |
| 238 String name = access(node.continuation); | 238 String name = access(node.continuation); |
| 239 if (node.isRecursive) name = 'rec $name'; | 239 if (node.isRecursive) name = 'rec $name'; |
| 240 String args = node.arguments.map(access).join(' '); | 240 String args = node.arguments.map(access).join(' '); |
| 241 return '$indentation($InvokeContinuation $name ($args))'; | 241 return '$indentation(InvokeContinuation $name ($args))'; |
| 242 } |
| 243 |
| 244 String visitThrow(Throw node) { |
| 245 String value = access(node.value); |
| 246 return '$indentation(Throw $value)'; |
| 247 } |
| 248 |
| 249 String visitRethrow(Rethrow node) { |
| 250 return '$indentation(Rethrow)'; |
| 242 } | 251 } |
| 243 | 252 |
| 244 String visitBranch(Branch node) { | 253 String visitBranch(Branch node) { |
| 245 String condition = visit(node.condition); | 254 String condition = visit(node.condition); |
| 246 String trueCont = access(node.trueContinuation); | 255 String trueCont = access(node.trueContinuation); |
| 247 String falseCont = access(node.falseContinuation); | 256 String falseCont = access(node.falseContinuation); |
| 248 return '$indentation(Branch $condition $trueCont $falseCont)'; | 257 return '$indentation(Branch $condition $trueCont $falseCont)'; |
| 249 } | 258 } |
| 250 | 259 |
| 251 String visitConstant(Constant node) { | 260 String visitConstant(Constant node) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 357 } |
| 349 | 358 |
| 350 String visitReifyRuntimeType(ReifyRuntimeType node) { | 359 String visitReifyRuntimeType(ReifyRuntimeType node) { |
| 351 return '(ReifyRuntimeType ${access(node.value)})'; | 360 return '(ReifyRuntimeType ${access(node.value)})'; |
| 352 } | 361 } |
| 353 | 362 |
| 354 String visitReadTypeVariable(ReadTypeVariable node) { | 363 String visitReadTypeVariable(ReadTypeVariable node) { |
| 355 return '(ReadTypeVariable ${access(node.target)}.${node.variable})'; | 364 return '(ReadTypeVariable ${access(node.target)}.${node.variable})'; |
| 356 } | 365 } |
| 357 | 366 |
| 358 @override | |
| 359 String visitTypeExpression(TypeExpression node) { | 367 String visitTypeExpression(TypeExpression node) { |
| 360 String args = node.arguments.map(access).join(', '); | 368 String args = node.arguments.map(access).join(', '); |
| 361 return '(TypeExpression ${node.dartType.toString()} $args)'; | 369 return '(TypeExpression ${node.dartType.toString()} $args)'; |
| 362 } | 370 } |
| 371 |
| 372 String visitNonTailThrow(NonTailThrow node) { |
| 373 String value = access(node.value); |
| 374 return '(NonTailThrow $value)'; |
| 375 } |
| 363 } | 376 } |
| 364 | 377 |
| 365 class ConstantStringifier extends ConstantValueVisitor<String, Null> { | 378 class ConstantStringifier extends ConstantValueVisitor<String, Null> { |
| 366 // Some of these methods are unimplemented because we haven't had a need | 379 // Some of these methods are unimplemented because we haven't had a need |
| 367 // to print such constants. When printing is implemented, the corresponding | 380 // to print such constants. When printing is implemented, the corresponding |
| 368 // parsing support should be added to SExpressionUnstringifier.parseConstant | 381 // parsing support should be added to SExpressionUnstringifier.parseConstant |
| 369 // in the dart2js tests (currently in the file | 382 // in the dart2js tests (currently in the file |
| 370 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). | 383 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). |
| 371 | 384 |
| 372 String _failWith(ConstantValue constant) { | 385 String _failWith(ConstantValue constant) { |
| 373 throw 'Stringification not supported for ${constant.toStructuredString()}'; | 386 throw 'Stringification not supported for ${constant.toStructuredString()}'; |
| 374 } | 387 } |
| 375 | 388 |
| 376 String visitFunction(FunctionConstantValue constant, _) { | 389 String visitFunction(FunctionConstantValue constant, _) { |
| 377 return _failWith(constant); | 390 return '(Function "${constant.unparse()}")'; |
| 378 } | 391 } |
| 379 | 392 |
| 380 String visitNull(NullConstantValue constant, _) { | 393 String visitNull(NullConstantValue constant, _) { |
| 381 return '(Null)'; | 394 return '(Null)'; |
| 382 } | 395 } |
| 383 | 396 |
| 384 String visitInt(IntConstantValue constant, _) { | 397 String visitInt(IntConstantValue constant, _) { |
| 385 return '(Int ${constant.unparse()})'; | 398 return '(Int ${constant.unparse()})'; |
| 386 } | 399 } |
| 387 | 400 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 assert(!_names.containsKey(node)); | 476 assert(!_names.containsKey(node)); |
| 464 return _names[node] = 'v${_valueCounter++}'; | 477 return _names[node] = 'v${_valueCounter++}'; |
| 465 } | 478 } |
| 466 | 479 |
| 467 void setReturnContinuation(Continuation node) { | 480 void setReturnContinuation(Continuation node) { |
| 468 assert(!_names.containsKey(node) || _names[node] == 'return'); | 481 assert(!_names.containsKey(node) || _names[node] == 'return'); |
| 469 _names[node] = 'return'; | 482 _names[node] = 'return'; |
| 470 } | 483 } |
| 471 | 484 |
| 472 String getName(Node node) { | 485 String getName(Node node) { |
| 473 assert(_names.containsKey(node)); | 486 if (!_names.containsKey(node)) return 'MISSING_NAME'; |
| 474 return _names[node]; | 487 return _names[node]; |
| 475 } | 488 } |
| 476 } | 489 } |
| OLD | NEW |