Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 result; |
|
kasperl
2012/09/13 10:34:19
Maybe move this to the else branch and just return
ngeoffray
2012/09/13 10:52:32
Done.
| |
| 1438 add(boolified); | 1438 HInstruction value = pop(); |
| 1439 return boolified; | 1439 if (compiler.enableTypeAssertions) { |
| 1440 result = potentiallyCheckType( | |
| 1441 value, | |
| 1442 compiler.boolClass, | |
| 1443 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); | |
| 1444 } else { | |
| 1445 result = new HBoolify(value); | |
| 1446 add(result); | |
| 1447 } | |
| 1448 return result; | |
| 1440 } | 1449 } |
| 1441 | 1450 |
| 1442 HInstruction attachPosition(HInstruction target, Node node) { | 1451 HInstruction attachPosition(HInstruction target, Node node) { |
| 1443 target.sourcePosition = sourceFileLocationForToken(node.getBeginToken()); | 1452 target.sourcePosition = sourceFileLocationForToken(node.getBeginToken()); |
| 1444 return target; | 1453 return target; |
| 1445 } | 1454 } |
| 1446 | 1455 |
| 1447 SourceFileLocation sourceFileLocationForToken(Token token) { | 1456 SourceFileLocation sourceFileLocationForToken(Token token) { |
| 1448 Element element = sourceElementStack.last(); | 1457 Element element = sourceElementStack.last(); |
| 1449 // TODO(johnniwinther): remove the 'element.patch' hack. | 1458 // TODO(johnniwinther): remove the 'element.patch' hack. |
| (...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4169 new HSubGraphBlockInformation(elseBranch.graph)); | 4178 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4170 | 4179 |
| 4171 HBasicBlock conditionStartBlock = conditionBranch.block; | 4180 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4172 conditionStartBlock.setBlockFlow(info, joinBlock); | 4181 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4173 SubGraph conditionGraph = conditionBranch.graph; | 4182 SubGraph conditionGraph = conditionBranch.graph; |
| 4174 HIf branch = conditionGraph.end.last; | 4183 HIf branch = conditionGraph.end.last; |
| 4175 assert(branch is HIf); | 4184 assert(branch is HIf); |
| 4176 branch.blockInformation = conditionStartBlock.blockFlow; | 4185 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4177 } | 4186 } |
| 4178 } | 4187 } |
| OLD | NEW |