| 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 library dart2js.resolution.members; |     5 library dart2js.resolution.members; | 
|     6  |     6  | 
|     7 import '../common.dart'; |     7 import '../common.dart'; | 
|     8 import '../common/names.dart' show Selectors; |     8 import '../common/names.dart' show Selectors; | 
|     9 import '../common/resolution.dart' show Resolution; |     9 import '../common/resolution.dart' show Resolution; | 
|    10 import '../compile_time_constants.dart'; |    10 import '../compile_time_constants.dart'; | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    78    * The current enclosing element for the visited AST nodes. |    78    * The current enclosing element for the visited AST nodes. | 
|    79    * |    79    * | 
|    80    * This field is updated when nested closures are visited. |    80    * This field is updated when nested closures are visited. | 
|    81    */ |    81    */ | 
|    82   Element enclosingElement; |    82   Element enclosingElement; | 
|    83  |    83  | 
|    84   /// Whether we are in a context where `this` is accessible (this will be false |    84   /// Whether we are in a context where `this` is accessible (this will be false | 
|    85   /// in static contexts, factory methods, and field initializers). |    85   /// in static contexts, factory methods, and field initializers). | 
|    86   bool inInstanceContext; |    86   bool inInstanceContext; | 
|    87   bool inCheckContext; |    87   bool inCheckContext; | 
 |    88   bool inCatchParameters = false; | 
|    88   bool inCatchBlock; |    89   bool inCatchBlock; | 
|    89   ConstantState constantState; |    90   ConstantState constantState; | 
|    90  |    91  | 
|    91   Scope scope; |    92   Scope scope; | 
|    92   ClassElement currentClass; |    93   ClassElement currentClass; | 
|    93   ExpressionStatement currentExpressionStatement; |    94   ExpressionStatement currentExpressionStatement; | 
|    94  |    95  | 
|    95   /// `true` if a [Send] or [SendSet] is visited as the prefix of member access. |    96   /// `true` if a [Send] or [SendSet] is visited as the prefix of member access. | 
|    96   /// For instance `Class` in `Class.staticField` or `prefix.Class` in |    97   /// For instance `Class` in `Class.staticField` or `prefix.Class` in | 
|    97   /// `prefix.Class.staticMethod()`. |    98   /// `prefix.Class.staticMethod()`. | 
| (...skipping 4598 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4696           !link.isEmpty; |  4697           !link.isEmpty; | 
|  4697           link = link.tail) { |  4698           link = link.tail) { | 
|  4698         // If the formal parameter is a node list, it means that it is a |  4699         // If the formal parameter is a node list, it means that it is a | 
|  4699         // sequence of optional parameters. |  4700         // sequence of optional parameters. | 
|  4700         NodeList nodeList = link.head.asNodeList(); |  4701         NodeList nodeList = link.head.asNodeList(); | 
|  4701         if (nodeList != null) { |  4702         if (nodeList != null) { | 
|  4702           reporter.reportErrorMessage( |  4703           reporter.reportErrorMessage( | 
|  4703               nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH); |  4704               nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH); | 
|  4704         } else { |  4705         } else { | 
|  4705           VariableDefinitions declaration = link.head; |  4706           VariableDefinitions declaration = link.head; | 
 |  4707  | 
|  4706           for (Node modifier in declaration.modifiers.nodes) { |  4708           for (Node modifier in declaration.modifiers.nodes) { | 
|  4707             reporter.reportErrorMessage( |  4709             reporter.reportErrorMessage( | 
|  4708                 modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH); |  4710                 modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH); | 
|  4709           } |  4711           } | 
|  4710           TypeAnnotation type = declaration.type; |  4712           TypeAnnotation type = declaration.type; | 
|  4711           if (type != null) { |  4713           if (type != null) { | 
|  4712             reporter.reportErrorMessage( |  4714             reporter.reportErrorMessage( | 
|  4713                 type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH); |  4715                 type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH); | 
|  4714           } |  4716           } | 
|  4715         } |  4717         } | 
|  4716       } |  4718       } | 
|  4717     } |  4719     } | 
|  4718  |  4720  | 
|  4719     Scope blockScope = new BlockScope(scope); |  4721     Scope blockScope = new BlockScope(scope); | 
|  4720     TypeResult exceptionTypeResult = visitIn(node.type, blockScope); |  4722     inCatchParameters = true; | 
|  4721     visitIn(node.formals, blockScope); |  4723     visitIn(node.formals, blockScope); | 
 |  4724     inCatchParameters = false; | 
|  4722     var oldInCatchBlock = inCatchBlock; |  4725     var oldInCatchBlock = inCatchBlock; | 
|  4723     inCatchBlock = true; |  4726     inCatchBlock = true; | 
|  4724     visitIn(node.block, blockScope); |  4727     visitIn(node.block, blockScope); | 
|  4725     inCatchBlock = oldInCatchBlock; |  4728     inCatchBlock = oldInCatchBlock; | 
|  4726  |  4729  | 
|  4727     if (exceptionTypeResult != null) { |  4730     if (node.type != null) { | 
|  4728       DartType exceptionType = exceptionTypeResult.type; |  4731       DartType exceptionType = | 
 |  4732           resolveTypeAnnotation(node.type, registerCheckedModeCheck: false); | 
|  4729       if (exceptionDefinition != null) { |  4733       if (exceptionDefinition != null) { | 
|  4730         Node exceptionVariable = exceptionDefinition.definitions.nodes.head; |  4734         Node exceptionVariable = exceptionDefinition.definitions.nodes.head; | 
|  4731         VariableElementX exceptionElement = |  4735         VariableElementX exceptionElement = | 
|  4732             registry.getDefinition(exceptionVariable); |  4736             registry.getDefinition(exceptionVariable); | 
|  4733         exceptionElement.variables.type = exceptionType; |  4737         exceptionElement.variables.type = exceptionType; | 
|  4734       } |  4738       } | 
|  4735       registry.registerTypeUse(new TypeUse.catchType(exceptionType)); |  4739       registry.registerTypeUse(new TypeUse.catchType(exceptionType)); | 
|  4736     } |  4740     } | 
|  4737     if (stackTraceDefinition != null) { |  4741     if (stackTraceDefinition != null) { | 
|  4738       Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; |  4742       Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; | 
|  4739       VariableElementX stackTraceElement = |  4743       VariableElementX stackTraceElement = | 
|  4740           registry.getDefinition(stackTraceVariable); |  4744           registry.getDefinition(stackTraceVariable); | 
|  4741       InterfaceType stackTraceType = coreTypes.stackTraceType; |  4745       InterfaceType stackTraceType = coreTypes.stackTraceType; | 
|  4742       stackTraceElement.variables.type = stackTraceType; |  4746       stackTraceElement.variables.type = stackTraceType; | 
|  4743     } |  4747     } | 
|  4744     return const NoneResult(); |  4748     return const NoneResult(); | 
|  4745   } |  4749   } | 
|  4746 } |  4750 } | 
|  4747  |  4751  | 
|  4748 /// Looks up [name] in [scope] and unwraps the result. |  4752 /// Looks up [name] in [scope] and unwraps the result. | 
|  4749 Element lookupInScope( |  4753 Element lookupInScope( | 
|  4750     DiagnosticReporter reporter, Node node, Scope scope, String name) { |  4754     DiagnosticReporter reporter, Node node, Scope scope, String name) { | 
|  4751   return Elements.unwrap(scope.lookup(name), reporter, node); |  4755   return Elements.unwrap(scope.lookup(name), reporter, node); | 
|  4752 } |  4756 } | 
| OLD | NEW |