Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 12095011: Properly register types on the JS foreign instruction. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of ssa; 5 part of ssa;
6 6
7 abstract class HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBailoutTarget(HBailoutTarget node); 9 R visitBailoutTarget(HBailoutTarget node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 HInstruction get value => inputs[1]; 1540 HInstruction get value => inputs[1];
1541 bool isJsStatement() => true; 1541 bool isJsStatement() => true;
1542 } 1542 }
1543 1543
1544 class HForeign extends HInstruction { 1544 class HForeign extends HInstruction {
1545 final DartString code; 1545 final DartString code;
1546 final HType foreignType; 1546 final HType foreignType;
1547 final bool isStatement; 1547 final bool isStatement;
1548 1548
1549 HForeign(this.code, 1549 HForeign(this.code,
1550 DartString declaredType, 1550 this.foreignType,
1551 List<HInstruction> inputs, 1551 List<HInstruction> inputs,
1552 {this.isStatement: false}) 1552 {this.isStatement: false})
1553 : foreignType = computeTypeFromDeclaredType(declaredType), 1553 : super(inputs) {
1554 super(inputs) {
1555 setAllSideEffects(); 1554 setAllSideEffects();
1556 setDependsOnSomething(); 1555 setDependsOnSomething();
1557 } 1556 }
1558 1557
1559 HForeign.statement(code, List<HInstruction> inputs) 1558 HForeign.statement(code, List<HInstruction> inputs)
1560 : this(code, const LiteralDartString('var'), inputs, isStatement: true); 1559 : this(code, HType.UNKNOWN, inputs, isStatement: true);
1561 1560
1562 accept(HVisitor visitor) => visitor.visitForeign(this); 1561 accept(HVisitor visitor) => visitor.visitForeign(this);
1563 1562
1564 static HType computeTypeFromDeclaredType(DartString declaredType) {
1565 if (declaredType.slowToString() == 'bool') return HType.BOOLEAN;
1566 if (declaredType.slowToString() == 'int') return HType.INTEGER;
1567 if (declaredType.slowToString() == 'double') return HType.DOUBLE;
1568 if (declaredType.slowToString() == 'num') return HType.NUMBER;
1569 if (declaredType.slowToString() == 'String') return HType.STRING;
1570 if (declaredType.slowToString() == '=List') return HType.READABLE_ARRAY;
1571 return HType.UNKNOWN;
1572 }
1573
1574 HType get guaranteedType => foreignType; 1563 HType get guaranteedType => foreignType;
1575 1564
1576 bool isJsStatement() => isStatement; 1565 bool isJsStatement() => isStatement;
1577 bool canThrow() => true; 1566 bool canThrow() => true;
1578
1579 } 1567 }
1580 1568
1581 class HForeignNew extends HForeign { 1569 class HForeignNew extends HForeign {
1582 ClassElement element; 1570 ClassElement element;
1583 HForeignNew(this.element, List<HInstruction> inputs) 1571 HForeignNew(this.element, HType type, List<HInstruction> inputs)
1584 : super(const LiteralDartString("new"), 1572 : super(const LiteralDartString("new"), type, inputs);
1585 const LiteralDartString("Object"), inputs);
1586 accept(HVisitor visitor) => visitor.visitForeignNew(this); 1573 accept(HVisitor visitor) => visitor.visitForeignNew(this);
1587 } 1574 }
1588 1575
1589 abstract class HInvokeBinary extends HInstruction { 1576 abstract class HInvokeBinary extends HInstruction {
1590 HInvokeBinary(HInstruction left, HInstruction right) 1577 HInvokeBinary(HInstruction left, HInstruction right)
1591 : super(<HInstruction>[left, right]) { 1578 : super(<HInstruction>[left, right]) {
1592 clearAllSideEffects(); 1579 clearAllSideEffects();
1593 setUseGvn(); 1580 setUseGvn();
1594 } 1581 }
1595 1582
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 HBasicBlock get start => expression.start; 2680 HBasicBlock get start => expression.start;
2694 HBasicBlock get end { 2681 HBasicBlock get end {
2695 // We don't create a switch block if there are no cases. 2682 // We don't create a switch block if there are no cases.
2696 assert(!statements.isEmpty); 2683 assert(!statements.isEmpty);
2697 return statements.last.end; 2684 return statements.last.end;
2698 } 2685 }
2699 2686
2700 bool accept(HStatementInformationVisitor visitor) => 2687 bool accept(HStatementInformationVisitor visitor) =>
2701 visitor.visitSwitchInfo(this); 2688 visitor.visitSwitchInfo(this);
2702 } 2689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698