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

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

Issue 10232011: Implement simple dynamic type check. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor edits. Created 8 years, 7 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 interface HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBitAnd(HBitAnd node); 7 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 8 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 9 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 10 R visitBitXor(HBitXor node);
(...skipping 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 // However it turns out that inserting an integer check in the optimized 2082 // However it turns out that inserting an integer check in the optimized
2083 // version is cheaper than having another bailout case. This is true, 2083 // version is cheaper than having another bailout case. This is true,
2084 // because the integer check will simply throw if it fails. 2084 // because the integer check will simply throw if it fails.
2085 return HType.UNKNOWN; 2085 return HType.UNKNOWN;
2086 } 2086 }
2087 2087
2088 bool get builtin() => receiver.isMutableArray() && index.isInteger(); 2088 bool get builtin() => receiver.isMutableArray() && index.isInteger();
2089 } 2089 }
2090 2090
2091 class HIs extends HInstruction { 2091 class HIs extends HInstruction {
2092 final Type typeName; 2092 final Type typeExpression;
kasperl 2012/04/30 08:48:32 It really isn't an expression but I guess it isn't
karlklose 2012/05/01 11:20:55 This is actually reverting a renaming from an earl
2093 final bool nullOk; 2093 final bool nullOk;
2094 2094
2095 HIs(this.typeName, HInstruction expression, [nullOk = false]) 2095 HIs.withTypeInfo(this.typeExpression, HInstruction expression,
ngeoffray 2012/04/30 08:51:12 withTypeInfoCall?
karlklose 2012/05/01 11:20:55 Done.
2096 : this.nullOk = nullOk, super(<HInstruction>[expression]); 2096 HInstruction typeInfo, [nullOk = false])
kasperl 2012/04/30 08:48:32 Can't we use this.nullOk in the parameter list?
karlklose 2012/05/01 11:20:55 Done.
2097 : this.nullOk = nullOk, super(<HInstruction>[expression, typeInfo]);
2098
2099 HIs(this.typeExpression, HInstruction expression, [nullOk = false])
2100 : this.nullOk = nullOk, super(<HInstruction>[expression]);
2097 2101
2098 HInstruction get expression() => inputs[0]; 2102 HInstruction get expression() => inputs[0];
2099 2103
2104 HInstruction get typeInfo() => inputs[1];
ngeoffray 2012/04/30 08:51:12 ditto
karlklose 2012/05/01 11:20:55 Done.
2105
2100 HType get guaranteedType() => HType.BOOLEAN; 2106 HType get guaranteedType() => HType.BOOLEAN;
2101 2107
2102 accept(HVisitor visitor) => visitor.visitIs(this); 2108 accept(HVisitor visitor) => visitor.visitIs(this);
2103 2109
2104 toString() => "$expression is $typeName"; 2110 toString() => "$expression is $typeExpression";
2105 } 2111 }
2106 2112
2107 2113
2108 interface HBlockInformation { 2114 interface HBlockInformation {
2109 bool accept(HBlockInformationVisitor visitor); 2115 bool accept(HBlockInformationVisitor visitor);
2110 } 2116 }
2111 2117
2112 interface HBlockInformationVisitor { 2118 interface HBlockInformationVisitor {
2113 bool visitLabeledBlockInfo(HLabeledBlockInformation info); 2119 bool visitLabeledBlockInfo(HLabeledBlockInformation info);
2114 bool visitLoopInfo(HLoopInformation info); 2120 bool visitLoopInfo(HLoopInformation info);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 final bool isAnd; 2236 final bool isAnd;
2231 final SubExpression left; 2237 final SubExpression left;
2232 final SubExpression right; 2238 final SubExpression right;
2233 final HBasicBlock joinBlock; 2239 final HBasicBlock joinBlock;
2234 HAndOrBlockInformation(this.isAnd, 2240 HAndOrBlockInformation(this.isAnd,
2235 this.left, 2241 this.left,
2236 this.right, 2242 this.right,
2237 this.joinBlock); 2243 this.joinBlock);
2238 bool accept(HBlockInformationVisitor visitor) => visitor.visitAndOrInfo(this); 2244 bool accept(HBlockInformationVisitor visitor) => visitor.visitAndOrInfo(this);
2239 } 2245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698