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

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

Issue 10668021: Distinguish statement and expression foreign code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: After rebase no need for parenthesis anymore. Created 8 years, 5 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
« no previous file with comments | « lib/compiler/implementation/native_handler.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1314
1315 HLocalValue get local() => inputs[0]; 1315 HLocalValue get local() => inputs[0];
1316 1316
1317 void prepareGvn() { 1317 void prepareGvn() {
1318 // TODO(floitsch): implement more fine grained side effects. 1318 // TODO(floitsch): implement more fine grained side effects.
1319 setAllSideEffects(); 1319 setAllSideEffects();
1320 } 1320 }
1321 } 1321 }
1322 1322
1323 class HForeign extends HInstruction { 1323 class HForeign extends HInstruction {
1324 final bool _isStatement;
Lasse Reichstein Nielsen 2012/06/27 08:10:16 Just make this non-private and final. No need to w
floitsch 2012/06/27 12:04:43 Done.
1324 final DartString code; 1325 final DartString code;
1325 final HType foreignType; 1326 final HType foreignType;
1326 HForeign(this.code, DartString declaredType, List<HInstruction> inputs) 1327 HForeign(this.code, DartString declaredType, List<HInstruction> inputs)
1327 : foreignType = computeTypeFromDeclaredType(declaredType), 1328 : foreignType = computeTypeFromDeclaredType(declaredType),
1329 _isStatement = false,
1330 super(inputs);
1331 HForeign.statement(this.code, List<HInstruction> inputs)
1332 : foreignType = HType.UNKNOWN,
1333 _isStatement = true,
1328 super(inputs); 1334 super(inputs);
1329 accept(HVisitor visitor) => visitor.visitForeign(this); 1335 accept(HVisitor visitor) => visitor.visitForeign(this);
1330 1336
1331 static HType computeTypeFromDeclaredType(DartString declaredType) { 1337 static HType computeTypeFromDeclaredType(DartString declaredType) {
1332 if (declaredType.slowToString() == 'bool') return HType.BOOLEAN; 1338 if (declaredType.slowToString() == 'bool') return HType.BOOLEAN;
1333 if (declaredType.slowToString() == 'int') return HType.INTEGER; 1339 if (declaredType.slowToString() == 'int') return HType.INTEGER;
1334 if (declaredType.slowToString() == 'double') return HType.DOUBLE; 1340 if (declaredType.slowToString() == 'double') return HType.DOUBLE;
1335 if (declaredType.slowToString() == 'num') return HType.NUMBER; 1341 if (declaredType.slowToString() == 'num') return HType.NUMBER;
1336 if (declaredType.slowToString() == 'String') return HType.STRING; 1342 if (declaredType.slowToString() == 'String') return HType.STRING;
1337 return HType.UNKNOWN; 1343 return HType.UNKNOWN;
1338 } 1344 }
1339 1345
1340 HType get guaranteedType() => foreignType; 1346 HType get guaranteedType() => foreignType;
1341 1347
1342 // Be conservative and treat all [HForeign] as statements, even 1348 bool isStatement() => _isStatement;
1343 // though some are just expressions.
1344 bool isStatement() => true;
1345 } 1349 }
1346 1350
1347 class HForeignNew extends HForeign { 1351 class HForeignNew extends HForeign {
1348 ClassElement element; 1352 ClassElement element;
1349 HForeignNew(this.element, List<HInstruction> inputs) 1353 HForeignNew(this.element, List<HInstruction> inputs)
1350 : super(const LiteralDartString("new"), 1354 : super(const LiteralDartString("new"),
1351 const LiteralDartString("Object"), inputs); 1355 const LiteralDartString("Object"), inputs);
1352 accept(HVisitor visitor) => visitor.visitForeignNew(this); 1356 accept(HVisitor visitor) => visitor.visitForeignNew(this);
1353 } 1357 }
1354 1358
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 HBasicBlock get start() => expression.start; 2623 HBasicBlock get start() => expression.start;
2620 HBasicBlock get end() { 2624 HBasicBlock get end() {
2621 // We don't create a switch block if there are no cases. 2625 // We don't create a switch block if there are no cases.
2622 assert(!statements.isEmpty()); 2626 assert(!statements.isEmpty());
2623 return statements.last().end; 2627 return statements.last().end;
2624 } 2628 }
2625 2629
2626 bool accept(HStatementInformationVisitor visitor) => 2630 bool accept(HStatementInformationVisitor visitor) =>
2627 visitor.visitSwitchInfo(this); 2631 visitor.visitSwitchInfo(this);
2628 } 2632 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/native_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698