| 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 dart_backend.tracer; | 5 library dart_backend.tracer; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink; | 7 import 'dart:async' show EventSink; |
| 8 import '../tracer.dart'; | 8 import '../tracer.dart'; |
| 9 import 'dart_tree.dart'; | 9 import 'dart_tree.dart'; |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 visitStatement(function.body); | 54 visitStatement(function.body); |
| 55 } | 55 } |
| 56 | 56 |
| 57 visitVariable(Variable node) {} | 57 visitVariable(Variable node) {} |
| 58 visitInvokeStatic(InvokeStatic node) {} | 58 visitInvokeStatic(InvokeStatic node) {} |
| 59 visitInvokeMethod(InvokeMethod node) {} | 59 visitInvokeMethod(InvokeMethod node) {} |
| 60 visitInvokeConstructor(InvokeConstructor node) {} | 60 visitInvokeConstructor(InvokeConstructor node) {} |
| 61 visitConcatenateStrings(ConcatenateStrings node) {} | 61 visitConcatenateStrings(ConcatenateStrings node) {} |
| 62 visitLiteralList(LiteralList node) {} | 62 visitLiteralList(LiteralList node) {} |
| 63 visitLiteralMap(LiteralMap node) {} | 63 visitLiteralMap(LiteralMap node) {} |
| 64 visitInvokeConstConstructor(InvokeConstConstructor node) {} | |
| 65 visitConstant(Constant node) {} | 64 visitConstant(Constant node) {} |
| 66 visitConditional(Conditional node) {} | 65 visitConditional(Conditional node) {} |
| 67 visitLogicalOperator(LogicalOperator node) {} | 66 visitLogicalOperator(LogicalOperator node) {} |
| 68 visitNot(Not node) {} | 67 visitNot(Not node) {} |
| 69 | 68 |
| 70 visitLabeledStatement(LabeledStatement node) { | 69 visitLabeledStatement(LabeledStatement node) { |
| 71 Block target = new Block(node.label); | 70 Block target = new Block(node.label); |
| 72 breakTargets[node.label] = target; | 71 breakTargets[node.label] = target; |
| 73 visitStatement(node.body); | 72 visitStatement(node.body); |
| 74 _addBlock(target); | 73 _addBlock(target); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 304 } |
| 306 | 305 |
| 307 String visitInvokeConstructor(InvokeConstructor node) { | 306 String visitInvokeConstructor(InvokeConstructor node) { |
| 308 String callName; | 307 String callName; |
| 309 if (node.target.name.isEmpty) { | 308 if (node.target.name.isEmpty) { |
| 310 callName = '${node.type}'; | 309 callName = '${node.type}'; |
| 311 } else { | 310 } else { |
| 312 callName = '${node.type}.${node.target.name}'; | 311 callName = '${node.type}.${node.target.name}'; |
| 313 } | 312 } |
| 314 String args = formatArguments(node); | 313 String args = formatArguments(node); |
| 315 return "new $callName($args)"; | 314 String keyword = node.constant != null ? 'const' : 'new'; |
| 315 return "$keyword $callName($args)"; |
| 316 } | 316 } |
| 317 | 317 |
| 318 String visitConcatenateStrings(ConcatenateStrings node) { | 318 String visitConcatenateStrings(ConcatenateStrings node) { |
| 319 String args = node.arguments.map(visitExpression).join(', '); | 319 String args = node.arguments.map(visitExpression).join(', '); |
| 320 return "concat [$args]"; | 320 return "concat [$args]"; |
| 321 } | 321 } |
| 322 | 322 |
| 323 String visitLiteralList(LiteralList node) { | 323 String visitLiteralList(LiteralList node) { |
| 324 String values = node.values.map(visitExpression).join(', '); | 324 String values = node.values.map(visitExpression).join(', '); |
| 325 return "list [$values]"; | 325 return "list [$values]"; |
| 326 } | 326 } |
| 327 | 327 |
| 328 String visitLiteralMap(LiteralMap node) { | 328 String visitLiteralMap(LiteralMap node) { |
| 329 List<String> entries = new List<String>(); | 329 List<String> entries = new List<String>(); |
| 330 for (int i = 0; i < node.values.length; ++i) { | 330 for (int i = 0; i < node.values.length; ++i) { |
| 331 String key = visitExpression(node.keys[i]); | 331 String key = visitExpression(node.keys[i]); |
| 332 String value = visitExpression(node.values[i]); | 332 String value = visitExpression(node.values[i]); |
| 333 entries.add("$key: $value"); | 333 entries.add("$key: $value"); |
| 334 } | 334 } |
| 335 return "map [${entries.join(', ')}]"; | 335 return "map [${entries.join(', ')}]"; |
| 336 } | 336 } |
| 337 | 337 |
| 338 String visitInvokeConstConstructor(InvokeConstConstructor node) { | |
| 339 String callName; | |
| 340 if (node.target.name.isEmpty) { | |
| 341 callName = '${node.type}'; | |
| 342 } else { | |
| 343 callName = '${node.type}.${node.target.name}'; | |
| 344 } | |
| 345 String arguments = node.arguments.map(visitExpression).join(', '); | |
| 346 return "const $callName($arguments)"; | |
| 347 } | |
| 348 | |
| 349 String visitConstant(Constant node) { | 338 String visitConstant(Constant node) { |
| 350 return "${node.value}"; | 339 return "${node.value}"; |
| 351 } | 340 } |
| 352 | 341 |
| 353 bool usesInfixNotation(Expression node) { | 342 bool usesInfixNotation(Expression node) { |
| 354 return node is Conditional || node is LogicalOperator; | 343 return node is Conditional || node is LogicalOperator; |
| 355 } | 344 } |
| 356 | 345 |
| 357 String visitConditional(Conditional node) { | 346 String visitConditional(Conditional node) { |
| 358 String condition = visitExpression(node.condition); | 347 String condition = visitExpression(node.condition); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 String prefix = v.element == null ? 'v' : '${v.element.name}_'; | 390 String prefix = v.element == null ? 'v' : '${v.element.name}_'; |
| 402 while (name == null || _usedNames.contains(name)) { | 391 while (name == null || _usedNames.contains(name)) { |
| 403 name = "$prefix${_counter++}"; | 392 name = "$prefix${_counter++}"; |
| 404 } | 393 } |
| 405 _names[v] = name; | 394 _names[v] = name; |
| 406 _usedNames.add(name); | 395 _usedNames.add(name); |
| 407 } | 396 } |
| 408 return name; | 397 return name; |
| 409 } | 398 } |
| 410 } | 399 } |
| OLD | NEW |