| 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_codegen; | 5 library dart_codegen; |
| 6 | 6 |
| 7 import 'dart_tree.dart' as tree; | 7 import 'dart_tree.dart' as tree; |
| 8 import 'dart_printer.dart'; | 8 import 'dart_printer.dart'; |
| 9 import 'dart_tree_printer.dart' show TreePrinter; | 9 import 'dart_tree_printer.dart' show TreePrinter; |
| 10 import '../tree/tree.dart' as frontend; | 10 import '../tree/tree.dart' as frontend; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 case SelectorKind.CALL: | 383 case SelectorKind.CALL: |
| 384 return new CallStatic(null, exp.target.name, emitArguments(exp)) | 384 return new CallStatic(null, exp.target.name, emitArguments(exp)) |
| 385 ..element = exp.target; | 385 ..element = exp.target; |
| 386 | 386 |
| 387 default: | 387 default: |
| 388 throw "Unexpected selector kind: ${exp.selector.kind}"; | 388 throw "Unexpected selector kind: ${exp.selector.kind}"; |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 Expression visitInvokeMethod(tree.InvokeMethod exp) { | 392 Expression emitMethodCall(tree.Invoke exp, Receiver receiver) { |
| 393 Expression receiver = visitExpression(exp.receiver); | |
| 394 List<Argument> args = emitArguments(exp); | 393 List<Argument> args = emitArguments(exp); |
| 395 switch (exp.selector.kind) { | 394 switch (exp.selector.kind) { |
| 396 case SelectorKind.CALL: | 395 case SelectorKind.CALL: |
| 397 if (exp.selector.name == "call") { | 396 if (exp.selector.name == "call") { |
| 398 return new CallFunction(receiver, args); | 397 return new CallFunction(receiver, args); |
| 399 } | 398 } |
| 400 return new CallMethod(receiver, exp.selector.name, args); | 399 return new CallMethod(receiver, exp.selector.name, args); |
| 401 | 400 |
| 402 case SelectorKind.OPERATOR: | 401 case SelectorKind.OPERATOR: |
| 403 if (args.length == 0) { | 402 if (args.length == 0) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 422 if (args.length == 2) { | 421 if (args.length == 2) { |
| 423 e = makeAssignment(e, args[1]); | 422 e = makeAssignment(e, args[1]); |
| 424 } | 423 } |
| 425 return e; | 424 return e; |
| 426 | 425 |
| 427 default: | 426 default: |
| 428 throw "Unexpected selector in InvokeMethod: ${exp.selector.kind}"; | 427 throw "Unexpected selector in InvokeMethod: ${exp.selector.kind}"; |
| 429 } | 428 } |
| 430 } | 429 } |
| 431 | 430 |
| 431 Expression visitInvokeMethod(tree.InvokeMethod exp) { |
| 432 Expression receiver = visitExpression(exp.receiver); |
| 433 return emitMethodCall(exp, receiver); |
| 434 } |
| 435 |
| 436 Expression visitInvokeSuperMethod(tree.InvokeSuperMethod exp) { |
| 437 return emitMethodCall(exp, new SuperReceiver()); |
| 438 } |
| 439 |
| 432 Expression visitInvokeConstructor(tree.InvokeConstructor exp) { | 440 Expression visitInvokeConstructor(tree.InvokeConstructor exp) { |
| 433 List args = emitArguments(exp); | 441 List args = emitArguments(exp); |
| 434 FunctionElement constructor = exp.target; | 442 FunctionElement constructor = exp.target; |
| 435 String name = constructor.name.isEmpty ? null : constructor.name; | 443 String name = constructor.name.isEmpty ? null : constructor.name; |
| 436 return new CallNew(emitType(exp.type), | 444 return new CallNew(emitType(exp.type), |
| 437 args, | 445 args, |
| 438 constructorName: name, | 446 constructorName: name, |
| 439 isConst: exp.constant != null) | 447 isConst: exp.constant != null) |
| 440 ..constructor = constructor | 448 ..constructor = constructor |
| 441 ..dartType = exp.type; | 449 ..dartType = exp.type; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } else if (constant is dart2js.TypeConstant) { | 523 } else if (constant is dart2js.TypeConstant) { |
| 516 GenericType type = constant.representedType; | 524 GenericType type = constant.representedType; |
| 517 return new Identifier(type.name) | 525 return new Identifier(type.name) |
| 518 ..element = type.element; | 526 ..element = type.element; |
| 519 } else { | 527 } else { |
| 520 throw "Unsupported constant: $constant"; | 528 throw "Unsupported constant: $constant"; |
| 521 } | 529 } |
| 522 } | 530 } |
| 523 } | 531 } |
| 524 | 532 |
| OLD | NEW |