Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_builder; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import '../constants/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../constants/values.dart' show PrimitiveConstantValue; | 9 import '../constants/values.dart' show PrimitiveConstantValue; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2478 for (VariableElement loopVar in scope.boxedLoopVariables) { | 2478 for (VariableElement loopVar in scope.boxedLoopVariables) { |
| 2479 ClosureLocation location = scope.capturedVariables[loopVar]; | 2479 ClosureLocation location = scope.capturedVariables[loopVar]; |
| 2480 ir.Primitive value = addPrimitive(new ir.GetField(box, location.field)); | 2480 ir.Primitive value = addPrimitive(new ir.GetField(box, location.field)); |
| 2481 add(new ir.SetField(newBox, location.field, value)); | 2481 add(new ir.SetField(newBox, location.field, value)); |
| 2482 } | 2482 } |
| 2483 environment.update(scope.box, newBox); | 2483 environment.update(scope.box, newBox); |
| 2484 } | 2484 } |
| 2485 | 2485 |
| 2486 ir.Primitive buildThis() { | 2486 ir.Primitive buildThis() { |
| 2487 if (jsState.receiver != null) return jsState.receiver; | 2487 if (jsState.receiver != null) return jsState.receiver; |
| 2488 assert(state.thisParameter != null); | |
| 2488 return state.thisParameter; | 2489 return state.thisParameter; |
| 2489 } | 2490 } |
| 2490 | 2491 |
| 2491 @override | 2492 @override |
| 2492 ir.Primitive buildSuperFieldGet(FieldElement target) { | 2493 ir.Primitive buildSuperFieldGet(FieldElement target) { |
| 2493 return addPrimitive(new ir.GetField(buildThis(), target)); | 2494 return addPrimitive(new ir.GetField(buildThis(), target)); |
| 2494 } | 2495 } |
| 2495 | 2496 |
| 2496 @override | 2497 @override |
| 2497 ir.Primitive buildSuperFieldSet(FieldElement target, ir.Primitive value) { | 2498 ir.Primitive buildSuperFieldSet(FieldElement target, ir.Primitive value) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2547 arguments = new List<ir.Primitive>.from(arguments) | 2548 arguments = new List<ir.Primitive>.from(arguments) |
| 2548 ..addAll(typeArguments); | 2549 ..addAll(typeArguments); |
| 2549 } | 2550 } |
| 2550 return _continueWithExpression( | 2551 return _continueWithExpression( |
| 2551 (k) => new ir.InvokeConstructor(type, element, selector, | 2552 (k) => new ir.InvokeConstructor(type, element, selector, |
| 2552 arguments, k)); | 2553 arguments, k)); |
| 2553 } | 2554 } |
| 2554 | 2555 |
| 2555 ir.Primitive buildTypeExpression(DartType type) { | 2556 ir.Primitive buildTypeExpression(DartType type) { |
| 2556 if (type is TypeVariableType) { | 2557 if (type is TypeVariableType) { |
| 2557 return buildTypeVariableAccess(buildThis(), type); | 2558 return buildTypeVariableAccess(buildThis(), type); |
|
asgerf
2015/05/08 11:14:43
buildThis() would fail here when inside a field in
| |
| 2558 } else if (type is InterfaceType) { | 2559 } else if (type is InterfaceType) { |
| 2559 List<ir.Primitive> arguments = <ir.Primitive>[]; | 2560 List<ir.Primitive> arguments = <ir.Primitive>[]; |
| 2560 type.forEachTypeVariable((TypeVariableType variable) { | 2561 type.forEachTypeVariable((TypeVariableType variable) { |
| 2561 ir.Primitive value = buildTypeVariableAccess(buildThis(), variable); | 2562 ir.Primitive value = buildTypeVariableAccess(buildThis(), variable); |
| 2562 arguments.add(value); | 2563 arguments.add(value); |
| 2563 }); | 2564 }); |
| 2564 return addPrimitive(new ir.TypeExpression(type, arguments)); | 2565 return addPrimitive(new ir.TypeExpression(type, arguments)); |
| 2565 } else { | 2566 } else { |
| 2566 // TypedefType can reach here, and possibly other things. | 2567 // TypedefType can reach here, and possibly other things. |
| 2567 throw 'unimplemented translation of type expression $type'; | 2568 throw 'unimplemented translation of type expression $type'; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2580 } | 2581 } |
| 2581 throw 'unable to find constructor parameter for type variable $variable.'; | 2582 throw 'unable to find constructor parameter for type variable $variable.'; |
| 2582 } | 2583 } |
| 2583 | 2584 |
| 2584 if (jsState.inInitializers) { | 2585 if (jsState.inInitializers) { |
| 2585 return accessTypeArgumentParameter(); | 2586 return accessTypeArgumentParameter(); |
| 2586 } else { | 2587 } else { |
| 2587 return addPrimitive(new ir.ReadTypeVariable(variable, target)); | 2588 return addPrimitive(new ir.ReadTypeVariable(variable, target)); |
| 2588 } | 2589 } |
| 2589 } | 2590 } |
| 2591 | |
| 2592 ir.Primitive buildInvocationMirror(Selector selector, | |
| 2593 List<ir.Primitive> arguments) { | |
| 2594 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); | |
| 2595 } | |
| 2590 } | 2596 } |
| 2591 | 2597 |
| 2592 | 2598 |
| 2593 /// Location of a variable relative to a given closure. | 2599 /// Location of a variable relative to a given closure. |
| 2594 class ClosureLocation { | 2600 class ClosureLocation { |
| 2595 /// If not `null`, this location is [box].[field]. | 2601 /// If not `null`, this location is [box].[field]. |
| 2596 /// The location of [box] can be obtained separately from an | 2602 /// The location of [box] can be obtained separately from an |
| 2597 /// enclosing [ClosureEnvironment] or [ClosureScope]. | 2603 /// enclosing [ClosureEnvironment] or [ClosureScope]. |
| 2598 /// If `null`, then the location is [field] on the enclosing function object. | 2604 /// If `null`, then the location is [field] on the enclosing function object. |
| 2599 final BoxLocal box; | 2605 final BoxLocal box; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2660 } | 2666 } |
| 2661 | 2667 |
| 2662 /// Synthetic parameter to a JavaScript factory method that takes the type | 2668 /// Synthetic parameter to a JavaScript factory method that takes the type |
| 2663 /// argument given for the type variable [variable]. | 2669 /// argument given for the type variable [variable]. |
| 2664 class TypeInformationParameter implements Local { | 2670 class TypeInformationParameter implements Local { |
| 2665 final TypeVariableElement variable; | 2671 final TypeVariableElement variable; |
| 2666 final ExecutableElement executableContext; | 2672 final ExecutableElement executableContext; |
| 2667 TypeInformationParameter(this.variable, this.executableContext); | 2673 TypeInformationParameter(this.variable, this.executableContext); |
| 2668 String get name => variable.name; | 2674 String get name => variable.name; |
| 2669 } | 2675 } |
| OLD | NEW |