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

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

Issue 10905235: Check boolean conversion in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 || functionElement.isGenerativeConstructor()) { 1345 || functionElement.isGenerativeConstructor()) {
1346 ClassElement cls = functionElement.enclosingElement; 1346 ClassElement cls = functionElement.enclosingElement;
1347 cls.typeVariables.forEach((TypeVariableType typeVariable) { 1347 cls.typeVariables.forEach((TypeVariableType typeVariable) {
1348 HParameterValue param = new HParameterValue(typeVariable.element); 1348 HParameterValue param = new HParameterValue(typeVariable.element);
1349 add(param); 1349 add(param);
1350 localsHandler.directLocals[typeVariable.element] = param; 1350 localsHandler.directLocals[typeVariable.element] = param;
1351 }); 1351 });
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 HInstruction potentiallyCheckType(HInstruction original, 1355 HInstruction potentiallyCheckType(
1356 Element sourceElement) { 1356 HInstruction original, Element sourceElement,
1357 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) {
1357 if (!compiler.enableTypeAssertions) return original; 1358 if (!compiler.enableTypeAssertions) return original;
1358 HInstruction other = original.convertType( 1359 HInstruction other = original.convertType(compiler, sourceElement, kind);
1359 compiler, sourceElement, HTypeConversion.CHECKED_MODE_CHECK);
1360 if (other != original) add(other); 1360 if (other != original) add(other);
1361 return other; 1361 return other;
1362 } 1362 }
1363 1363
1364 HGraph closeFunction() { 1364 HGraph closeFunction() {
1365 // TODO(kasperl): Make this goto an implicit return. 1365 // TODO(kasperl): Make this goto an implicit return.
1366 if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit); 1366 if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit);
1367 graph.finalize(); 1367 graph.finalize();
1368 return graph; 1368 return graph;
1369 } 1369 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 } 1426 }
1427 1427
1428 HInstruction pop() { 1428 HInstruction pop() {
1429 return stack.removeLast(); 1429 return stack.removeLast();
1430 } 1430 }
1431 1431
1432 void dup() { 1432 void dup() {
1433 stack.add(stack.last()); 1433 stack.add(stack.last());
1434 } 1434 }
1435 1435
1436 HBoolify popBoolified() { 1436 HInstruction popBoolified() {
1437 HBoolify boolified = new HBoolify(pop()); 1437 HInstruction value = pop();
1438 add(boolified); 1438 if (compiler.enableTypeAssertions) {
1439 return boolified; 1439 return potentiallyCheckType(
1440 value,
1441 compiler.boolClass,
1442 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK);
1443 }
1444 HInstruction result = new HBoolify(value);
1445 add(result);
1446 return result;
1440 } 1447 }
1441 1448
1442 HInstruction attachPosition(HInstruction target, Node node) { 1449 HInstruction attachPosition(HInstruction target, Node node) {
1443 target.sourcePosition = sourceFileLocationForToken(node.getBeginToken()); 1450 target.sourcePosition = sourceFileLocationForToken(node.getBeginToken());
1444 return target; 1451 return target;
1445 } 1452 }
1446 1453
1447 SourceFileLocation sourceFileLocationForToken(Token token) { 1454 SourceFileLocation sourceFileLocationForToken(Token token) {
1448 Element element = sourceElementStack.last(); 1455 Element element = sourceElementStack.last();
1449 // TODO(johnniwinther): remove the 'element.patch' hack. 1456 // TODO(johnniwinther): remove the 'element.patch' hack.
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 new HSubGraphBlockInformation(elseBranch.graph)); 4176 new HSubGraphBlockInformation(elseBranch.graph));
4170 4177
4171 HBasicBlock conditionStartBlock = conditionBranch.block; 4178 HBasicBlock conditionStartBlock = conditionBranch.block;
4172 conditionStartBlock.setBlockFlow(info, joinBlock); 4179 conditionStartBlock.setBlockFlow(info, joinBlock);
4173 SubGraph conditionGraph = conditionBranch.graph; 4180 SubGraph conditionGraph = conditionBranch.graph;
4174 HIf branch = conditionGraph.end.last; 4181 HIf branch = conditionGraph.end.last;
4175 assert(branch is HIf); 4182 assert(branch is HIf);
4176 branch.blockInformation = conditionStartBlock.blockFlow; 4183 branch.blockInformation = conditionStartBlock.blockFlow;
4177 } 4184 }
4178 } 4185 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698