| OLD | NEW |
| 1 library dart2js.unsugar_cps; | 1 library dart2js.unsugar_cps; |
| 2 | 2 |
| 3 import '../../cps_ir/cps_ir_nodes.dart'; | 3 import '../../cps_ir/cps_ir_nodes.dart'; |
| 4 | 4 |
| 5 import '../../cps_ir/optimizers.dart' show ParentVisitor; | 5 import '../../cps_ir/optimizers.dart' show ParentVisitor, Pass; |
| 6 import '../../constants/values.dart'; | 6 import '../../constants/values.dart'; |
| 7 import '../../elements/elements.dart'; | 7 import '../../elements/elements.dart'; |
| 8 import '../../io/source_information.dart'; | 8 import '../../io/source_information.dart'; |
| 9 import '../../js_backend/codegen/glue.dart'; | 9 import '../../js_backend/codegen/glue.dart'; |
| 10 import '../../universe/selector.dart' show Selector; | 10 import '../../universe/selector.dart' show Selector; |
| 11 import '../../cps_ir/cps_ir_builder.dart' show ThisParameterLocal; | 11 import '../../cps_ir/cps_ir_builder.dart' show ThisParameterLocal; |
| 12 | 12 |
| 13 class ExplicitReceiverParameterEntity implements Local { | 13 class ExplicitReceiverParameterEntity implements Local { |
| 14 String get name => 'receiver'; | 14 String get name => 'receiver'; |
| 15 final ExecutableElement executableContext; | 15 final ExecutableElement executableContext; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 | 29 |
| 30 /// Rewrites the initial CPS IR to make Dart semantics explicit and inserts | 30 /// Rewrites the initial CPS IR to make Dart semantics explicit and inserts |
| 31 /// special nodes that respect JavaScript behavior. | 31 /// special nodes that respect JavaScript behavior. |
| 32 /// | 32 /// |
| 33 /// Performs the following rewrites: | 33 /// Performs the following rewrites: |
| 34 /// - Add interceptors at call sites that use interceptor calling convention. | 34 /// - Add interceptors at call sites that use interceptor calling convention. |
| 35 /// - Add explicit receiver argument for methods that are called in interceptor | 35 /// - Add explicit receiver argument for methods that are called in interceptor |
| 36 /// calling convention. | 36 /// calling convention. |
| 37 /// - Convert two-parameter exception handlers to one-parameter ones. | 37 /// - Convert two-parameter exception handlers to one-parameter ones. |
| 38 class UnsugarVisitor extends RecursiveVisitor { | 38 class UnsugarVisitor extends RecursiveVisitor implements Pass { |
| 39 Glue _glue; | 39 Glue _glue; |
| 40 ParentVisitor _parentVisitor = new ParentVisitor(); | 40 ParentVisitor _parentVisitor = new ParentVisitor(); |
| 41 | 41 |
| 42 Parameter thisParameter; | 42 Parameter thisParameter; |
| 43 Parameter explicitReceiverParameter; | 43 Parameter explicitReceiverParameter; |
| 44 | 44 |
| 45 // In a catch block, rethrow implicitly throws the block's exception | 45 // In a catch block, rethrow implicitly throws the block's exception |
| 46 // parameter. This is the exception parameter when nested in a catch | 46 // parameter. This is the exception parameter when nested in a catch |
| 47 // block and null otherwise. | 47 // block and null otherwise. |
| 48 Parameter _exceptionParameter = null; | 48 Parameter _exceptionParameter = null; |
| 49 | 49 |
| 50 UnsugarVisitor(this._glue); | 50 UnsugarVisitor(this._glue); |
| 51 | 51 |
| 52 String get passName => 'Unsugaring'; |
| 53 |
| 52 bool methodUsesReceiverArgument(FunctionElement function) { | 54 bool methodUsesReceiverArgument(FunctionElement function) { |
| 53 assert(_glue.isInterceptedMethod(function)); | 55 assert(_glue.isInterceptedMethod(function)); |
| 54 ClassElement clazz = function.enclosingClass.declaration; | 56 ClassElement clazz = function.enclosingClass.declaration; |
| 55 return _glue.isInterceptorClass(clazz) || | 57 return _glue.isInterceptorClass(clazz) || |
| 56 _glue.isUsedAsMixin(clazz); | 58 _glue.isUsedAsMixin(clazz); |
| 57 } | 59 } |
| 58 | 60 |
| 59 void rewrite(FunctionDefinition function) { | 61 void rewrite(FunctionDefinition function) { |
| 60 thisParameter = function.thisParameter; | 62 thisParameter = function.thisParameter; |
| 61 bool inInterceptedMethod = _glue.isInterceptedMethod(function.element); | 63 bool inInterceptedMethod = _glue.isInterceptedMethod(function.element); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 insertLetPrim(newReceiver, contBinding); | 277 insertLetPrim(newReceiver, contBinding); |
| 276 } | 278 } |
| 277 node.arguments.insert(0, node.receiver); | 279 node.arguments.insert(0, node.receiver); |
| 278 node.receiver = new Reference<Primitive>(newReceiver); | 280 node.receiver = new Reference<Primitive>(newReceiver); |
| 279 } | 281 } |
| 280 | 282 |
| 281 processInterceptor(Interceptor node) { | 283 processInterceptor(Interceptor node) { |
| 282 _glue.registerSpecializedGetInterceptor(node.interceptedClasses); | 284 _glue.registerSpecializedGetInterceptor(node.interceptedClasses); |
| 283 } | 285 } |
| 284 } | 286 } |
| OLD | NEW |