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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 Element get currentElement; | 8 Element get currentElement; |
| 9 Set<Node> get superUses; | 9 Set<Node> get superUses; |
| 10 | 10 |
| (...skipping 2956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2967 error(node, MessageKind.NO_CATCH_NOR_FINALLY); | 2967 error(node, MessageKind.NO_CATCH_NOR_FINALLY); |
| 2968 } | 2968 } |
| 2969 visit(node.catchBlocks); | 2969 visit(node.catchBlocks); |
| 2970 visit(node.finallyBlock); | 2970 visit(node.finallyBlock); |
| 2971 } | 2971 } |
| 2972 | 2972 |
| 2973 visitCatchBlock(CatchBlock node) { | 2973 visitCatchBlock(CatchBlock node) { |
| 2974 compiler.backend.registerCatchStatement(world, mapping); | 2974 compiler.backend.registerCatchStatement(world, mapping); |
| 2975 // Check that if catch part is present, then | 2975 // Check that if catch part is present, then |
| 2976 // it has one or two formal parameters. | 2976 // it has one or two formal parameters. |
| 2977 VariableDefinitions exceptionDefinition; | |
| 2978 VariableDefinitions stackTraceDefinition; | |
| 2977 if (node.formals != null) { | 2979 if (node.formals != null) { |
| 2978 if (node.formals.isEmpty) { | 2980 if (node.formals.isEmpty) { |
| 2979 error(node, MessageKind.EMPTY_CATCH_DECLARATION); | 2981 error(node, MessageKind.EMPTY_CATCH_DECLARATION); |
| 2980 } | 2982 } else { |
| 2981 if (!node.formals.nodes.tail.isEmpty) { | 2983 exceptionDefinition = node.formals.nodes.head; |
|
karlklose
2013/05/27 08:45:22
Store node.formals.nodes in a local.
Johnni Winther
2013/05/27 11:01:23
Done.
| |
| 2982 if (!node.formals.nodes.tail.tail.isEmpty) { | 2984 if (!node.formals.nodes.tail.isEmpty) { |
| 2983 for (Node extra in node.formals.nodes.tail.tail) { | 2985 stackTraceDefinition = node.formals.nodes.tail.head; |
| 2984 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); | 2986 if (!node.formals.nodes.tail.tail.isEmpty) { |
|
karlklose
2013/05/27 08:45:22
Also for node.formals.nodes.tail.tail.
Johnni Winther
2013/05/27 11:01:23
Done.
| |
| 2987 for (Node extra in node.formals.nodes.tail.tail) { | |
| 2988 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); | |
| 2989 } | |
| 2985 } | 2990 } |
| 2991 compiler.backend.registerStackTraceInCatch(mapping); | |
| 2986 } | 2992 } |
| 2987 compiler.backend.registerStackTraceInCatch(mapping); | |
| 2988 } | 2993 } |
| 2989 | 2994 |
| 2990 // Check that the formals aren't optional and that they have no | 2995 // Check that the formals aren't optional and that they have no |
| 2991 // modifiers or type. | 2996 // modifiers or type. |
| 2992 for (Link<Node> link = node.formals.nodes; | 2997 for (Link<Node> link = node.formals.nodes; |
| 2993 !link.isEmpty; | 2998 !link.isEmpty; |
| 2994 link = link.tail) { | 2999 link = link.tail) { |
| 2995 // If the formal parameter is a node list, it means that it is a | 3000 // If the formal parameter is a node list, it means that it is a |
| 2996 // sequence of optional parameters. | 3001 // sequence of optional parameters. |
| 2997 NodeList nodeList = link.head.asNodeList(); | 3002 NodeList nodeList = link.head.asNodeList(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3013 Scope blockScope = new BlockScope(scope); | 3018 Scope blockScope = new BlockScope(scope); |
| 3014 var wasTypeRequired = typeRequired; | 3019 var wasTypeRequired = typeRequired; |
| 3015 typeRequired = true; | 3020 typeRequired = true; |
| 3016 doInCheckContext(() => visitIn(node.type, blockScope)); | 3021 doInCheckContext(() => visitIn(node.type, blockScope)); |
| 3017 typeRequired = wasTypeRequired; | 3022 typeRequired = wasTypeRequired; |
| 3018 visitIn(node.formals, blockScope); | 3023 visitIn(node.formals, blockScope); |
| 3019 var oldInCatchBlock = inCatchBlock; | 3024 var oldInCatchBlock = inCatchBlock; |
| 3020 inCatchBlock = true; | 3025 inCatchBlock = true; |
| 3021 visitIn(node.block, blockScope); | 3026 visitIn(node.block, blockScope); |
| 3022 inCatchBlock = oldInCatchBlock; | 3027 inCatchBlock = oldInCatchBlock; |
| 3028 | |
| 3029 if (node.type != null && exceptionDefinition != null) { | |
| 3030 DartType exceptionType = mapping.getType(node.type); | |
| 3031 Node exceptionVariable = exceptionDefinition.definitions.nodes.head; | |
| 3032 VariableElementX exceptionElement = mapping[exceptionVariable]; | |
| 3033 exceptionElement.variables.type = exceptionType; | |
| 3034 } | |
| 3035 if (stackTraceDefinition != null) { | |
| 3036 Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; | |
| 3037 VariableElementX stackTraceElement = mapping[stackTraceVariable]; | |
| 3038 world.registerInstantiatedClass(compiler.stackTraceClass, mapping); | |
| 3039 stackTraceElement.variables.type = | |
| 3040 compiler.stackTraceClass.computeType(compiler); | |
|
karlklose
2013/05/27 08:45:22
Use rawType instead of computeType. I'd like to ge
Johnni Winther
2013/05/27 11:01:23
Done.
| |
| 3041 } | |
| 3023 } | 3042 } |
| 3024 | 3043 |
| 3025 visitTypedef(Typedef node) { | 3044 visitTypedef(Typedef node) { |
| 3026 unimplemented(node, 'typedef'); | 3045 unimplemented(node, 'typedef'); |
| 3027 } | 3046 } |
| 3028 } | 3047 } |
| 3029 | 3048 |
| 3030 class TypeDefinitionVisitor extends MappingVisitor<DartType> { | 3049 class TypeDefinitionVisitor extends MappingVisitor<DartType> { |
| 3031 Scope scope; | 3050 Scope scope; |
| 3032 final TypeDeclarationElement enclosingElement; | 3051 final TypeDeclarationElement enclosingElement; |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3938 return e; | 3957 return e; |
| 3939 } | 3958 } |
| 3940 | 3959 |
| 3941 /// Assumed to be called by [resolveRedirectingFactory]. | 3960 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3942 Element visitReturn(Return node) { | 3961 Element visitReturn(Return node) { |
| 3943 Node expression = node.expression; | 3962 Node expression = node.expression; |
| 3944 return finishConstructorReference(visit(expression), | 3963 return finishConstructorReference(visit(expression), |
| 3945 expression, expression); | 3964 expression, expression); |
| 3946 } | 3965 } |
| 3947 } | 3966 } |
| OLD | NEW |