OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 return super_op; | 1067 return super_op; |
1068 } | 1068 } |
1069 | 1069 |
1070 | 1070 |
1071 AstNode* Parser::CreateImplicitClosureNode(const Function& func, | 1071 AstNode* Parser::CreateImplicitClosureNode(const Function& func, |
1072 intptr_t token_pos, | 1072 intptr_t token_pos, |
1073 AstNode* receiver) { | 1073 AstNode* receiver) { |
1074 Function& implicit_closure_function = | 1074 Function& implicit_closure_function = |
1075 Function::ZoneHandle(func.ImplicitClosureFunction()); | 1075 Function::ZoneHandle(func.ImplicitClosureFunction()); |
1076 ASSERT(!implicit_closure_function.IsNull()); | 1076 ASSERT(!implicit_closure_function.IsNull()); |
1077 ASSERT(implicit_closure_function.is_static()); // TODO(regis): For now. | 1077 ASSERT(func.is_static() == implicit_closure_function.is_static()); |
1078 AstNode* node; | 1078 AstNode* node; |
1079 if (receiver == NULL) { | 1079 if (receiver == NULL) { |
1080 ASSERT(func.is_static()); | 1080 ASSERT(func.is_static()); |
1081 node = new StaticImplicitClosureNode(token_pos, implicit_closure_function); | 1081 node = new StaticImplicitClosureNode(token_pos, implicit_closure_function); |
1082 } else { | 1082 } else { |
1083 ASSERT(!func.is_static()); | 1083 ASSERT(!func.is_static()); |
1084 node = new ImplicitClosureNode(token_pos, | 1084 node = new ImplicitClosureNode(token_pos, |
1085 implicit_closure_function, | 1085 implicit_closure_function, |
1086 receiver); | 1086 receiver); |
1087 } | 1087 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1413 return MakeImplicitConstructor(func); | 1413 return MakeImplicitConstructor(func); |
1414 } | 1414 } |
1415 | 1415 |
1416 // Build local scope for function. | 1416 // Build local scope for function. |
1417 OpenFunctionBlock(func); | 1417 OpenFunctionBlock(func); |
1418 | 1418 |
1419 ParamList params; | 1419 ParamList params; |
1420 // The first parameter of a factory is the TypeArguments vector of the type | 1420 // The first parameter of a factory is the TypeArguments vector of the type |
1421 // of the instance to be allocated. We name this hidden parameter 'this'. | 1421 // of the instance to be allocated. We name this hidden parameter 'this'. |
1422 const bool has_receiver = | 1422 const bool has_receiver = |
1423 !func.is_static() || func.IsConstructor() || func.IsFactory(); | 1423 !func.IsClosureFunction() && |
siva
2011/10/11 21:00:46
Maybe we should append to the comment as to why
fu
regis
2011/10/11 23:40:19
I added a comment.
I prefer that is_static() refle
| |
1424 (!func.is_static() || func.IsConstructor() || func.IsFactory()); | |
1424 const bool are_implicitly_final = func.is_const() && func.IsConstructor(); | 1425 const bool are_implicitly_final = func.is_const() && func.IsConstructor(); |
1425 const bool allow_explicit_default_values = true; | 1426 const bool allow_explicit_default_values = true; |
1426 ASSERT(CurrentToken() == Token::kLPAREN); | 1427 ASSERT(CurrentToken() == Token::kLPAREN); |
1427 if (has_receiver) { | 1428 if (has_receiver) { |
1428 params.AddReceiver(token_index_); | 1429 params.AddReceiver(token_index_); |
1429 } | 1430 } |
1430 if (are_implicitly_final) { | 1431 if (are_implicitly_final) { |
1431 params.SetImplicitlyFinal(); | 1432 params.SetImplicitlyFinal(); |
1432 } | 1433 } |
1433 ParseFormalParameterList(allow_explicit_default_values, ¶ms); | 1434 ParseFormalParameterList(allow_explicit_default_values, ¶ms); |
(...skipping 5495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6929 } | 6930 } |
6930 | 6931 |
6931 | 6932 |
6932 void Parser::SkipNestedExpr() { | 6933 void Parser::SkipNestedExpr() { |
6933 const bool saved_mode = SetAllowFunctionLiterals(true); | 6934 const bool saved_mode = SetAllowFunctionLiterals(true); |
6934 SkipExpr(); | 6935 SkipExpr(); |
6935 SetAllowFunctionLiterals(saved_mode); | 6936 SetAllowFunctionLiterals(saved_mode); |
6936 } | 6937 } |
6937 | 6938 |
6938 } // namespace dart | 6939 } // namespace dart |
OLD | NEW |