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

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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1536
1537 accept(HVisitor visitor) => visitor.visitLocalSet(this); 1537 accept(HVisitor visitor) => visitor.visitLocalSet(this);
1538 1538
1539 HLocalValue get local => inputs[0]; 1539 HLocalValue get local => inputs[0];
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;
kasperl 2013/02/04 09:27:50 Could this be type instead of foreignType? The for
ngeoffray 2013/02/04 10:45:06 Done.
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) {
kasperl 2013/02/04 09:27:50 Too much indentation.
ngeoffray 2013/02/04 10:45:06 Done.
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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 HBasicBlock get start => expression.start; 2683 HBasicBlock get start => expression.start;
2697 HBasicBlock get end { 2684 HBasicBlock get end {
2698 // We don't create a switch block if there are no cases. 2685 // We don't create a switch block if there are no cases.
2699 assert(!statements.isEmpty); 2686 assert(!statements.isEmpty);
2700 return statements.last.end; 2687 return statements.last.end;
2701 } 2688 }
2702 2689
2703 bool accept(HStatementInformationVisitor visitor) => 2690 bool accept(HStatementInformationVisitor visitor) =>
2704 visitor.visitSwitchInfo(this); 2691 visitor.visitSwitchInfo(this);
2705 } 2692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698