OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
8 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 8 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
9 | 9 |
10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
(...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 } | 2420 } |
2421 | 2421 |
2422 void exitFunction() { | 2422 void exitFunction() { |
2423 debugEvent("exitFunction"); | 2423 debugEvent("exitFunction"); |
2424 functionNestingLevel--; | 2424 functionNestingLevel--; |
2425 inCatchBlock = pop(); | 2425 inCatchBlock = pop(); |
2426 switchScope = pop(); | 2426 switchScope = pop(); |
2427 } | 2427 } |
2428 | 2428 |
2429 @override | 2429 @override |
2430 void beginFunctionDeclaration(Token token) { | 2430 void beginLocalFunctionDeclaration(Token token) { |
2431 debugEvent("beginNamedFunctionExpression"); | 2431 debugEvent("beginLocalFunctionDeclaration"); |
2432 enterFunction(); | 2432 enterFunction(); |
2433 } | 2433 } |
2434 | 2434 |
2435 @override | 2435 @override |
2436 void beginNamedFunctionExpression(Token token) { | 2436 void beginNamedFunctionExpression(Token token) { |
2437 debugEvent("beginNamedFunctionExpression"); | 2437 debugEvent("beginNamedFunctionExpression"); |
2438 enterFunction(); | 2438 enterFunction(); |
2439 } | 2439 } |
2440 | 2440 |
2441 @override | 2441 @override |
(...skipping 25 matching lines...) Expand all Loading... |
2467 new FunctionNode(body, | 2467 new FunctionNode(body, |
2468 typeParameters: typeParameters, asyncMarker: asyncModifier) | 2468 typeParameters: typeParameters, asyncMarker: asyncModifier) |
2469 ..fileOffset = formals.charOffset | 2469 ..fileOffset = formals.charOffset |
2470 ..fileEndOffset = endToken.charOffset)) | 2470 ..fileEndOffset = endToken.charOffset)) |
2471 ..parent = variable | 2471 ..parent = variable |
2472 ..fileOffset = formals.charOffset; | 2472 ..fileOffset = formals.charOffset; |
2473 push(new Let(variable, new VariableGet(variable))); | 2473 push(new Let(variable, new VariableGet(variable))); |
2474 } | 2474 } |
2475 | 2475 |
2476 @override | 2476 @override |
2477 void endFunctionDeclaration(Token endToken) { | 2477 void endLocalFunctionDeclaration(Token token) { |
2478 debugEvent("FunctionDeclaration"); | 2478 debugEvent("LocalFunctionDeclaration"); |
2479 Statement body = popStatement(); | 2479 Statement body = popStatement(); |
2480 AsyncMarker asyncModifier = pop(); | 2480 AsyncMarker asyncModifier = pop(); |
2481 if (functionNestingLevel != 0) { | 2481 if (functionNestingLevel != 0) { |
2482 exitLocalScope(); | 2482 exitLocalScope(); |
2483 } | 2483 } |
2484 FormalParameters formals = pop(); | 2484 FormalParameters formals = pop(); |
2485 List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop()); | 2485 List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop()); |
2486 FunctionNode function = formals.addToFunction(new FunctionNode(body, | 2486 FunctionNode function = formals.addToFunction(new FunctionNode(body, |
2487 typeParameters: typeParameters, asyncMarker: asyncModifier) | 2487 typeParameters: typeParameters, asyncMarker: asyncModifier) |
2488 ..fileOffset = formals.charOffset | 2488 ..fileOffset = formals.charOffset |
2489 ..fileEndOffset = endToken.charOffset); | 2489 ..fileEndOffset = token.charOffset); |
2490 exitLocalScope(); | 2490 exitLocalScope(); |
2491 var declaration = pop(); | 2491 var declaration = pop(); |
2492 var returnType = pop(); | 2492 var returnType = pop(); |
2493 var hasImplicitReturnType = returnType == null; | 2493 var hasImplicitReturnType = returnType == null; |
2494 returnType ??= const DynamicType(); | 2494 returnType ??= const DynamicType(); |
2495 pop(); // Modifiers. | 2495 pop(); // Modifiers. |
2496 exitFunction(); | 2496 exitFunction(); |
2497 if (declaration is FunctionDeclaration) { | 2497 if (declaration is FunctionDeclaration) { |
2498 KernelFunctionDeclaration.setHasImplicitReturnType( | 2498 KernelFunctionDeclaration.setHasImplicitReturnType( |
2499 declaration, hasImplicitReturnType); | 2499 declaration, hasImplicitReturnType); |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3788 return AsyncMarker.Async; | 3788 return AsyncMarker.Async; |
3789 } else { | 3789 } else { |
3790 assert(identical(starToken.stringValue, "*")); | 3790 assert(identical(starToken.stringValue, "*")); |
3791 return AsyncMarker.AsyncStar; | 3791 return AsyncMarker.AsyncStar; |
3792 } | 3792 } |
3793 } else { | 3793 } else { |
3794 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3794 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3795 asyncToken.charOffset, null); | 3795 asyncToken.charOffset, null); |
3796 } | 3796 } |
3797 } | 3797 } |
OLD | NEW |