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 11896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11907 } | 11907 } |
11908 type_parameter ^= ClassFinalizer::FinalizeType( | 11908 type_parameter ^= ClassFinalizer::FinalizeType( |
11909 current_class(), type_parameter, ClassFinalizer::kCanonicalize); | 11909 current_class(), type_parameter, ClassFinalizer::kCanonicalize); |
11910 ASSERT(!type_parameter.IsMalformed()); | 11910 ASSERT(!type_parameter.IsMalformed()); |
11911 return new(Z) TypeNode(primary_pos, type_parameter); | 11911 return new(Z) TypeNode(primary_pos, type_parameter); |
11912 } else { | 11912 } else { |
11913 ASSERT(type_parameter.IsFunctionTypeParameter()); | 11913 ASSERT(type_parameter.IsFunctionTypeParameter()); |
11914 // TODO(regis): Verify that CaptureFunctionInstantiator() was already | 11914 // TODO(regis): Verify that CaptureFunctionInstantiator() was already |
11915 // called if necessary. | 11915 // called if necessary. |
11916 // TODO(regis): Finalize type parameter and return as type node. | 11916 // TODO(regis): Finalize type parameter and return as type node. |
11917 // For now, throw a type error. | 11917 // For now, map to dynamic type. |
11918 Type& malformed_type = Type::ZoneHandle(Z); | 11918 Type& type = Type::ZoneHandle(Z, Type::DynamicType()); |
11919 malformed_type = ClassFinalizer::NewFinalizedMalformedType( | 11919 return new(Z) TypeNode(primary_pos, type); |
11920 Error::Handle(Z), // No previous error. | |
11921 script_, | |
11922 primary_pos, | |
11923 "function type parameter '%s' not yet supported", | |
11924 String::Handle(Z, type_parameter.name()).ToCString()); | |
11925 return ThrowTypeError(primary_pos, malformed_type); | |
11926 } | 11920 } |
11927 } | 11921 } |
11928 | 11922 |
11929 | 11923 |
11930 AstNode* Parser::ParseSelectors(AstNode* primary, bool is_cascade) { | 11924 AstNode* Parser::ParseSelectors(AstNode* primary, bool is_cascade) { |
11931 AstNode* left = primary; | 11925 AstNode* left = primary; |
11932 while (true) { | 11926 while (true) { |
11933 AstNode* selector = NULL; | 11927 AstNode* selector = NULL; |
11934 if ((CurrentToken() == Token::kPERIOD) || | 11928 if ((CurrentToken() == Token::kPERIOD) || |
11935 (CurrentToken() == Token::kQM_PERIOD)) { | 11929 (CurrentToken() == Token::kQM_PERIOD)) { |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12376 Class& resolved_type_class = Class::Handle(Z); | 12370 Class& resolved_type_class = Class::Handle(Z); |
12377 if (unresolved_class.library_prefix() == LibraryPrefix::null()) { | 12371 if (unresolved_class.library_prefix() == LibraryPrefix::null()) { |
12378 // First check if the type is a function type parameter. | 12372 // First check if the type is a function type parameter. |
12379 if (!innermost_function().IsNull()) { | 12373 if (!innermost_function().IsNull()) { |
12380 // TODO(regis): Shortcut this lookup if no generic functions in scope. | 12374 // TODO(regis): Shortcut this lookup if no generic functions in scope. |
12381 TypeParameter& type_parameter = TypeParameter::ZoneHandle(Z, | 12375 TypeParameter& type_parameter = TypeParameter::ZoneHandle(Z, |
12382 innermost_function().LookupTypeParameter(unresolved_class_name, | 12376 innermost_function().LookupTypeParameter(unresolved_class_name, |
12383 NULL)); | 12377 NULL)); |
12384 if (!type_parameter.IsNull()) { | 12378 if (!type_parameter.IsNull()) { |
12385 // TODO(regis): Check for absence of type arguments. | 12379 // TODO(regis): Check for absence of type arguments. |
12386 // For now, return as malformed type. | 12380 // For now, resolve the function type parameter to dynamic. |
12387 Type& malformed_type = Type::ZoneHandle(Z); | 12381 *type = Type::DynamicType(); |
12388 malformed_type = ClassFinalizer::NewFinalizedMalformedType( | |
12389 Error::Handle(Z), // No previous error. | |
12390 script_, | |
12391 type->token_pos(), | |
12392 "function type parameter '%s' not yet supported", | |
12393 String::Handle(Z, type_parameter.name()).ToCString()); | |
12394 *type = malformed_type.raw(); | |
12395 return; | 12382 return; |
12396 } | 12383 } |
12397 } | 12384 } |
12398 // Then check if the type is a class type parameter. | 12385 // Then check if the type is a class type parameter. |
12399 const TypeParameter& type_parameter = TypeParameter::Handle(Z, | 12386 const TypeParameter& type_parameter = TypeParameter::Handle(Z, |
12400 current_class().LookupTypeParameter(unresolved_class_name)); | 12387 current_class().LookupTypeParameter(unresolved_class_name)); |
12401 if (!type_parameter.IsNull()) { | 12388 if (!type_parameter.IsNull()) { |
12402 // A type parameter is considered to be a malformed type when | 12389 // A type parameter is considered to be a malformed type when |
12403 // referenced by a static member. | 12390 // referenced by a static member. |
12404 if (ParsingStaticMember()) { | 12391 if (ParsingStaticMember()) { |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12994 &type_param_func_level)); | 12981 &type_param_func_level)); |
12995 if (!type_parameter.IsNull()) { | 12982 if (!type_parameter.IsNull()) { |
12996 if ((resolved == NULL) || (resolved_func_level < type_param_func_level)) { | 12983 if ((resolved == NULL) || (resolved_func_level < type_param_func_level)) { |
12997 // The identifier is a function type parameter, possibly shadowing | 12984 // The identifier is a function type parameter, possibly shadowing |
12998 // 'resolved'. | 12985 // 'resolved'. |
12999 if (type_param_func_level < FunctionLevel()) { | 12986 if (type_param_func_level < FunctionLevel()) { |
13000 // Make sure that the function instantiator is captured. | 12987 // Make sure that the function instantiator is captured. |
13001 CaptureFunctionInstantiator(); | 12988 CaptureFunctionInstantiator(); |
13002 } | 12989 } |
13003 // TODO(regis): Finalize type parameter and return as type node. | 12990 // TODO(regis): Finalize type parameter and return as type node. |
13004 // For now, return as malformed type. | 12991 // For now, map to dynamic type. |
13005 Type& malformed_type = Type::ZoneHandle(Z); | 12992 Type& type = Type::ZoneHandle(Z, Type::DynamicType()); |
13006 malformed_type = ClassFinalizer::NewFinalizedMalformedType( | 12993 return new(Z) TypeNode(ident_pos, type); |
13007 Error::Handle(Z), // No previous error. | |
13008 script_, | |
13009 ident_pos, | |
13010 "function type parameter '%s' not yet supported", | |
13011 ident.ToCString()); | |
13012 return new(Z) TypeNode(ident_pos, malformed_type); | |
13013 } | 12994 } |
13014 } | 12995 } |
13015 } | 12996 } |
13016 if (resolved == NULL) { | 12997 if (resolved == NULL) { |
13017 // Check whether the identifier is a class type parameter. | 12998 // Check whether the identifier is a class type parameter. |
13018 if (!current_class().IsNull()) { | 12999 if (!current_class().IsNull()) { |
13019 TypeParameter& type_parameter = TypeParameter::ZoneHandle(Z, | 13000 TypeParameter& type_parameter = TypeParameter::ZoneHandle(Z, |
13020 current_class().LookupTypeParameter(ident)); | 13001 current_class().LookupTypeParameter(ident)); |
13021 if (!type_parameter.IsNull()) { | 13002 if (!type_parameter.IsNull()) { |
13022 if (FunctionLevel() > 0) { | 13003 if (FunctionLevel() > 0) { |
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15113 const ArgumentListNode& function_args, | 15094 const ArgumentListNode& function_args, |
15114 const LocalVariable* temp_for_last_arg, | 15095 const LocalVariable* temp_for_last_arg, |
15115 bool is_super_invocation) { | 15096 bool is_super_invocation) { |
15116 UNREACHABLE(); | 15097 UNREACHABLE(); |
15117 return NULL; | 15098 return NULL; |
15118 } | 15099 } |
15119 | 15100 |
15120 } // namespace dart | 15101 } // namespace dart |
15121 | 15102 |
15122 #endif // DART_PRECOMPILED_RUNTIME | 15103 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |