| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 HInstruction readLocal(Element element) { | 389 HInstruction readLocal(Element element) { |
| 390 if (isAccessedDirectly(element)) { | 390 if (isAccessedDirectly(element)) { |
| 391 if (directLocals[element] == null) { | 391 if (directLocals[element] == null) { |
| 392 builder.compiler.internalError("Cannot find value $element", | 392 builder.compiler.internalError("Cannot find value $element", |
| 393 element: element); | 393 element: element); |
| 394 } | 394 } |
| 395 return directLocals[element]; | 395 return directLocals[element]; |
| 396 } else if (isStoredInClosureField(element)) { | 396 } else if (isStoredInClosureField(element)) { |
| 397 Element redirect = redirectionMapping[element]; | 397 Element redirect = redirectionMapping[element]; |
| 398 HInstruction receiver = readLocal(closureData.closureElement); | 398 HInstruction receiver = readLocal(closureData.closureElement); |
| 399 HInstruction fieldGet = new HFieldGet(redirect, receiver); | 399 HInstruction fieldGet = new HFieldGet.withElement(redirect, receiver); |
| 400 builder.add(fieldGet); | 400 builder.add(fieldGet); |
| 401 return fieldGet; | 401 return fieldGet; |
| 402 } else if (isBoxed(element)) { | 402 } else if (isBoxed(element)) { |
| 403 Element redirect = redirectionMapping[element]; | 403 Element redirect = redirectionMapping[element]; |
| 404 // In the function that declares the captured variable the box is | 404 // In the function that declares the captured variable the box is |
| 405 // accessed as direct local. Inside the nested closure the box is | 405 // accessed as direct local. Inside the nested closure the box is |
| 406 // accessed through a closure-field. | 406 // accessed through a closure-field. |
| 407 // Calling [readLocal] makes sure we generate the correct code to get | 407 // Calling [readLocal] makes sure we generate the correct code to get |
| 408 // the box. | 408 // the box. |
| 409 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); | 409 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); |
| 410 HInstruction box = readLocal(redirect.enclosingElement); | 410 HInstruction box = readLocal(redirect.enclosingElement); |
| 411 HInstruction lookup = new HFieldGet(redirect, box); | 411 HInstruction lookup = new HFieldGet.withElement(redirect, box); |
| 412 builder.add(lookup); | 412 builder.add(lookup); |
| 413 return lookup; | 413 return lookup; |
| 414 } else { | 414 } else { |
| 415 assert(isUsedInTry(element)); | 415 assert(isUsedInTry(element)); |
| 416 HLocalValue local = getLocal(element); | 416 HLocalValue local = getLocal(element); |
| 417 HInstruction variable = new HLocalGet(element, local); | 417 HInstruction variable = new HLocalGet(element, local); |
| 418 builder.add(variable); | 418 builder.add(variable); |
| 419 return variable; | 419 return variable; |
| 420 } | 420 } |
| 421 } | 421 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (isAccessedDirectly(element)) { | 461 if (isAccessedDirectly(element)) { |
| 462 directLocals[element] = value; | 462 directLocals[element] = value; |
| 463 } else if (isBoxed(element)) { | 463 } else if (isBoxed(element)) { |
| 464 Element redirect = redirectionMapping[element]; | 464 Element redirect = redirectionMapping[element]; |
| 465 // The box itself could be captured, or be local. A local variable that | 465 // The box itself could be captured, or be local. A local variable that |
| 466 // is captured will be boxed, but the box itself will be a local. | 466 // is captured will be boxed, but the box itself will be a local. |
| 467 // Inside the closure the box is stored in a closure-field and cannot | 467 // Inside the closure the box is stored in a closure-field and cannot |
| 468 // be accessed directly. | 468 // be accessed directly. |
| 469 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); | 469 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); |
| 470 HInstruction box = readLocal(redirect.enclosingElement); | 470 HInstruction box = readLocal(redirect.enclosingElement); |
| 471 builder.add(new HFieldSet(redirect, box, value)); | 471 builder.add(new HFieldSet.withElement(redirect, box, value)); |
| 472 } else { | 472 } else { |
| 473 assert(isUsedInTry(element)); | 473 assert(isUsedInTry(element)); |
| 474 HLocalValue local = getLocal(element); | 474 HLocalValue local = getLocal(element); |
| 475 builder.add(new HLocalSet(element, local, value)); | 475 builder.add(new HLocalSet(element, local, value)); |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 | 478 |
| 479 /** | 479 /** |
| 480 * This function must be called before visiting any children of the loop. In | 480 * This function must be called before visiting any children of the loop. In |
| 481 * particular it needs to be called before executing the initializers. | 481 * particular it needs to be called before executing the initializers. |
| (...skipping 3103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 new HSubGraphBlockInformation(elseBranch.graph)); | 3585 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3586 | 3586 |
| 3587 HBasicBlock conditionStartBlock = conditionBranch.block; | 3587 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3588 conditionStartBlock.setBlockFlow(info, joinBlock); | 3588 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3589 SubGraph conditionGraph = conditionBranch.graph; | 3589 SubGraph conditionGraph = conditionBranch.graph; |
| 3590 HIf branch = conditionGraph.end.last; | 3590 HIf branch = conditionGraph.end.last; |
| 3591 assert(branch is HIf); | 3591 assert(branch is HIf); |
| 3592 branch.blockInformation = conditionStartBlock.blockFlow; | 3592 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3593 } | 3593 } |
| 3594 } | 3594 } |
| OLD | NEW |