| 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 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // committed to the current version. | 52 // committed to the current version. |
| 53 DEFINE_FLAG(bool, | 53 DEFINE_FLAG(bool, |
| 54 conditional_directives, | 54 conditional_directives, |
| 55 true, | 55 true, |
| 56 "Enable conditional directives"); | 56 "Enable conditional directives"); |
| 57 DEFINE_FLAG(bool, | 57 DEFINE_FLAG(bool, |
| 58 generic_method_syntax, | 58 generic_method_syntax, |
| 59 true, | 59 true, |
| 60 "Enable generic function syntax."); | 60 "Enable generic function syntax."); |
| 61 DEFINE_FLAG(bool, | 61 DEFINE_FLAG(bool, |
| 62 generic_method_semantics, | |
| 63 false, | |
| 64 "Enable generic function semantics (not yet supported)."); | |
| 65 DEFINE_FLAG(bool, | |
| 66 initializing_formal_access, | 62 initializing_formal_access, |
| 67 true, | 63 true, |
| 68 "Make initializing formal parameters visible in initializer list."); | 64 "Make initializing formal parameters visible in initializer list."); |
| 69 DEFINE_FLAG(bool, | 65 DEFINE_FLAG(bool, |
| 70 warn_super, | 66 warn_super, |
| 71 false, | 67 false, |
| 72 "Warning if super initializer not last in initializer list."); | 68 "Warning if super initializer not last in initializer list."); |
| 73 DEFINE_FLAG( | 69 DEFINE_FLAG( |
| 74 bool, | 70 bool, |
| 75 await_is_keyword, | 71 await_is_keyword, |
| 76 false, | 72 false, |
| 77 "await and yield are treated as proper keywords in synchronous code."); | 73 "await and yield are treated as proper keywords in synchronous code."); |
| 78 DEFINE_FLAG(bool, | 74 DEFINE_FLAG(bool, |
| 79 assert_initializer, | 75 assert_initializer, |
| 80 false, | 76 false, |
| 81 "Allow asserts in initializer lists."); | 77 "Allow asserts in initializer lists."); |
| 82 | 78 |
| 79 DECLARE_FLAG(bool, reify_generic_functions); |
| 83 DECLARE_FLAG(bool, profile_vm); | 80 DECLARE_FLAG(bool, profile_vm); |
| 84 DECLARE_FLAG(bool, trace_service); | 81 DECLARE_FLAG(bool, trace_service); |
| 85 DECLARE_FLAG(bool, ignore_patch_signature_mismatch); | 82 DECLARE_FLAG(bool, ignore_patch_signature_mismatch); |
| 86 | 83 |
| 87 // Quick access to the current thread, isolate and zone. | 84 // Quick access to the current thread, isolate and zone. |
| 88 #define T (thread()) | 85 #define T (thread()) |
| 89 #define I (isolate()) | 86 #define I (isolate()) |
| 90 #define Z (zone()) | 87 #define Z (zone()) |
| 91 | 88 |
| 92 // Quick synthetic token position. | 89 // Quick synthetic token position. |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 kTestOnly); | 1172 kTestOnly); |
| 1176 } else { | 1173 } else { |
| 1177 instantiator = parser.LookupReceiver(node_sequence->scope(), kTestOnly); | 1174 instantiator = parser.LookupReceiver(node_sequence->scope(), kTestOnly); |
| 1178 } | 1175 } |
| 1179 if (!parser.current_function().IsLocalFunction() || | 1176 if (!parser.current_function().IsLocalFunction() || |
| 1180 ((instantiator != NULL) && instantiator->is_captured())) { | 1177 ((instantiator != NULL) && instantiator->is_captured())) { |
| 1181 parsed_function->set_instantiator(instantiator); | 1178 parsed_function->set_instantiator(instantiator); |
| 1182 } | 1179 } |
| 1183 } | 1180 } |
| 1184 // ParseFunc has recorded the generic function type arguments variable. | 1181 // ParseFunc has recorded the generic function type arguments variable. |
| 1185 ASSERT(!FLAG_generic_method_semantics || | 1182 ASSERT(!FLAG_reify_generic_functions || |
| 1186 !parser.current_function().IsGeneric() || | 1183 !parser.current_function().IsGeneric() || |
| 1187 (parsed_function->function_type_arguments() != NULL)); | 1184 (parsed_function->function_type_arguments() != NULL)); |
| 1188 } | 1185 } |
| 1189 | 1186 |
| 1190 | 1187 |
| 1191 RawObject* Parser::ParseMetadata(const Field& meta_data) { | 1188 RawObject* Parser::ParseMetadata(const Field& meta_data) { |
| 1192 LongJumpScope jump; | 1189 LongJumpScope jump; |
| 1193 if (setjmp(*jump.Set()) == 0) { | 1190 if (setjmp(*jump.Set()) == 0) { |
| 1194 Thread* thread = Thread::Current(); | 1191 Thread* thread = Thread::Current(); |
| 1195 StackZone stack_zone(thread); | 1192 StackZone stack_zone(thread); |
| (...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3457 | 3454 |
| 3458 if (func.IsGenerativeConstructor()) { | 3455 if (func.IsGenerativeConstructor()) { |
| 3459 SequenceNode* statements = ParseConstructor(func); | 3456 SequenceNode* statements = ParseConstructor(func); |
| 3460 last_used_try_index_ = saved_try_index; | 3457 last_used_try_index_ = saved_try_index; |
| 3461 return statements; | 3458 return statements; |
| 3462 } | 3459 } |
| 3463 | 3460 |
| 3464 ASSERT(!func.IsGenerativeConstructor()); | 3461 ASSERT(!func.IsGenerativeConstructor()); |
| 3465 OpenFunctionBlock(func); // Build local scope for function. | 3462 OpenFunctionBlock(func); // Build local scope for function. |
| 3466 | 3463 |
| 3467 if (FLAG_generic_method_semantics && func.IsGeneric()) { | 3464 if (FLAG_reify_generic_functions && func.IsGeneric()) { |
| 3468 // Lookup function type arguments variable in parent function scope, if any. | 3465 // Lookup function type arguments variable in parent function scope, if any. |
| 3469 if (func.HasGenericParent()) { | 3466 if (func.HasGenericParent()) { |
| 3470 const String* variable_name = &Symbols::FunctionTypeArgumentsVar(); | 3467 const String* variable_name = &Symbols::FunctionTypeArgumentsVar(); |
| 3471 LocalVariable* parent_type_arguments = | 3468 LocalVariable* parent_type_arguments = |
| 3472 current_block_->scope->LookupVariable(*variable_name, true); | 3469 current_block_->scope->LookupVariable(*variable_name, true); |
| 3473 ASSERT(parent_type_arguments != NULL); | 3470 ASSERT(parent_type_arguments != NULL); |
| 3474 // TODO(regis): It may be too early to capture parent_type_arguments here. | 3471 // TODO(regis): It may be too early to capture parent_type_arguments here. |
| 3475 // In case it is never used, we could save capturing and concatenating. | 3472 // In case it is never used, we could save capturing and concatenating. |
| 3476 current_block_->scope->CaptureVariable(parent_type_arguments); | 3473 current_block_->scope->CaptureVariable(parent_type_arguments); |
| 3477 parsed_function_->set_parent_type_arguments(parent_type_arguments); | 3474 parsed_function_->set_parent_type_arguments(parent_type_arguments); |
| (...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5523 for (intptr_t i = 0; i < index; i++) { | 5520 for (intptr_t i = 0; i < index; i++) { |
| 5524 existing_type_parameter ^= type_parameters_array.At(i)->raw(); | 5521 existing_type_parameter ^= type_parameters_array.At(i)->raw(); |
| 5525 existing_type_parameter_name = existing_type_parameter.name(); | 5522 existing_type_parameter_name = existing_type_parameter.name(); |
| 5526 if (existing_type_parameter_name.Equals(type_parameter_name)) { | 5523 if (existing_type_parameter_name.Equals(type_parameter_name)) { |
| 5527 ReportError(type_parameter_pos, "duplicate type parameter '%s'", | 5524 ReportError(type_parameter_pos, "duplicate type parameter '%s'", |
| 5528 type_parameter_name.ToCString()); | 5525 type_parameter_name.ToCString()); |
| 5529 } | 5526 } |
| 5530 } | 5527 } |
| 5531 if ((CurrentToken() == Token::kEXTENDS) || | 5528 if ((CurrentToken() == Token::kEXTENDS) || |
| 5532 (!parameterizing_class && (CurrentToken() == Token::kSUPER))) { | 5529 (!parameterizing_class && (CurrentToken() == Token::kSUPER))) { |
| 5530 const bool is_lower_bound = CurrentToken() == Token::kSUPER; |
| 5533 ConsumeToken(); | 5531 ConsumeToken(); |
| 5534 // TODO(regis): Handle 'super' differently than 'extends'. | |
| 5535 // A bound may refer to the owner of the type parameter it applies to, | 5532 // A bound may refer to the owner of the type parameter it applies to, |
| 5536 // i.e. to the class or function currently being parsed. | 5533 // i.e. to the class or function currently being parsed. |
| 5537 // Postpone resolution in order to avoid resolving the owner and its | 5534 // Postpone resolution in order to avoid resolving the owner and its |
| 5538 // type parameters, as they are not fully parsed yet. | 5535 // type parameters, as they are not fully parsed yet. |
| 5539 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve); | 5536 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve); |
| 5537 if (is_lower_bound) { |
| 5538 // TODO(regis): Handle 'super' differently than 'extends' if lower |
| 5539 // bounds make it in the final specification and if run time support |
| 5540 // for lower bounds is required. |
| 5541 // For now, we parse but ignore lower bounds and only support upper |
| 5542 // bounds. |
| 5543 type_parameter_bound = I->object_store()->object_type(); |
| 5544 } |
| 5540 } else { | 5545 } else { |
| 5541 type_parameter_bound = I->object_store()->object_type(); | 5546 type_parameter_bound = I->object_store()->object_type(); |
| 5542 } | 5547 } |
| 5543 // Note that we cannot yet calculate the final index of a function type | 5548 // Note that we cannot yet calculate the final index of a function type |
| 5544 // parameter, because we may not have parsed the parent function yet. | 5549 // parameter, because we may not have parsed the parent function yet. |
| 5545 type_parameter = TypeParameter::New( | 5550 type_parameter = TypeParameter::New( |
| 5546 parameterizing_class ? current_class() : Class::Handle(Z), | 5551 parameterizing_class ? current_class() : Class::Handle(Z), |
| 5547 parameterizing_class ? Function::Handle(Z) : innermost_function(), | 5552 parameterizing_class ? Function::Handle(Z) : innermost_function(), |
| 5548 index, type_parameter_name, type_parameter_bound, declaration_pos); | 5553 index, type_parameter_name, type_parameter_bound, declaration_pos); |
| 5549 type_parameters_array.Add( | 5554 type_parameters_array.Add( |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6890 body = found_func.raw(); | 6895 body = found_func.raw(); |
| 6891 body_closure_name = body.name(); | 6896 body_closure_name = body.name(); |
| 6892 } else { | 6897 } else { |
| 6893 // Create the closure containing the body of this generator function. | 6898 // Create the closure containing the body of this generator function. |
| 6894 String& generator_name = String::Handle(Z, innermost_function().name()); | 6899 String& generator_name = String::Handle(Z, innermost_function().name()); |
| 6895 body_closure_name = | 6900 body_closure_name = |
| 6896 Symbols::NewFormatted(T, "<%s_sync_body>", generator_name.ToCString()); | 6901 Symbols::NewFormatted(T, "<%s_sync_body>", generator_name.ToCString()); |
| 6897 body = Function::NewClosureFunction(body_closure_name, innermost_function(), | 6902 body = Function::NewClosureFunction(body_closure_name, innermost_function(), |
| 6898 func_pos); | 6903 func_pos); |
| 6899 body.set_is_generated_body(true); | 6904 body.set_is_generated_body(true); |
| 6905 // TODO(regis): Handle generic generator function. |
| 6900 body.set_result_type(Object::dynamic_type()); | 6906 body.set_result_type(Object::dynamic_type()); |
| 6901 is_new_closure = true; | 6907 is_new_closure = true; |
| 6902 } | 6908 } |
| 6903 | 6909 |
| 6904 ParamList closure_params; | 6910 ParamList closure_params; |
| 6905 AddSyncGenClosureParameters(&closure_params); | 6911 AddSyncGenClosureParameters(&closure_params); |
| 6906 | 6912 |
| 6907 if (is_new_closure) { | 6913 if (is_new_closure) { |
| 6908 // Add the parameters to the newly created closure. | 6914 // Add the parameters to the newly created closure. |
| 6909 AddFormalParamsToFunction(&closure_params, body); | 6915 AddFormalParamsToFunction(&closure_params, body); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7018 } else { | 7024 } else { |
| 7019 // Create the closure containing the body of this async function. | 7025 // Create the closure containing the body of this async function. |
| 7020 const String& async_func_name = | 7026 const String& async_func_name = |
| 7021 String::Handle(Z, innermost_function().name()); | 7027 String::Handle(Z, innermost_function().name()); |
| 7022 String& closure_name = | 7028 String& closure_name = |
| 7023 String::Handle(Z, Symbols::NewFormatted(T, "<%s_async_body>", | 7029 String::Handle(Z, Symbols::NewFormatted(T, "<%s_async_body>", |
| 7024 async_func_name.ToCString())); | 7030 async_func_name.ToCString())); |
| 7025 closure = Function::NewClosureFunction(closure_name, innermost_function(), | 7031 closure = Function::NewClosureFunction(closure_name, innermost_function(), |
| 7026 async_func_pos); | 7032 async_func_pos); |
| 7027 closure.set_is_generated_body(true); | 7033 closure.set_is_generated_body(true); |
| 7034 // TODO(regis): Handle generic async function. |
| 7028 closure.set_result_type(Object::dynamic_type()); | 7035 closure.set_result_type(Object::dynamic_type()); |
| 7029 is_new_closure = true; | 7036 is_new_closure = true; |
| 7030 } | 7037 } |
| 7031 // Create the parameter list for the async body closure. | 7038 // Create the parameter list for the async body closure. |
| 7032 ParamList closure_params; | 7039 ParamList closure_params; |
| 7033 AddAsyncClosureParameters(&closure_params); | 7040 AddAsyncClosureParameters(&closure_params); |
| 7034 if (is_new_closure) { | 7041 if (is_new_closure) { |
| 7035 // Add the parameters to the newly created closure. | 7042 // Add the parameters to the newly created closure. |
| 7036 AddFormalParamsToFunction(&closure_params, closure); | 7043 AddFormalParamsToFunction(&closure_params, closure); |
| 7037 ResolveSignature(closure); | 7044 ResolveSignature(closure); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7154 } else { | 7161 } else { |
| 7155 // Create the closure containing the body of this async generator function. | 7162 // Create the closure containing the body of this async generator function. |
| 7156 const String& async_generator_name = | 7163 const String& async_generator_name = |
| 7157 String::Handle(Z, innermost_function().name()); | 7164 String::Handle(Z, innermost_function().name()); |
| 7158 const String& closure_name = String::Handle( | 7165 const String& closure_name = String::Handle( |
| 7159 Z, Symbols::NewFormatted(T, "<%s_async_gen_body>", | 7166 Z, Symbols::NewFormatted(T, "<%s_async_gen_body>", |
| 7160 async_generator_name.ToCString())); | 7167 async_generator_name.ToCString())); |
| 7161 closure = Function::NewClosureFunction(closure_name, innermost_function(), | 7168 closure = Function::NewClosureFunction(closure_name, innermost_function(), |
| 7162 async_func_pos); | 7169 async_func_pos); |
| 7163 closure.set_is_generated_body(true); | 7170 closure.set_is_generated_body(true); |
| 7171 // TODO(regis): Handle generic async generator function. |
| 7164 closure.set_result_type(Object::dynamic_type()); | 7172 closure.set_result_type(Object::dynamic_type()); |
| 7165 is_new_closure = true; | 7173 is_new_closure = true; |
| 7166 } | 7174 } |
| 7167 | 7175 |
| 7168 ParamList closure_params; | 7176 ParamList closure_params; |
| 7169 AddAsyncGenClosureParameters(&closure_params); | 7177 AddAsyncGenClosureParameters(&closure_params); |
| 7170 | 7178 |
| 7171 if (is_new_closure) { | 7179 if (is_new_closure) { |
| 7172 // Add the parameters to the newly created closure. | 7180 // Add the parameters to the newly created closure. |
| 7173 AddFormalParamsToFunction(&closure_params, closure); | 7181 AddFormalParamsToFunction(&closure_params, closure); |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7735 ? &Symbols::TypeArgumentsParameter() | 7743 ? &Symbols::TypeArgumentsParameter() |
| 7736 : &Symbols::This(); | 7744 : &Symbols::This(); |
| 7737 current_block_->scope->CaptureVariable( | 7745 current_block_->scope->CaptureVariable( |
| 7738 current_block_->scope->LookupVariable(*variable_name, true)); | 7746 current_block_->scope->LookupVariable(*variable_name, true)); |
| 7739 } | 7747 } |
| 7740 | 7748 |
| 7741 | 7749 |
| 7742 void Parser::CaptureFunctionTypeArguments() { | 7750 void Parser::CaptureFunctionTypeArguments() { |
| 7743 ASSERT(InGenericFunctionScope()); | 7751 ASSERT(InGenericFunctionScope()); |
| 7744 ASSERT(FunctionLevel() > 0); | 7752 ASSERT(FunctionLevel() > 0); |
| 7745 if (!FLAG_generic_method_semantics) { | 7753 if (!FLAG_reify_generic_functions) { |
| 7746 return; | 7754 return; |
| 7747 } | 7755 } |
| 7748 const String* variable_name = &Symbols::FunctionTypeArgumentsVar(); | 7756 const String* variable_name = &Symbols::FunctionTypeArgumentsVar(); |
| 7749 current_block_->scope->CaptureVariable( | 7757 current_block_->scope->CaptureVariable( |
| 7750 current_block_->scope->LookupVariable(*variable_name, true)); | 7758 current_block_->scope->LookupVariable(*variable_name, true)); |
| 7751 } | 7759 } |
| 7752 | 7760 |
| 7753 | 7761 |
| 7754 void Parser::CaptureAllInstantiators() { | 7762 void Parser::CaptureAllInstantiators() { |
| 7755 if (IsInstantiatorRequired()) { | 7763 if (IsInstantiatorRequired()) { |
| (...skipping 4133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11889 "from static function", | 11897 "from static function", |
| 11890 name.ToCString()); | 11898 name.ToCString()); |
| 11891 } | 11899 } |
| 11892 if (FunctionLevel() > 0) { | 11900 if (FunctionLevel() > 0) { |
| 11893 // Make sure that the class instantiator is captured. | 11901 // Make sure that the class instantiator is captured. |
| 11894 CaptureInstantiator(); | 11902 CaptureInstantiator(); |
| 11895 } | 11903 } |
| 11896 type_parameter ^= CanonicalizeType(type_parameter); | 11904 type_parameter ^= CanonicalizeType(type_parameter); |
| 11897 } else { | 11905 } else { |
| 11898 ASSERT(type_parameter.IsFunctionTypeParameter()); | 11906 ASSERT(type_parameter.IsFunctionTypeParameter()); |
| 11899 if (!FLAG_generic_method_semantics) { | 11907 if (!FLAG_reify_generic_functions) { |
| 11900 Type& type = Type::ZoneHandle(Z, Type::DynamicType()); | 11908 Type& type = Type::ZoneHandle(Z, Type::DynamicType()); |
| 11901 return new (Z) TypeNode(primary_pos, type); | 11909 return new (Z) TypeNode(primary_pos, type); |
| 11902 } | 11910 } |
| 11903 if (FunctionLevel() > 0) { | 11911 if (FunctionLevel() > 0) { |
| 11904 // Make sure that the parent function type arguments are captured. | 11912 // Make sure that the parent function type arguments are captured. |
| 11905 CaptureFunctionTypeArguments(); | 11913 CaptureFunctionTypeArguments(); |
| 11906 } | 11914 } |
| 11907 } | 11915 } |
| 11908 ASSERT(type_parameter.IsFinalized()); | 11916 ASSERT(type_parameter.IsFinalized()); |
| 11909 ASSERT(!type_parameter.IsMalformed()); | 11917 ASSERT(!type_parameter.IsMalformed()); |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12398 // A type parameter cannot be parameterized, so make the type | 12406 // A type parameter cannot be parameterized, so make the type |
| 12399 // malformed if type arguments have previously been parsed. | 12407 // malformed if type arguments have previously been parsed. |
| 12400 if (type->arguments() != TypeArguments::null()) { | 12408 if (type->arguments() != TypeArguments::null()) { |
| 12401 *type = ClassFinalizer::NewFinalizedMalformedType( | 12409 *type = ClassFinalizer::NewFinalizedMalformedType( |
| 12402 Error::Handle(Z), // No previous error. | 12410 Error::Handle(Z), // No previous error. |
| 12403 script_, type_parameter.token_pos(), | 12411 script_, type_parameter.token_pos(), |
| 12404 "type parameter '%s' cannot be parameterized", | 12412 "type parameter '%s' cannot be parameterized", |
| 12405 String::Handle(Z, type_parameter.name()).ToCString()); | 12413 String::Handle(Z, type_parameter.name()).ToCString()); |
| 12406 return; | 12414 return; |
| 12407 } | 12415 } |
| 12408 if (FLAG_generic_method_semantics) { | 12416 if (FLAG_reify_generic_functions) { |
| 12409 ASSERT(!type_parameter.IsMalformed()); | 12417 ASSERT(!type_parameter.IsMalformed()); |
| 12410 *type = type_parameter.raw(); | 12418 *type = type_parameter.raw(); |
| 12411 } else { | 12419 } else { |
| 12412 *type = Type::DynamicType(); | 12420 *type = Type::DynamicType(); |
| 12413 } | 12421 } |
| 12414 return; | 12422 return; |
| 12415 } | 12423 } |
| 12416 } | 12424 } |
| 12417 // Then check if the type is a class type parameter. | 12425 // Then check if the type is a class type parameter. |
| 12418 const TypeParameter& type_parameter = TypeParameter::Handle( | 12426 const TypeParameter& type_parameter = TypeParameter::Handle( |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13004 ResolveIdentInLocalScope(ident_pos, ident, &resolved, &resolved_func_level); | 13012 ResolveIdentInLocalScope(ident_pos, ident, &resolved, &resolved_func_level); |
| 13005 if (InGenericFunctionScope()) { | 13013 if (InGenericFunctionScope()) { |
| 13006 intptr_t type_param_func_level = FunctionLevel(); | 13014 intptr_t type_param_func_level = FunctionLevel(); |
| 13007 const TypeParameter& type_parameter = | 13015 const TypeParameter& type_parameter = |
| 13008 TypeParameter::ZoneHandle(Z, innermost_function().LookupTypeParameter( | 13016 TypeParameter::ZoneHandle(Z, innermost_function().LookupTypeParameter( |
| 13009 ident, &type_param_func_level)); | 13017 ident, &type_param_func_level)); |
| 13010 if (!type_parameter.IsNull()) { | 13018 if (!type_parameter.IsNull()) { |
| 13011 if ((resolved == NULL) || (resolved_func_level < type_param_func_level)) { | 13019 if ((resolved == NULL) || (resolved_func_level < type_param_func_level)) { |
| 13012 // The identifier is a function type parameter, possibly shadowing | 13020 // The identifier is a function type parameter, possibly shadowing |
| 13013 // 'resolved'. | 13021 // 'resolved'. |
| 13014 if (!FLAG_generic_method_semantics) { | 13022 if (!FLAG_reify_generic_functions) { |
| 13015 Type& type = Type::ZoneHandle(Z, Type::DynamicType()); | 13023 Type& type = Type::ZoneHandle(Z, Type::DynamicType()); |
| 13016 return new (Z) TypeNode(ident_pos, type); | 13024 return new (Z) TypeNode(ident_pos, type); |
| 13017 } | 13025 } |
| 13018 ASSERT(type_parameter.IsFinalized()); | 13026 ASSERT(type_parameter.IsFinalized()); |
| 13019 ASSERT(!type_parameter.IsMalformed()); | 13027 ASSERT(!type_parameter.IsMalformed()); |
| 13020 return new (Z) TypeNode(ident_pos, type_parameter); | 13028 return new (Z) TypeNode(ident_pos, type_parameter); |
| 13021 } | 13029 } |
| 13022 } | 13030 } |
| 13023 } | 13031 } |
| 13024 if (resolved == NULL) { | 13032 if (resolved == NULL) { |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13852 ParseFormalParameters(ctr, ¶ms); | 13860 ParseFormalParameters(ctr, ¶ms); |
| 13853 // Per language spec, the type of the closure parameters is dynamic. | 13861 // Per language spec, the type of the closure parameters is dynamic. |
| 13854 // Replace the types parsed from the constructor. | 13862 // Replace the types parsed from the constructor. |
| 13855 params.EraseParameterTypes(); | 13863 params.EraseParameterTypes(); |
| 13856 | 13864 |
| 13857 closure = Function::NewClosureFunction(closure_name, innermost_function(), | 13865 closure = Function::NewClosureFunction(closure_name, innermost_function(), |
| 13858 token_pos); | 13866 token_pos); |
| 13859 closure.set_is_generated_body(true); | 13867 closure.set_is_generated_body(true); |
| 13860 closure.set_is_debuggable(false); | 13868 closure.set_is_debuggable(false); |
| 13861 closure.set_is_visible(false); | 13869 closure.set_is_visible(false); |
| 13870 // TODO(regis): Verify that the closure cannot be generic. |
| 13862 closure.set_result_type(Object::dynamic_type()); | 13871 closure.set_result_type(Object::dynamic_type()); |
| 13863 AddFormalParamsToFunction(¶ms, closure); | 13872 AddFormalParamsToFunction(¶ms, closure); |
| 13864 ResolveSignature(closure); | 13873 ResolveSignature(closure); |
| 13865 | 13874 |
| 13866 // Finalize function type. | 13875 // Finalize function type. |
| 13867 Type& signature_type = Type::Handle(Z, closure.SignatureType()); | 13876 Type& signature_type = Type::Handle(Z, closure.SignatureType()); |
| 13868 signature_type ^= CanonicalizeType(signature_type); | 13877 signature_type ^= CanonicalizeType(signature_type); |
| 13869 closure.SetSignatureType(signature_type); | 13878 closure.SetSignatureType(signature_type); |
| 13870 // Finalization would be premature when top-level parsing. | 13879 // Finalization would be premature when top-level parsing. |
| 13871 ASSERT(!is_top_level_); | 13880 ASSERT(!is_top_level_); |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15162 const ArgumentListNode& function_args, | 15171 const ArgumentListNode& function_args, |
| 15163 const LocalVariable* temp_for_last_arg, | 15172 const LocalVariable* temp_for_last_arg, |
| 15164 bool is_super_invocation) { | 15173 bool is_super_invocation) { |
| 15165 UNREACHABLE(); | 15174 UNREACHABLE(); |
| 15166 return NULL; | 15175 return NULL; |
| 15167 } | 15176 } |
| 15168 | 15177 |
| 15169 } // namespace dart | 15178 } // namespace dart |
| 15170 | 15179 |
| 15171 #endif // DART_PRECOMPILED_RUNTIME | 15180 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |