| 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 analyzer2dart.cps_generator; | 5 library analyzer2dart.cps_generator; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 | 8 |
| 9 import 'package:compiler/src/dart_types.dart' as dart2js; | 9 import 'package:compiler/src/dart_types.dart' as dart2js; |
| 10 import 'package:compiler/src/elements/elements.dart' as dart2js; | 10 import 'package:compiler/src/elements/elements.dart' as dart2js; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 AccessSemantics semantics) { | 384 AccessSemantics semantics) { |
| 385 if (node.operator.lexeme != '=') { | 385 if (node.operator.lexeme != '=') { |
| 386 return giveUp(node, 'Assignment operator: ${node.operator.lexeme}'); | 386 return giveUp(node, 'Assignment operator: ${node.operator.lexeme}'); |
| 387 } | 387 } |
| 388 analyzer.Element element = semantics.element; | 388 analyzer.Element element = semantics.element; |
| 389 dart2js.Element target = converter.convertElement(element); | 389 dart2js.Element target = converter.convertElement(element); |
| 390 // TODO(johnniwinther): Selector information should be computed in the | 390 // TODO(johnniwinther): Selector information should be computed in the |
| 391 // [TreeShaker] and shared with the [CpsGeneratingVisitor]. | 391 // [TreeShaker] and shared with the [CpsGeneratingVisitor]. |
| 392 assert(invariant(node, target.isTopLevel || target.isStatic, | 392 assert(invariant(node, target.isTopLevel || target.isStatic, |
| 393 '$target expected to be top-level or static.')); | 393 '$target expected to be top-level or static.')); |
| 394 return irBuilder.buildStaticSet( | 394 return irBuilder.buildStaticSet(target, build(node.rightHandSide)); |
| 395 target, | |
| 396 new Selector.setter(target.name, target.library), | |
| 397 build(node.rightHandSide)); | |
| 398 } | 395 } |
| 399 | 396 |
| 400 @override | 397 @override |
| 401 ir.Node visitDynamicAccess(AstNode node, AccessSemantics semantics) { | 398 ir.Node visitDynamicAccess(AstNode node, AccessSemantics semantics) { |
| 402 // TODO(johnniwinther): Handle implicit `this`. | 399 // TODO(johnniwinther): Handle implicit `this`. |
| 403 ir.Primitive receiver = build(semantics.target); | 400 ir.Primitive receiver = build(semantics.target); |
| 404 return irBuilder.buildDynamicGet(receiver, | 401 return irBuilder.buildDynamicGet(receiver, |
| 405 new Selector.getter(semantics.identifier.name, | 402 new Selector.getter(semantics.identifier.name, |
| 406 converter.convertElement(element.library))); | 403 converter.convertElement(element.library))); |
| 407 } | 404 } |
| 408 | 405 |
| 409 @override | 406 @override |
| 410 ir.Node visitStaticFieldAccess(AstNode node, AccessSemantics semantics) { | 407 ir.Node visitStaticFieldAccess(AstNode node, AccessSemantics semantics) { |
| 411 analyzer.Element element = semantics.element; | 408 analyzer.Element element = semantics.element; |
| 412 dart2js.Element target = converter.convertElement(element); | 409 dart2js.Element target = converter.convertElement(element); |
| 413 // TODO(johnniwinther): Selector information should be computed in the | 410 // TODO(johnniwinther): Selector information should be computed in the |
| 414 // [TreeShaker] and shared with the [CpsGeneratingVisitor]. | 411 // [TreeShaker] and shared with the [CpsGeneratingVisitor]. |
| 415 assert(invariant(node, target.isTopLevel || target.isStatic, | 412 assert(invariant(node, target.isTopLevel || target.isStatic, |
| 416 '$target expected to be top-level or static.')); | 413 '$target expected to be top-level or static.')); |
| 417 return irBuilder.buildStaticGet(target, | 414 return irBuilder.buildStaticGet(target); |
| 418 new Selector.getter(target.name, target.library)); | |
| 419 } | 415 } |
| 420 | 416 |
| 421 ir.Primitive handleBinaryExpression(BinaryExpression node, | 417 ir.Primitive handleBinaryExpression(BinaryExpression node, |
| 422 String op) { | 418 String op) { |
| 423 ir.Primitive left = build(node.leftOperand); | 419 ir.Primitive left = build(node.leftOperand); |
| 424 ir.Primitive right = build(node.rightOperand); | 420 ir.Primitive right = build(node.rightOperand); |
| 425 Selector selector = new Selector.binaryOperator(op); | 421 Selector selector = new Selector.binaryOperator(op); |
| 426 return irBuilder.buildDynamicInvocation( | 422 return irBuilder.buildDynamicInvocation( |
| 427 left, selector, <ir.Primitive>[right]); | 423 left, selector, <ir.Primitive>[right]); |
| 428 } | 424 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 irBuilder.buildTry( | 583 irBuilder.buildTry( |
| 588 tryStatementInfo: new TryStatementInfo(), | 584 tryStatementInfo: new TryStatementInfo(), |
| 589 buildTryBlock: subbuild(node.body), | 585 buildTryBlock: subbuild(node.body), |
| 590 catchClauseInfos: catchClauseInfos); | 586 catchClauseInfos: catchClauseInfos); |
| 591 } | 587 } |
| 592 } | 588 } |
| 593 | 589 |
| 594 class NullCapturedVariables extends DartCapturedVariables { | 590 class NullCapturedVariables extends DartCapturedVariables { |
| 595 NullCapturedVariables() : super(null); | 591 NullCapturedVariables() : super(null); |
| 596 } | 592 } |
| OLD | NEW |