| 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 | 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 11 matching lines...) Expand all Loading... |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); | 24 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); |
| 25 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); | 25 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); |
| 26 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 26 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| 27 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); | 27 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); |
| 28 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); | 28 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); |
| 29 | 29 |
| 30 // All references to Dart names are listed here. | 30 // All references to Dart names are listed here. |
| 31 static const char* kAssertionErrorName = "AssertionError"; | 31 static const char* kAssertionErrorName = "AssertionError"; |
| 32 static const char* kTypeErrorName = "TypeError"; |
| 32 static const char* kFallThroughErrorName = "FallThroughError"; | 33 static const char* kFallThroughErrorName = "FallThroughError"; |
| 33 static const char* kStaticResolutionExceptionName = "StaticResolutionException"; | 34 static const char* kStaticResolutionExceptionName = "StaticResolutionException"; |
| 34 static const char* kThrowNewName = "_throwNew"; | 35 static const char* kThrowNewName = "_throwNew"; |
| 35 static const char* kListLiteralFactoryClassName = "_ListLiteralFactory"; | 36 static const char* kListLiteralFactoryClassName = "_ListLiteralFactory"; |
| 36 static const char* kListLiteralFactoryName = "List.fromLiteral"; | 37 static const char* kListLiteralFactoryName = "List.fromLiteral"; |
| 37 static const char* kMapLiteralFactoryClassName = "_MapLiteralFactory"; | 38 static const char* kMapLiteralFactoryClassName = "_MapLiteralFactory"; |
| 38 static const char* kMapLiteralFactoryName = "Map.fromLiteral"; | 39 static const char* kMapLiteralFactoryName = "Map.fromLiteral"; |
| 39 static const char* kImmutableMapName = "ImmutableMap"; | 40 static const char* kImmutableMapName = "ImmutableMap"; |
| 40 static const char* kImmutableMapConstructorName = "ImmutableMap._create"; | 41 static const char* kImmutableMapConstructorName = "ImmutableMap._create"; |
| 41 static const char* kStringClassName = "StringBase"; | 42 static const char* kStringClassName = "StringBase"; |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 // We have an identifier followed by a 'follower' token. | 812 // We have an identifier followed by a 'follower' token. |
| 812 // We either parse a type or assume that no type is specified. | 813 // We either parse a type or assume that no type is specified. |
| 813 if ((follower == Token::kLT) || // Parameterized type. | 814 if ((follower == Token::kLT) || // Parameterized type. |
| 814 (follower == Token::kPERIOD) || // Qualified class name of type. | 815 (follower == Token::kPERIOD) || // Qualified class name of type. |
| 815 Token::IsIdentifier(follower) || // Parameter name following a type. | 816 Token::IsIdentifier(follower) || // Parameter name following a type. |
| 816 (follower == Token::kTHIS)) { // Field parameter following a type. | 817 (follower == Token::kTHIS)) { // Field parameter following a type. |
| 817 // The types of formal parameters are never ignored, even in unchecked | 818 // The types of formal parameters are never ignored, even in unchecked |
| 818 // mode, because they are part of the function type of closurized | 819 // mode, because they are part of the function type of closurized |
| 819 // functions appearing in type tests with typedefs. | 820 // functions appearing in type tests with typedefs. |
| 820 parameter.type = &AbstractType::ZoneHandle( | 821 parameter.type = &AbstractType::ZoneHandle( |
| 821 ParseType(is_top_level_ ? kCanResolve : kMustResolve)); | 822 ParseType(is_top_level_ ? ClassFinalizer::kTryResolve : |
| 823 ClassFinalizer::kFinalize)); |
| 822 } else { | 824 } else { |
| 823 parameter.type = &Type::ZoneHandle(Type::DynamicType()); | 825 parameter.type = &Type::ZoneHandle(Type::DynamicType()); |
| 824 } | 826 } |
| 825 } | 827 } |
| 826 if (!this_seen && (CurrentToken() == Token::kTHIS)) { | 828 if (!this_seen && (CurrentToken() == Token::kTHIS)) { |
| 827 ConsumeToken(); | 829 ConsumeToken(); |
| 828 ExpectToken(Token::kPERIOD); | 830 ExpectToken(Token::kPERIOD); |
| 829 this_seen = true; | 831 this_seen = true; |
| 830 parameter.is_field_initializer = true; | 832 parameter.is_field_initializer = true; |
| 831 } | 833 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 signature_function, | 875 signature_function, |
| 874 script_); | 876 script_); |
| 875 // Record the function signature class in the current library. | 877 // Record the function signature class in the current library. |
| 876 library_.AddClass(signature_class); | 878 library_.AddClass(signature_class); |
| 877 } else { | 879 } else { |
| 878 signature_function.set_signature_class(signature_class); | 880 signature_function.set_signature_class(signature_class); |
| 879 } | 881 } |
| 880 ASSERT(signature_function.signature_class() == signature_class.raw()); | 882 ASSERT(signature_function.signature_class() == signature_class.raw()); |
| 881 Type& signature_type = Type::ZoneHandle(signature_class.SignatureType()); | 883 Type& signature_type = Type::ZoneHandle(signature_class.SignatureType()); |
| 882 if (!is_top_level_ && !signature_type.IsFinalized()) { | 884 if (!is_top_level_ && !signature_type.IsFinalized()) { |
| 883 signature_type ^= | 885 signature_type ^= ClassFinalizer::FinalizeType( |
| 884 ClassFinalizer::FinalizeType(signature_class, signature_type); | 886 signature_class, signature_type, ClassFinalizer::kFinalize); |
| 885 } | 887 } |
| 886 // The type of the parameter is now the signature type. | 888 // The type of the parameter is now the signature type. |
| 887 parameter.type = &signature_type; | 889 parameter.type = &signature_type; |
| 888 } | 890 } |
| 889 } | 891 } |
| 890 | 892 |
| 891 if (CurrentToken() == Token::kASSIGN) { | 893 if (CurrentToken() == Token::kASSIGN) { |
| 892 if (!params->has_named_optional_parameters || | 894 if (!params->has_named_optional_parameters || |
| 893 !allow_explicit_default_value) { | 895 !allow_explicit_default_value) { |
| 894 ErrorMsg("parameter must not specify a default value"); | 896 ErrorMsg("parameter must not specify a default value"); |
| (...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2338 (follower == Token::kGET) || // Getter following a type. | 2340 (follower == Token::kGET) || // Getter following a type. |
| 2339 (follower == Token::kSET) || // Setter following a type. | 2341 (follower == Token::kSET) || // Setter following a type. |
| 2340 (follower == Token::kOPERATOR) || // Operator following a type. | 2342 (follower == Token::kOPERATOR) || // Operator following a type. |
| 2341 (Token::IsIdentifier(follower)) || // Member name following a type. | 2343 (Token::IsIdentifier(follower)) || // Member name following a type. |
| 2342 ((follower == Token::kPERIOD) && // Qualified class name of type, | 2344 ((follower == Token::kPERIOD) && // Qualified class name of type, |
| 2343 (LookaheadToken(3) != Token::kLPAREN))) { // but not a named constr. | 2345 (LookaheadToken(3) != Token::kLPAREN))) { // but not a named constr. |
| 2344 ASSERT(is_top_level_); | 2346 ASSERT(is_top_level_); |
| 2345 // The declared type of fields is never ignored, even in unchecked mode, | 2347 // The declared type of fields is never ignored, even in unchecked mode, |
| 2346 // because getters and setters could be closurized at some time (not | 2348 // because getters and setters could be closurized at some time (not |
| 2347 // supported yet). | 2349 // supported yet). |
| 2348 member.type = &AbstractType::ZoneHandle(ParseType(kCanResolve)); | 2350 member.type = &AbstractType::ZoneHandle( |
| 2351 ParseType(ClassFinalizer::kTryResolve)); |
| 2349 } | 2352 } |
| 2350 } | 2353 } |
| 2351 } | 2354 } |
| 2352 Token::Kind operator_token = Token::kILLEGAL; | 2355 Token::Kind operator_token = Token::kILLEGAL; |
| 2353 // Optionally parse a (possibly named) constructor name or factory. | 2356 // Optionally parse a (possibly named) constructor name or factory. |
| 2354 if (IsIdentifier() && | 2357 if (IsIdentifier() && |
| 2355 (CurrentLiteral()->Equals(members->class_name()) || member.has_factory)) { | 2358 (CurrentLiteral()->Equals(members->class_name()) || member.has_factory)) { |
| 2356 if (member.has_factory) { | 2359 if (member.has_factory) { |
| 2357 // The factory name may be qualified. | 2360 // The factory name may be qualified. |
| 2358 QualIdent factory_name; | 2361 QualIdent factory_name; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 } | 2526 } |
| 2524 } | 2527 } |
| 2525 ASSERT(!cls.IsNull()); | 2528 ASSERT(!cls.IsNull()); |
| 2526 ASSERT(cls.functions() == Array::Empty()); | 2529 ASSERT(cls.functions() == Array::Empty()); |
| 2527 set_current_class(cls); | 2530 set_current_class(cls); |
| 2528 ParseTypeParameters(cls); | 2531 ParseTypeParameters(cls); |
| 2529 Type& super_type = Type::Handle(); | 2532 Type& super_type = Type::Handle(); |
| 2530 if (CurrentToken() == Token::kEXTENDS) { | 2533 if (CurrentToken() == Token::kEXTENDS) { |
| 2531 ConsumeToken(); | 2534 ConsumeToken(); |
| 2532 const intptr_t type_pos = token_index_; | 2535 const intptr_t type_pos = token_index_; |
| 2533 const AbstractType& type = AbstractType::Handle(ParseType(kCanResolve)); | 2536 const AbstractType& type = AbstractType::Handle( |
| 2537 ParseType(ClassFinalizer::kTryResolve)); |
| 2534 if (type.IsTypeParameter()) { | 2538 if (type.IsTypeParameter()) { |
| 2535 ErrorMsg(type_pos, | 2539 ErrorMsg(type_pos, |
| 2536 "class '%s' may not extend type parameter '%s'", | 2540 "class '%s' may not extend type parameter '%s'", |
| 2537 class_name.ToCString(), | 2541 class_name.ToCString(), |
| 2538 String::Handle(type.Name()).ToCString()); | 2542 String::Handle(type.Name()).ToCString()); |
| 2539 } | 2543 } |
| 2540 super_type ^= type.raw(); | 2544 super_type ^= type.raw(); |
| 2541 if (super_type.IsInterfaceType()) { | 2545 if (super_type.IsInterfaceType()) { |
| 2542 ErrorMsg(type_pos, | 2546 ErrorMsg(type_pos, |
| 2543 "class '%s' may implement, but cannot extend interface '%s'", | 2547 "class '%s' may implement, but cannot extend interface '%s'", |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 set_current_class(alias_owner); | 2676 set_current_class(alias_owner); |
| 2673 | 2677 |
| 2674 // Parse the result type of the function type. | 2678 // Parse the result type of the function type. |
| 2675 AbstractType& result_type = Type::Handle(Type::DynamicType()); | 2679 AbstractType& result_type = Type::Handle(Type::DynamicType()); |
| 2676 if (CurrentToken() == Token::kVOID) { | 2680 if (CurrentToken() == Token::kVOID) { |
| 2677 ConsumeToken(); | 2681 ConsumeToken(); |
| 2678 result_type = Type::VoidType(); | 2682 result_type = Type::VoidType(); |
| 2679 } else if (!IsFunctionTypeAliasName()) { | 2683 } else if (!IsFunctionTypeAliasName()) { |
| 2680 // Type annotations in typedef are never ignored, even in unchecked mode. | 2684 // Type annotations in typedef are never ignored, even in unchecked mode. |
| 2681 // Wait until we have an owner class before resolving the result type. | 2685 // Wait until we have an owner class before resolving the result type. |
| 2682 result_type = ParseType(kDoNotResolve); | 2686 result_type = ParseType(ClassFinalizer::kDoNotResolve); |
| 2683 } | 2687 } |
| 2684 | 2688 |
| 2685 const intptr_t alias_name_pos = token_index_; | 2689 const intptr_t alias_name_pos = token_index_; |
| 2686 const String* alias_name = | 2690 const String* alias_name = |
| 2687 ExpectTypeIdentifier("function alias name expected"); | 2691 ExpectTypeIdentifier("function alias name expected"); |
| 2688 | 2692 |
| 2689 // Parse the type parameters of the function type. | 2693 // Parse the type parameters of the function type. |
| 2690 ParseTypeParameters(alias_owner); | 2694 ParseTypeParameters(alias_owner); |
| 2691 // At this point, the type parameters have been parsed, so we can resolve the | 2695 // At this point, the type parameters have been parsed, so we can resolve the |
| 2692 // result type. | 2696 // result type. |
| 2693 if (!result_type.IsNull()) { | 2697 if (!result_type.IsNull()) { |
| 2694 ResolveTypeFromClass(alias_owner, kCanResolve, &result_type); | 2698 ResolveTypeFromClass(alias_owner, |
| 2699 ClassFinalizer::kTryResolve, |
| 2700 &result_type); |
| 2695 } | 2701 } |
| 2696 // Parse the formal parameters of the function type. | 2702 // Parse the formal parameters of the function type. |
| 2697 if (CurrentToken() != Token::kLPAREN) { | 2703 if (CurrentToken() != Token::kLPAREN) { |
| 2698 ErrorMsg("formal parameter list expected"); | 2704 ErrorMsg("formal parameter list expected"); |
| 2699 } | 2705 } |
| 2700 ParamList func_params; | 2706 ParamList func_params; |
| 2701 const bool no_explicit_default_values = false; | 2707 const bool no_explicit_default_values = false; |
| 2702 ParseFormalParameterList(no_explicit_default_values, &func_params); | 2708 ParseFormalParameterList(no_explicit_default_values, &func_params); |
| 2703 // The field 'is_static' has no meaning for signature functions. | 2709 // The field 'is_static' has no meaning for signature functions. |
| 2704 Function& signature_function = Function::Handle( | 2710 Function& signature_function = Function::Handle( |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2913 if (CurrentToken() != Token::kIDENT) { | 2919 if (CurrentToken() != Token::kIDENT) { |
| 2914 ErrorMsg("type parameter name expected"); | 2920 ErrorMsg("type parameter name expected"); |
| 2915 } | 2921 } |
| 2916 String& type_parameter_name = *CurrentLiteral(); | 2922 String& type_parameter_name = *CurrentLiteral(); |
| 2917 AbstractType& type_parameter = TypeParameter::ZoneHandle( | 2923 AbstractType& type_parameter = TypeParameter::ZoneHandle( |
| 2918 TypeParameter::New(index, type_parameter_name, token_index_)); | 2924 TypeParameter::New(index, type_parameter_name, token_index_)); |
| 2919 ConsumeToken(); | 2925 ConsumeToken(); |
| 2920 AbstractType& bound = Type::ZoneHandle(Type::DynamicType()); | 2926 AbstractType& bound = Type::ZoneHandle(Type::DynamicType()); |
| 2921 if (CurrentToken() == Token::kEXTENDS) { | 2927 if (CurrentToken() == Token::kEXTENDS) { |
| 2922 ConsumeToken(); | 2928 ConsumeToken(); |
| 2923 bound = ParseType(kCanResolve); | 2929 bound = ParseType(ClassFinalizer::kTryResolve); |
| 2924 } | 2930 } |
| 2925 type_parameters_array.Add(&type_parameter); | 2931 type_parameters_array.Add(&type_parameter); |
| 2926 bounds_array.Add(&bound); | 2932 bounds_array.Add(&bound); |
| 2927 index++; | 2933 index++; |
| 2928 } while (CurrentToken() == Token::kCOMMA); | 2934 } while (CurrentToken() == Token::kCOMMA); |
| 2929 Token::Kind token = CurrentToken(); | 2935 Token::Kind token = CurrentToken(); |
| 2930 if ((token == Token::kGT) || (token == Token::kSHR)) { | 2936 if ((token == Token::kGT) || (token == Token::kSHR)) { |
| 2931 ConsumeRightAngleBracket(); | 2937 ConsumeRightAngleBracket(); |
| 2932 } else { | 2938 } else { |
| 2933 ErrorMsg("right angle bracket expected"); | 2939 ErrorMsg("right angle bracket expected"); |
| 2934 } | 2940 } |
| 2935 const TypeArguments& type_parameters = | 2941 const TypeArguments& type_parameters = |
| 2936 TypeArguments::Handle(NewTypeArguments(type_parameters_array)); | 2942 TypeArguments::Handle(NewTypeArguments(type_parameters_array)); |
| 2937 const TypeArguments& bounds = | 2943 const TypeArguments& bounds = |
| 2938 TypeArguments::Handle(NewTypeArguments(bounds_array)); | 2944 TypeArguments::Handle(NewTypeArguments(bounds_array)); |
| 2939 cls.set_type_parameters(type_parameters); | 2945 cls.set_type_parameters(type_parameters); |
| 2940 cls.set_type_parameter_bounds(bounds); | 2946 cls.set_type_parameter_bounds(bounds); |
| 2941 // Try to resolve the upper bounds, which will at least resolve the | 2947 // Try to resolve the upper bounds, which will at least resolve the |
| 2942 // referenced type parameters. | 2948 // referenced type parameters. |
| 2943 AbstractType& bound = AbstractType::Handle(); | 2949 AbstractType& bound = AbstractType::Handle(); |
| 2944 const intptr_t num_types = bounds.Length(); | 2950 const intptr_t num_types = bounds.Length(); |
| 2945 for (intptr_t i = 0; i < num_types; i++) { | 2951 for (intptr_t i = 0; i < num_types; i++) { |
| 2946 bound = bounds.TypeAt(i); | 2952 bound = bounds.TypeAt(i); |
| 2947 ResolveTypeFromClass(cls, kCanResolve, &bound); | 2953 ResolveTypeFromClass(cls, ClassFinalizer::kTryResolve, &bound); |
| 2948 bounds.SetTypeAt(i, bound); | 2954 bounds.SetTypeAt(i, bound); |
| 2949 } | 2955 } |
| 2950 } | 2956 } |
| 2951 } | 2957 } |
| 2952 | 2958 |
| 2953 | 2959 |
| 2954 RawAbstractTypeArguments* Parser::ParseTypeArguments( | 2960 RawAbstractTypeArguments* Parser::ParseTypeArguments( |
| 2955 TypeResolution type_resolution) { | 2961 Error* malformed_error, |
| 2962 ClassFinalizer::FinalizationKind finalization) { |
| 2956 TRACE_PARSER("ParseTypeArguments"); | 2963 TRACE_PARSER("ParseTypeArguments"); |
| 2957 if (CurrentToken() == Token::kLT) { | 2964 if (CurrentToken() == Token::kLT) { |
| 2958 GrowableArray<AbstractType*> types; | 2965 GrowableArray<AbstractType*> types; |
| 2959 do { | 2966 do { |
| 2960 ConsumeToken(); | 2967 ConsumeToken(); |
| 2961 AbstractType& type = AbstractType::ZoneHandle(ParseType(type_resolution)); | 2968 AbstractType& type = AbstractType::ZoneHandle(ParseType(finalization)); |
| 2962 types.Add(&type); | 2969 types.Add(&type); |
| 2970 // Only keep the error for the first malformed type argument. |
| 2971 if (malformed_error->IsNull() && type.IsMalformed()) { |
| 2972 *malformed_error = type.malformed_error(); |
| 2973 } |
| 2963 } while (CurrentToken() == Token::kCOMMA); | 2974 } while (CurrentToken() == Token::kCOMMA); |
| 2964 Token::Kind token = CurrentToken(); | 2975 Token::Kind token = CurrentToken(); |
| 2965 if ((token == Token::kGT) || (token == Token::kSHR)) { | 2976 if ((token == Token::kGT) || (token == Token::kSHR)) { |
| 2966 ConsumeRightAngleBracket(); | 2977 ConsumeRightAngleBracket(); |
| 2967 } else { | 2978 } else { |
| 2968 ErrorMsg("right angle bracket expected"); | 2979 ErrorMsg("right angle bracket expected"); |
| 2969 } | 2980 } |
| 2970 if (type_resolution != kIgnore) { | 2981 if (finalization != ClassFinalizer::kIgnore) { |
| 2971 return NewTypeArguments(types); | 2982 return NewTypeArguments(types); |
| 2972 } | 2983 } |
| 2973 } | 2984 } |
| 2974 return TypeArguments::null(); | 2985 return TypeArguments::null(); |
| 2975 } | 2986 } |
| 2976 | 2987 |
| 2977 | 2988 |
| 2978 // Parse and return an array of interface types. | 2989 // Parse and return an array of interface types. |
| 2979 RawArray* Parser::ParseInterfaceList() { | 2990 RawArray* Parser::ParseInterfaceList() { |
| 2980 TRACE_PARSER("ParseInterfaceList"); | 2991 TRACE_PARSER("ParseInterfaceList"); |
| 2981 ASSERT((CurrentToken() == Token::kIMPLEMENTS) || | 2992 ASSERT((CurrentToken() == Token::kIMPLEMENTS) || |
| 2982 (CurrentToken() == Token::kEXTENDS)); | 2993 (CurrentToken() == Token::kEXTENDS)); |
| 2983 GrowableArray<AbstractType*> interfaces; | 2994 GrowableArray<AbstractType*> interfaces; |
| 2984 String& interface_name = String::Handle(); | 2995 String& interface_name = String::Handle(); |
| 2985 do { | 2996 do { |
| 2986 ConsumeToken(); | 2997 ConsumeToken(); |
| 2987 intptr_t supertype_pos = token_index_; | 2998 intptr_t supertype_pos = token_index_; |
| 2988 AbstractType& interface = AbstractType::ZoneHandle(ParseType(kCanResolve)); | 2999 AbstractType& interface = AbstractType::ZoneHandle( |
| 3000 ParseType(ClassFinalizer::kTryResolve)); |
| 2989 interface_name = interface.Name(); | 3001 interface_name = interface.Name(); |
| 2990 for (int i = 0; i < interfaces.length(); i++) { | 3002 for (int i = 0; i < interfaces.length(); i++) { |
| 2991 String& other_name = String::Handle(interfaces[i]->Name()); | 3003 String& other_name = String::Handle(interfaces[i]->Name()); |
| 2992 if (interface_name.Equals(other_name)) { | 3004 if (interface_name.Equals(other_name)) { |
| 2993 ErrorMsg(supertype_pos, "Duplicate supertype '%s'", | 3005 ErrorMsg(supertype_pos, "Duplicate supertype '%s'", |
| 2994 interface_name.ToCString()); | 3006 interface_name.ToCString()); |
| 2995 } | 3007 } |
| 2996 } | 3008 } |
| 2997 interfaces.Add(&interface); | 3009 interfaces.Add(&interface); |
| 2998 } while (CurrentToken() == Token::kCOMMA); | 3010 } while (CurrentToken() == Token::kCOMMA); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3042 cls_interfaces = NewArray<AbstractType>(all_interfaces); | 3054 cls_interfaces = NewArray<AbstractType>(all_interfaces); |
| 3043 cls.set_interfaces(cls_interfaces); | 3055 cls.set_interfaces(cls_interfaces); |
| 3044 } | 3056 } |
| 3045 | 3057 |
| 3046 | 3058 |
| 3047 void Parser::ParseTopLevelVariable(TopLevel* top_level) { | 3059 void Parser::ParseTopLevelVariable(TopLevel* top_level) { |
| 3048 TRACE_PARSER("ParseTopLevelVariable"); | 3060 TRACE_PARSER("ParseTopLevelVariable"); |
| 3049 const bool is_final = (CurrentToken() == Token::kFINAL); | 3061 const bool is_final = (CurrentToken() == Token::kFINAL); |
| 3050 const bool is_static = true; | 3062 const bool is_static = true; |
| 3051 const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( | 3063 const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( |
| 3052 FLAG_enable_type_checks ? kCanResolve : kIgnore)); | 3064 FLAG_enable_type_checks ? ClassFinalizer::kTryResolve : |
| 3053 | 3065 ClassFinalizer::kIgnore)); |
| 3054 while (true) { | 3066 while (true) { |
| 3055 const intptr_t name_pos = token_index_; | 3067 const intptr_t name_pos = token_index_; |
| 3056 String& var_name = *ExpectIdentifier("variable name expected"); | 3068 String& var_name = *ExpectIdentifier("variable name expected"); |
| 3057 | 3069 |
| 3058 if (library_.LookupObject(var_name) != Object::null()) { | 3070 if (library_.LookupObject(var_name) != Object::null()) { |
| 3059 ErrorMsg(name_pos, "'%s' is already defined", var_name.ToCString()); | 3071 ErrorMsg(name_pos, "'%s' is already defined", var_name.ToCString()); |
| 3060 } | 3072 } |
| 3061 String& accessor_name = String::Handle(Field::GetterName(var_name)); | 3073 String& accessor_name = String::Handle(Field::GetterName(var_name)); |
| 3062 if (library_.LookupObject(accessor_name) != Object::null()) { | 3074 if (library_.LookupObject(accessor_name) != Object::null()) { |
| 3063 ErrorMsg(name_pos, "getter for '%s' is already defined", | 3075 ErrorMsg(name_pos, "getter for '%s' is already defined", |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3106 TRACE_PARSER("ParseTopLevelFunction"); | 3118 TRACE_PARSER("ParseTopLevelFunction"); |
| 3107 AbstractType& result_type = Type::Handle(Type::DynamicType()); | 3119 AbstractType& result_type = Type::Handle(Type::DynamicType()); |
| 3108 const bool is_static = true; | 3120 const bool is_static = true; |
| 3109 if (CurrentToken() == Token::kVOID) { | 3121 if (CurrentToken() == Token::kVOID) { |
| 3110 ConsumeToken(); | 3122 ConsumeToken(); |
| 3111 result_type = Type::VoidType(); | 3123 result_type = Type::VoidType(); |
| 3112 } else { | 3124 } else { |
| 3113 // Parse optional type. | 3125 // Parse optional type. |
| 3114 if ((CurrentToken() == Token::kIDENT) && | 3126 if ((CurrentToken() == Token::kIDENT) && |
| 3115 (LookaheadToken(1) != Token::kLPAREN)) { | 3127 (LookaheadToken(1) != Token::kLPAREN)) { |
| 3116 result_type = ParseType(kCanResolve); | 3128 result_type = ParseType(ClassFinalizer::kTryResolve); |
| 3117 } | 3129 } |
| 3118 } | 3130 } |
| 3119 const intptr_t name_pos = token_index_; | 3131 const intptr_t name_pos = token_index_; |
| 3120 const String& func_name = *ExpectIdentifier("function name expected"); | 3132 const String& func_name = *ExpectIdentifier("function name expected"); |
| 3121 | 3133 |
| 3122 if (library_.LookupObject(func_name) != Object::null()) { | 3134 if (library_.LookupObject(func_name) != Object::null()) { |
| 3123 ErrorMsg(name_pos, "'%s' is already defined", func_name.ToCString()); | 3135 ErrorMsg(name_pos, "'%s' is already defined", func_name.ToCString()); |
| 3124 } | 3136 } |
| 3125 String& accessor_name = String::Handle(Field::GetterName(func_name)); | 3137 String& accessor_name = String::Handle(Field::GetterName(func_name)); |
| 3126 if (library_.LookupObject(accessor_name) != Object::null()) { | 3138 if (library_.LookupObject(accessor_name) != Object::null()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3173 bool is_getter = (CurrentToken() == Token::kGET); | 3185 bool is_getter = (CurrentToken() == Token::kGET); |
| 3174 if (CurrentToken() == Token::kGET || | 3186 if (CurrentToken() == Token::kGET || |
| 3175 CurrentToken() == Token::kSET) { | 3187 CurrentToken() == Token::kSET) { |
| 3176 ConsumeToken(); | 3188 ConsumeToken(); |
| 3177 result_type = Type::DynamicType(); | 3189 result_type = Type::DynamicType(); |
| 3178 } else { | 3190 } else { |
| 3179 if (CurrentToken() == Token::kVOID) { | 3191 if (CurrentToken() == Token::kVOID) { |
| 3180 ConsumeToken(); | 3192 ConsumeToken(); |
| 3181 result_type = Type::VoidType(); | 3193 result_type = Type::VoidType(); |
| 3182 } else { | 3194 } else { |
| 3183 result_type = ParseType(kCanResolve); | 3195 result_type = ParseType(ClassFinalizer::kTryResolve); |
| 3184 } | 3196 } |
| 3185 is_getter = (CurrentToken() == Token::kGET); | 3197 is_getter = (CurrentToken() == Token::kGET); |
| 3186 if (CurrentToken() == Token::kGET || CurrentToken() == Token::kSET) { | 3198 if (CurrentToken() == Token::kGET || CurrentToken() == Token::kSET) { |
| 3187 ConsumeToken(); | 3199 ConsumeToken(); |
| 3188 } else { | 3200 } else { |
| 3189 UnexpectedToken(); | 3201 UnexpectedToken(); |
| 3190 } | 3202 } |
| 3191 } | 3203 } |
| 3192 const intptr_t name_pos = token_index_; | 3204 const intptr_t name_pos = token_index_; |
| 3193 const String* field_name = ExpectIdentifier("accessor name expected"); | 3205 const String* field_name = ExpectIdentifier("accessor name expected"); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3700 } | 3712 } |
| 3701 if (is_final) { | 3713 if (is_final) { |
| 3702 variable->set_is_final(); | 3714 variable->set_is_final(); |
| 3703 } | 3715 } |
| 3704 return initialization; | 3716 return initialization; |
| 3705 } | 3717 } |
| 3706 | 3718 |
| 3707 | 3719 |
| 3708 // Parses ('var' | 'final' [type] | type). | 3720 // Parses ('var' | 'final' [type] | type). |
| 3709 // The presence of 'final' must be detected and remembered before the call. | 3721 // The presence of 'final' must be detected and remembered before the call. |
| 3710 // If a type is parsed, it is resolved (or not) according to type_resolution. | 3722 // If a type is parsed, it may be resolved and finalized according to the given |
| 3711 RawAbstractType* Parser::ParseFinalVarOrType(TypeResolution type_resolution) { | 3723 // type finalization mode. |
| 3724 RawAbstractType* Parser::ParseFinalVarOrType( |
| 3725 ClassFinalizer::FinalizationKind finalization) { |
| 3712 TRACE_PARSER("ParseFinalVarOrType"); | 3726 TRACE_PARSER("ParseFinalVarOrType"); |
| 3713 if (CurrentToken() == Token::kVAR) { | 3727 if (CurrentToken() == Token::kVAR) { |
| 3714 ConsumeToken(); | 3728 ConsumeToken(); |
| 3715 return Type::DynamicType(); | 3729 return Type::DynamicType(); |
| 3716 } | 3730 } |
| 3717 bool type_is_optional = false; | 3731 bool type_is_optional = false; |
| 3718 if (CurrentToken() == Token::kFINAL) { | 3732 if (CurrentToken() == Token::kFINAL) { |
| 3719 ConsumeToken(); | 3733 ConsumeToken(); |
| 3720 type_is_optional = true; | 3734 type_is_optional = true; |
| 3721 } | 3735 } |
| 3722 if (CurrentToken() != Token::kIDENT) { | 3736 if (CurrentToken() != Token::kIDENT) { |
| 3723 if (type_is_optional) { | 3737 if (type_is_optional) { |
| 3724 return Type::DynamicType(); | 3738 return Type::DynamicType(); |
| 3725 } else { | 3739 } else { |
| 3726 ErrorMsg("type name expected"); | 3740 ErrorMsg("type name expected"); |
| 3727 } | 3741 } |
| 3728 } | 3742 } |
| 3729 if (type_is_optional) { | 3743 if (type_is_optional) { |
| 3730 Token::Kind follower = LookaheadToken(1); | 3744 Token::Kind follower = LookaheadToken(1); |
| 3731 // We have an identifier followed by a 'follower' token. | 3745 // We have an identifier followed by a 'follower' token. |
| 3732 // We either parse a type or return now. | 3746 // We either parse a type or return now. |
| 3733 if ((follower != Token::kLT) && // Parameterized type. | 3747 if ((follower != Token::kLT) && // Parameterized type. |
| 3734 (follower != Token::kPERIOD) && // Qualified class name of type. | 3748 (follower != Token::kPERIOD) && // Qualified class name of type. |
| 3735 !Token::IsIdentifier(follower) && // Variable name following a type. | 3749 !Token::IsIdentifier(follower) && // Variable name following a type. |
| 3736 (follower != Token::kTHIS)) { // Field parameter following a type. | 3750 (follower != Token::kTHIS)) { // Field parameter following a type. |
| 3737 return Type::DynamicType(); | 3751 return Type::DynamicType(); |
| 3738 } | 3752 } |
| 3739 } | 3753 } |
| 3740 return ParseType(type_resolution); | 3754 return ParseType(finalization); |
| 3741 } | 3755 } |
| 3742 | 3756 |
| 3743 | 3757 |
| 3744 // Returns ast nodes of the variable initialization. Variables without an | 3758 // Returns ast nodes of the variable initialization. Variables without an |
| 3745 // explicit initializer are initialized to null. If several variables are | 3759 // explicit initializer are initialized to null. If several variables are |
| 3746 // declared, the individual initializers are collected in a sequence node. | 3760 // declared, the individual initializers are collected in a sequence node. |
| 3747 AstNode* Parser::ParseVariableDeclarationList() { | 3761 AstNode* Parser::ParseVariableDeclarationList() { |
| 3748 TRACE_PARSER("ParseVariableDeclarationList"); | 3762 TRACE_PARSER("ParseVariableDeclarationList"); |
| 3749 bool is_final = (CurrentToken() == Token::kFINAL); | 3763 bool is_final = (CurrentToken() == Token::kFINAL); |
| 3750 const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( | 3764 const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( |
| 3751 FLAG_enable_type_checks ? kMustResolve : kIgnore)); | 3765 FLAG_enable_type_checks ? ClassFinalizer::kFinalize : |
| 3766 ClassFinalizer::kIgnore)); |
| 3752 if (!IsIdentifier()) { | 3767 if (!IsIdentifier()) { |
| 3753 ErrorMsg("identifier expected"); | 3768 ErrorMsg("identifier expected"); |
| 3754 } | 3769 } |
| 3755 | 3770 |
| 3756 AstNode* initializers = ParseVariableDeclaration(type, is_final); | 3771 AstNode* initializers = ParseVariableDeclaration(type, is_final); |
| 3757 ASSERT(initializers != NULL); | 3772 ASSERT(initializers != NULL); |
| 3758 while (CurrentToken() == Token::kCOMMA) { | 3773 while (CurrentToken() == Token::kCOMMA) { |
| 3759 ConsumeToken(); | 3774 ConsumeToken(); |
| 3760 if (!IsIdentifier()) { | 3775 if (!IsIdentifier()) { |
| 3761 ErrorMsg("identifier expected after comma"); | 3776 ErrorMsg("identifier expected after comma"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3777 AbstractType& result_type = AbstractType::Handle(); | 3792 AbstractType& result_type = AbstractType::Handle(); |
| 3778 const String* variable_name = NULL; | 3793 const String* variable_name = NULL; |
| 3779 const String* function_name = NULL; | 3794 const String* function_name = NULL; |
| 3780 | 3795 |
| 3781 result_type = Type::DynamicType(); | 3796 result_type = Type::DynamicType(); |
| 3782 if (CurrentToken() == Token::kVOID) { | 3797 if (CurrentToken() == Token::kVOID) { |
| 3783 ConsumeToken(); | 3798 ConsumeToken(); |
| 3784 result_type = Type::VoidType(); | 3799 result_type = Type::VoidType(); |
| 3785 } else if ((CurrentToken() == Token::kIDENT) && | 3800 } else if ((CurrentToken() == Token::kIDENT) && |
| 3786 (LookaheadToken(1) != Token::kLPAREN)) { | 3801 (LookaheadToken(1) != Token::kLPAREN)) { |
| 3787 result_type = ParseType(kMustResolve); | 3802 result_type = ParseType(ClassFinalizer::kFinalize); |
| 3788 } | 3803 } |
| 3789 const intptr_t ident_pos = token_index_; | 3804 const intptr_t ident_pos = token_index_; |
| 3790 if (IsIdentifier()) { | 3805 if (IsIdentifier()) { |
| 3791 variable_name = CurrentLiteral(); | 3806 variable_name = CurrentLiteral(); |
| 3792 function_name = variable_name; | 3807 function_name = variable_name; |
| 3793 ConsumeToken(); | 3808 ConsumeToken(); |
| 3794 } else { | 3809 } else { |
| 3795 if (!is_literal) { | 3810 if (!is_literal) { |
| 3796 ErrorMsg("function name expected"); | 3811 ErrorMsg("function name expected"); |
| 3797 } | 3812 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3878 // Patch the function type now that the signature is known. | 3893 // Patch the function type now that the signature is known. |
| 3879 // We need to create a new type for proper finalization, since the existing | 3894 // We need to create a new type for proper finalization, since the existing |
| 3880 // type is already marked as finalized. | 3895 // type is already marked as finalized. |
| 3881 Type& signature_type = Type::Handle(signature_class.SignatureType()); | 3896 Type& signature_type = Type::Handle(signature_class.SignatureType()); |
| 3882 const AbstractTypeArguments& signature_type_arguments = | 3897 const AbstractTypeArguments& signature_type_arguments = |
| 3883 AbstractTypeArguments::Handle(signature_type.arguments()); | 3898 AbstractTypeArguments::Handle(signature_type.arguments()); |
| 3884 | 3899 |
| 3885 // Since the signature type is cached by the signature class, it may have | 3900 // Since the signature type is cached by the signature class, it may have |
| 3886 // been finalized already. | 3901 // been finalized already. |
| 3887 if (!signature_type.IsFinalized()) { | 3902 if (!signature_type.IsFinalized()) { |
| 3888 signature_type ^= | 3903 signature_type ^= ClassFinalizer::FinalizeType( |
| 3889 ClassFinalizer::FinalizeType(signature_class, signature_type); | 3904 signature_class, signature_type, ClassFinalizer::kFinalize); |
| 3890 // The call to ClassFinalizer::FinalizeType may have | 3905 // The call to ClassFinalizer::FinalizeType may have |
| 3891 // extended the vector of type arguments. | 3906 // extended the vector of type arguments. |
| 3892 ASSERT(signature_type_arguments.IsNull() || | 3907 ASSERT(signature_type_arguments.IsNull() || |
| 3893 (signature_type_arguments.Length() == | 3908 (signature_type_arguments.Length() == |
| 3894 signature_class.NumTypeArguments())); | 3909 signature_class.NumTypeArguments())); |
| 3895 // The signature_class should not have changed. | 3910 // The signature_class should not have changed. |
| 3896 ASSERT(signature_type.type_class() == signature_class.raw()); | 3911 ASSERT(signature_type.type_class() == signature_class.raw()); |
| 3897 } | 3912 } |
| 3898 | 3913 |
| 3899 // Now patch the function type of the variable. | 3914 // Now patch the function type of the variable. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4424 bool is_final = (CurrentToken() == Token::kFINAL); | 4439 bool is_final = (CurrentToken() == Token::kFINAL); |
| 4425 const String* loop_var_name = NULL; | 4440 const String* loop_var_name = NULL; |
| 4426 LocalVariable* loop_var = NULL; | 4441 LocalVariable* loop_var = NULL; |
| 4427 intptr_t loop_var_pos = 0; | 4442 intptr_t loop_var_pos = 0; |
| 4428 if (LookaheadToken(1) == Token::kIN) { | 4443 if (LookaheadToken(1) == Token::kIN) { |
| 4429 loop_var_pos = token_index_; | 4444 loop_var_pos = token_index_; |
| 4430 loop_var_name = ExpectIdentifier("variable name expected"); | 4445 loop_var_name = ExpectIdentifier("variable name expected"); |
| 4431 } else { | 4446 } else { |
| 4432 // The case without a type is handled above, so require a type here. | 4447 // The case without a type is handled above, so require a type here. |
| 4433 const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( | 4448 const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( |
| 4434 FLAG_enable_type_checks ? kMustResolve : kIgnore)); | 4449 FLAG_enable_type_checks ? ClassFinalizer::kFinalize : |
| 4450 ClassFinalizer::kIgnore)); |
| 4435 loop_var_pos = token_index_; | 4451 loop_var_pos = token_index_; |
| 4436 loop_var_name = ExpectIdentifier("variable name expected"); | 4452 loop_var_name = ExpectIdentifier("variable name expected"); |
| 4437 loop_var = new LocalVariable(loop_var_pos, *loop_var_name, type); | 4453 loop_var = new LocalVariable(loop_var_pos, *loop_var_name, type); |
| 4438 if (is_final) { | 4454 if (is_final) { |
| 4439 loop_var->set_is_final(); | 4455 loop_var->set_is_final(); |
| 4440 } | 4456 } |
| 4441 } | 4457 } |
| 4442 ExpectToken(Token::kIN); | 4458 ExpectToken(Token::kIN); |
| 4443 const intptr_t collection_pos = token_index_; | 4459 const intptr_t collection_pos = token_index_; |
| 4444 AstNode* collection_expr = ParseExpr(kAllowConst); | 4460 AstNode* collection_expr = ParseExpr(kAllowConst); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4683 | 4699 |
| 4684 | 4700 |
| 4685 // Parse the parameter specified in the catch clause. | 4701 // Parse the parameter specified in the catch clause. |
| 4686 void Parser::ParseCatchParameter(CatchParamDesc* catch_param) { | 4702 void Parser::ParseCatchParameter(CatchParamDesc* catch_param) { |
| 4687 TRACE_PARSER("ParseCatchParameter"); | 4703 TRACE_PARSER("ParseCatchParameter"); |
| 4688 ASSERT(catch_param != NULL); | 4704 ASSERT(catch_param != NULL); |
| 4689 catch_param->is_final = (CurrentToken() == Token::kFINAL); | 4705 catch_param->is_final = (CurrentToken() == Token::kFINAL); |
| 4690 // The type of the catch parameter must always be resolved, even in unchecked | 4706 // The type of the catch parameter must always be resolved, even in unchecked |
| 4691 // mode. | 4707 // mode. |
| 4692 catch_param->type = &AbstractType::ZoneHandle( | 4708 catch_param->type = &AbstractType::ZoneHandle( |
| 4693 ParseFinalVarOrType(kMustResolve)); | 4709 ParseFinalVarOrType(ClassFinalizer::kFinalizeWellFormed)); |
| 4694 catch_param->token_index = token_index_; | 4710 catch_param->token_index = token_index_; |
| 4695 catch_param->var = ExpectIdentifier("identifier expected"); | 4711 catch_param->var = ExpectIdentifier("identifier expected"); |
| 4696 } | 4712 } |
| 4697 | 4713 |
| 4698 | 4714 |
| 4699 // Populate local scope of the catch block with the catch parameters. | 4715 // Populate local scope of the catch block with the catch parameters. |
| 4700 void Parser::AddCatchParamsToScope(const CatchParamDesc& exception_param, | 4716 void Parser::AddCatchParamsToScope(const CatchParamDesc& exception_param, |
| 4701 const CatchParamDesc& stack_trace_param, | 4717 const CatchParamDesc& stack_trace_param, |
| 4702 LocalScope* scope) { | 4718 LocalScope* scope) { |
| 4703 ASSERT(exception_param.var != NULL); | 4719 ASSERT(exception_param.var != NULL); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5215 new LoadLocalNode(statement_pos, *trace_var)); | 5231 new LoadLocalNode(statement_pos, *trace_var)); |
| 5216 } | 5232 } |
| 5217 } else { | 5233 } else { |
| 5218 statement = ParseExpr(kAllowConst); | 5234 statement = ParseExpr(kAllowConst); |
| 5219 ExpectSemicolon(); | 5235 ExpectSemicolon(); |
| 5220 } | 5236 } |
| 5221 return statement; | 5237 return statement; |
| 5222 } | 5238 } |
| 5223 | 5239 |
| 5224 | 5240 |
| 5225 // Static | |
| 5226 RawError* Parser::FormatError(const Script& script, | 5241 RawError* Parser::FormatError(const Script& script, |
| 5227 intptr_t token_index, | 5242 intptr_t token_index, |
| 5228 const char* message_header, | 5243 const char* message_header, |
| 5229 const char* format, | 5244 const char* format, |
| 5230 va_list args) { | 5245 va_list args) { |
| 5231 const intptr_t kMessageBufferSize = 512; | 5246 const intptr_t kMessageBufferSize = 512; |
| 5232 char message_buffer[kMessageBufferSize]; | 5247 char message_buffer[kMessageBufferSize]; |
| 5233 FormatMessage(script, token_index, message_header, | 5248 FormatMessage(script, token_index, message_header, |
| 5234 message_buffer, kMessageBufferSize, | 5249 message_buffer, kMessageBufferSize, |
| 5235 format, args); | 5250 format, args); |
| 5236 const String& msg = String::Handle(String::New(message_buffer)); | 5251 const String& msg = String::Handle(String::New(message_buffer)); |
| 5237 return LanguageError::New(msg); | 5252 return LanguageError::New(msg); |
| 5238 } | 5253 } |
| 5239 | 5254 |
| 5240 | 5255 |
| 5241 // Static. | |
| 5242 void Parser::FormatMessage(const Script& script, | 5256 void Parser::FormatMessage(const Script& script, |
| 5243 intptr_t token_index, | 5257 intptr_t token_index, |
| 5244 const char* message_header, | 5258 const char* message_header, |
| 5245 char* message_buffer, | 5259 char* message_buffer, |
| 5246 intptr_t message_buffer_size, | 5260 intptr_t message_buffer_size, |
| 5247 const char* format, va_list args) { | 5261 const char* format, va_list args) { |
| 5248 intptr_t msg_len = 0; | 5262 intptr_t msg_len = 0; |
| 5249 if (!script.IsNull()) { | 5263 if (!script.IsNull()) { |
| 5250 const String& script_url = String::CheckedHandle(script.url()); | 5264 const String& script_url = String::CheckedHandle(script.url()); |
| 5251 if (token_index >= 0) { | 5265 if (token_index >= 0) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5431 SequenceNode* sequence = new SequenceNode(sequence_pos, scope); | 5445 SequenceNode* sequence = new SequenceNode(sequence_pos, scope); |
| 5432 if (node != NULL) { | 5446 if (node != NULL) { |
| 5433 sequence->Add(node); | 5447 sequence->Add(node); |
| 5434 } | 5448 } |
| 5435 return sequence; | 5449 return sequence; |
| 5436 } | 5450 } |
| 5437 return node->AsSequenceNode(); | 5451 return node->AsSequenceNode(); |
| 5438 } | 5452 } |
| 5439 | 5453 |
| 5440 | 5454 |
| 5455 AstNode* Parser::ThrowTypeError(intptr_t type_pos, const AbstractType& type) { |
| 5456 ASSERT(type.IsMalformed()); |
| 5457 ArgumentListNode* arguments = new ArgumentListNode(type_pos); |
| 5458 // Location argument. |
| 5459 arguments->Add(new LiteralNode( |
| 5460 type_pos, Integer::ZoneHandle(Integer::New(type_pos)))); |
| 5461 // Src value argument. |
| 5462 arguments->Add(new LiteralNode(type_pos, Instance::ZoneHandle())); |
| 5463 // Dst type name argument. |
| 5464 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
| 5465 String::NewSymbol("malformed type")))); |
| 5466 // Dst type name argument. |
| 5467 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
| 5468 String::NewSymbol("")))); |
| 5469 // Malformed type error. |
| 5470 const Error& error = Error::Handle(type.malformed_error()); |
| 5471 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
| 5472 String::NewSymbol(error.ToErrorCString())))); |
| 5473 return MakeStaticCall(kTypeErrorName, kThrowNewName, arguments); |
| 5474 } |
| 5475 |
| 5476 |
| 5441 AstNode* Parser::ParseBinaryExpr(int min_preced) { | 5477 AstNode* Parser::ParseBinaryExpr(int min_preced) { |
| 5442 TRACE_PARSER("ParseBinaryExpr"); | 5478 TRACE_PARSER("ParseBinaryExpr"); |
| 5443 ASSERT(min_preced >= 4); | 5479 ASSERT(min_preced >= 4); |
| 5444 AstNode* left_operand = ParseUnaryExpr(); | 5480 AstNode* left_operand = ParseUnaryExpr(); |
| 5445 int current_preced = Token::Precedence(CurrentToken()); | 5481 int current_preced = Token::Precedence(CurrentToken()); |
| 5446 while (current_preced >= min_preced) { | 5482 while (current_preced >= min_preced) { |
| 5447 while (Token::Precedence(CurrentToken()) == current_preced) { | 5483 while (Token::Precedence(CurrentToken()) == current_preced) { |
| 5448 Token::Kind op_kind = CurrentToken(); | 5484 Token::Kind op_kind = CurrentToken(); |
| 5449 if (op_kind == Token::kTIGHTADD) { | 5485 if (op_kind == Token::kTIGHTADD) { |
| 5450 op_kind = Token::kADD; | 5486 op_kind = Token::kADD; |
| 5451 } | 5487 } |
| 5452 const intptr_t op_pos = token_index_; | 5488 const intptr_t op_pos = token_index_; |
| 5453 ConsumeToken(); | 5489 ConsumeToken(); |
| 5454 AstNode* right_operand = NULL; | 5490 AstNode* right_operand = NULL; |
| 5455 if (op_kind != Token::kIS) { | 5491 if (op_kind != Token::kIS) { |
| 5456 right_operand = ParseBinaryExpr(current_preced + 1); | 5492 right_operand = ParseBinaryExpr(current_preced + 1); |
| 5457 } else { | 5493 } else { |
| 5458 // For 'is' we expect the right operand to be a type. | 5494 // For 'is' we expect the right operand to be a type. |
| 5459 if (CurrentToken() == Token::kNOT) { | 5495 if (CurrentToken() == Token::kNOT) { |
| 5460 ConsumeToken(); | 5496 ConsumeToken(); |
| 5461 op_kind = Token::kISNOT; | 5497 op_kind = Token::kISNOT; |
| 5462 } | 5498 } |
| 5463 const intptr_t type_pos = token_index_; | 5499 const intptr_t type_pos = token_index_; |
| 5464 const AbstractType& type = | 5500 const AbstractType& type = |
| 5465 AbstractType::ZoneHandle(ParseType(kMustResolve)); | 5501 AbstractType::ZoneHandle(ParseType(ClassFinalizer::kFinalize)); |
| 5466 if (!type.IsInstantiated() && | 5502 if (!type.IsInstantiated() && |
| 5467 (current_block_->scope->function_level() > 0)) { | 5503 (current_block_->scope->function_level() > 0)) { |
| 5468 // Make sure that the instantiator is captured. | 5504 // Make sure that the instantiator is captured. |
| 5469 CaptureReceiver(); | 5505 CaptureReceiver(); |
| 5470 } | 5506 } |
| 5471 right_operand = new TypeNode(type_pos, type); | 5507 right_operand = new TypeNode(type_pos, type); |
| 5508 if (type.IsMalformed()) { |
| 5509 return ThrowTypeError(type_pos, type); |
| 5510 } |
| 5472 } | 5511 } |
| 5473 if (Token::IsRelationalOperator(op_kind) | 5512 if (Token::IsRelationalOperator(op_kind) |
| 5474 || Token::IsInstanceofOperator(op_kind) | 5513 || Token::IsInstanceofOperator(op_kind) |
| 5475 || Token::IsEqualityOperator(op_kind)) { | 5514 || Token::IsEqualityOperator(op_kind)) { |
| 5476 left_operand = new ComparisonNode( | 5515 left_operand = new ComparisonNode( |
| 5477 op_pos, op_kind, left_operand, right_operand); | 5516 op_pos, op_kind, left_operand, right_operand); |
| 5478 break; // Equality and relational operators cannot be chained. | 5517 break; // Equality and relational operators cannot be chained. |
| 5479 } else { | 5518 } else { |
| 5480 StringConcatNode* str_concat = NULL; | 5519 StringConcatNode* str_concat = NULL; |
| 5481 if (op_kind == Token::kADD) { | 5520 if (op_kind == Token::kADD) { |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6243 if (incr_op_node == NULL) { | 6282 if (incr_op_node == NULL) { |
| 6244 Unimplemented("incr op not implemented"); | 6283 Unimplemented("incr op not implemented"); |
| 6245 } | 6284 } |
| 6246 postfix_expr = incr_op_node; | 6285 postfix_expr = incr_op_node; |
| 6247 } | 6286 } |
| 6248 return postfix_expr; | 6287 return postfix_expr; |
| 6249 } | 6288 } |
| 6250 | 6289 |
| 6251 | 6290 |
| 6252 // Resolve the given type and its type arguments from the given scope class | 6291 // Resolve the given type and its type arguments from the given scope class |
| 6253 // according to the given type_resolution. | 6292 // according to the given type finalization mode. |
| 6254 // If the given scope class is null, use the current library, but do not try to | 6293 // If the given scope class is null, use the current library, but do not try to |
| 6255 // resolve type parameters. | 6294 // resolve type parameters. |
| 6256 // Not all involved type classes may get resolved yet, but at least the type | 6295 // Not all involved type classes may get resolved yet, but at least the type |
| 6257 // parameters of the given class will get resolved, thereby relieving the class | 6296 // parameters of the given class will get resolved, thereby relieving the class |
| 6258 // finalizer from resolving type parameters out of context. | 6297 // finalizer from resolving type parameters out of context. |
| 6259 void Parser::ResolveTypeFromClass(const Class& scope_class, | 6298 void Parser::ResolveTypeFromClass(const Class& scope_class, |
| 6260 TypeResolution type_resolution, | 6299 ClassFinalizer::FinalizationKind finalization, |
| 6261 AbstractType* type) { | 6300 AbstractType* type) { |
| 6262 ASSERT((type_resolution == kCanResolve) || (type_resolution == kMustResolve)); | 6301 ASSERT(finalization >= ClassFinalizer::kTryResolve); |
| 6263 ASSERT(type != NULL); | 6302 ASSERT(type != NULL); |
| 6264 if (type->IsResolved()) { | 6303 if (type->IsResolved()) { |
| 6265 return; | 6304 return; |
| 6266 } | 6305 } |
| 6267 // Resolve class. | 6306 // Resolve class. |
| 6268 if (!type->HasResolvedTypeClass()) { | 6307 if (!type->HasResolvedTypeClass()) { |
| 6269 const UnresolvedClass& unresolved_class = | 6308 const UnresolvedClass& unresolved_class = |
| 6270 UnresolvedClass::Handle(type->unresolved_class()); | 6309 UnresolvedClass::Handle(type->unresolved_class()); |
| 6271 const String& unresolved_class_name = | 6310 const String& unresolved_class_name = |
| 6272 String::Handle(unresolved_class.ident()); | 6311 String::Handle(unresolved_class.ident()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6290 } | 6329 } |
| 6291 } | 6330 } |
| 6292 // Global lookup in current library. | 6331 // Global lookup in current library. |
| 6293 resolved_type_class = library_.LookupClass(unresolved_class_name); | 6332 resolved_type_class = library_.LookupClass(unresolved_class_name); |
| 6294 } else { | 6333 } else { |
| 6295 LibraryPrefix& lib_prefix = | 6334 LibraryPrefix& lib_prefix = |
| 6296 LibraryPrefix::Handle(unresolved_class.library_prefix()); | 6335 LibraryPrefix::Handle(unresolved_class.library_prefix()); |
| 6297 // Local lookup in library prefix scope. | 6336 // Local lookup in library prefix scope. |
| 6298 resolved_type_class = lib_prefix.LookupLocalClass(unresolved_class_name); | 6337 resolved_type_class = lib_prefix.LookupLocalClass(unresolved_class_name); |
| 6299 } | 6338 } |
| 6339 // At this point, we can only have a parameterized_type. |
| 6340 Type& parameterized_type = Type::Handle(); |
| 6341 parameterized_type ^= type->raw(); |
| 6300 if (!resolved_type_class.IsNull()) { | 6342 if (!resolved_type_class.IsNull()) { |
| 6301 Object& type_class = Object::Handle(resolved_type_class.raw()); | 6343 Object& type_class = Object::Handle(resolved_type_class.raw()); |
| 6302 ASSERT(type->IsType()); | |
| 6303 // Replace unresolved class with resolved type class. | 6344 // Replace unresolved class with resolved type class. |
| 6304 Type& parameterized_type = Type::Handle(); | |
| 6305 parameterized_type ^= type->raw(); | |
| 6306 parameterized_type.set_type_class(type_class); | 6345 parameterized_type.set_type_class(type_class); |
| 6307 } else if (type_resolution == kMustResolve) { | 6346 } else if (finalization >= ClassFinalizer::kFinalize) { |
| 6308 ErrorMsg(type->token_index(), "type '%s' is not loaded", | 6347 // The type is malformed. |
| 6309 String::Handle(type->Name()).ToCString()); | 6348 ClassFinalizer::FinalizeMalformedType( |
| 6349 current_class(), parameterized_type, finalization, |
| 6350 "type '%s' is not loaded", |
| 6351 String::Handle(parameterized_type.Name()).ToCString()); |
| 6310 } | 6352 } |
| 6311 } | 6353 } |
| 6312 // Resolve type arguments, if any. | 6354 // Resolve type arguments, if any. |
| 6313 const AbstractTypeArguments& arguments = | 6355 const AbstractTypeArguments& arguments = |
| 6314 AbstractTypeArguments::Handle(type->arguments()); | 6356 AbstractTypeArguments::Handle(type->arguments()); |
| 6315 if (!arguments.IsNull()) { | 6357 if (!arguments.IsNull()) { |
| 6316 const intptr_t num_arguments = arguments.Length(); | 6358 const intptr_t num_arguments = arguments.Length(); |
| 6317 for (intptr_t i = 0; i < num_arguments; i++) { | 6359 for (intptr_t i = 0; i < num_arguments; i++) { |
| 6318 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); | 6360 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); |
| 6319 ResolveTypeFromClass(scope_class, | 6361 ResolveTypeFromClass(scope_class, finalization, &type_argument); |
| 6320 type_resolution, | |
| 6321 &type_argument); | |
| 6322 arguments.SetTypeAt(i, type_argument); | 6362 arguments.SetTypeAt(i, type_argument); |
| 6323 } | 6363 } |
| 6324 } | 6364 } |
| 6325 } | 6365 } |
| 6326 | 6366 |
| 6327 | 6367 |
| 6328 LocalVariable* Parser::LookupLocalScope(const String& ident) { | 6368 LocalVariable* Parser::LookupLocalScope(const String& ident) { |
| 6329 if (current_block_ == NULL) { | 6369 if (current_block_ == NULL) { |
| 6330 return NULL; | 6370 return NULL; |
| 6331 } | 6371 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6747 String& map_name = String::Handle(library_.LookupImportMap(ident)); | 6787 String& map_name = String::Handle(library_.LookupImportMap(ident)); |
| 6748 if (!map_name.IsNull()) { | 6788 if (!map_name.IsNull()) { |
| 6749 return map_name.raw(); | 6789 return map_name.raw(); |
| 6750 } | 6790 } |
| 6751 ErrorMsg(ident_pos, "import variable '%s' has not been defined", | 6791 ErrorMsg(ident_pos, "import variable '%s' has not been defined", |
| 6752 ident.ToCString()); | 6792 ident.ToCString()); |
| 6753 return String::null(); | 6793 return String::null(); |
| 6754 } | 6794 } |
| 6755 | 6795 |
| 6756 | 6796 |
| 6757 // Parses type = [ident "."] ident ["<" type { "," type } ">"] and resolve it | 6797 // Parses type = [ident "."] ident ["<" type { "," type } ">"], then resolve and |
| 6758 // according to the given type_resolution. | 6798 // finalize it according to the given type finalization mode. |
| 6759 RawAbstractType* Parser::ParseType(TypeResolution type_resolution) { | 6799 RawAbstractType* Parser::ParseType( |
| 6800 ClassFinalizer::FinalizationKind finalization) { |
| 6760 TRACE_PARSER("ParseType"); | 6801 TRACE_PARSER("ParseType"); |
| 6761 if (CurrentToken() != Token::kIDENT) { | 6802 if (CurrentToken() != Token::kIDENT) { |
| 6762 ErrorMsg("type name expected"); | 6803 ErrorMsg("type name expected"); |
| 6763 } | 6804 } |
| 6764 QualIdent type_name; | 6805 QualIdent type_name; |
| 6765 if (type_resolution == kIgnore) { | 6806 if (finalization == ClassFinalizer::kIgnore) { |
| 6766 SkipQualIdent(); | 6807 SkipQualIdent(); |
| 6767 } else { | 6808 } else { |
| 6768 ParseQualIdent(&type_name); | 6809 ParseQualIdent(&type_name); |
| 6769 // An identifier cannot be resolved in a local scope when top level parsing. | 6810 // An identifier cannot be resolved in a local scope when top level parsing. |
| 6770 if (!is_top_level_ && | 6811 if (!is_top_level_ && |
| 6771 (type_name.lib_prefix == NULL) && | 6812 (type_name.lib_prefix == NULL) && |
| 6772 ResolveIdentInLocalScope(type_name.ident_pos, *type_name.ident, NULL)) { | 6813 ResolveIdentInLocalScope(type_name.ident_pos, *type_name.ident, NULL)) { |
| 6773 ErrorMsg(type_name.ident_pos, "using '%s' in this context is invalid", | 6814 ErrorMsg(type_name.ident_pos, "using '%s' in this context is invalid", |
| 6774 type_name.ident->ToCString()); | 6815 type_name.ident->ToCString()); |
| 6775 } | 6816 } |
| 6776 } | 6817 } |
| 6777 Object& type_class = Object::Handle(); | 6818 Object& type_class = Object::Handle(); |
| 6778 // Leave type_class as null if type_resolution equals kIgnore. | 6819 // Leave type_class as null if type finalization mode is kIgnore. |
| 6779 if (type_resolution != kIgnore) { | 6820 if (finalization != ClassFinalizer::kIgnore) { |
| 6780 LibraryPrefix& lib_prefix = LibraryPrefix::Handle(); | 6821 LibraryPrefix& lib_prefix = LibraryPrefix::Handle(); |
| 6781 if (type_name.lib_prefix != NULL) { | 6822 if (type_name.lib_prefix != NULL) { |
| 6782 lib_prefix = type_name.lib_prefix->raw(); | 6823 lib_prefix = type_name.lib_prefix->raw(); |
| 6783 } | 6824 } |
| 6784 type_class = UnresolvedClass::New(lib_prefix, | 6825 type_class = UnresolvedClass::New(lib_prefix, |
| 6785 *type_name.ident, | 6826 *type_name.ident, |
| 6786 type_name.ident_pos); | 6827 type_name.ident_pos); |
| 6787 } | 6828 } |
| 6829 Error& malformed_error = Error::Handle(); |
| 6788 AbstractTypeArguments& type_arguments = | 6830 AbstractTypeArguments& type_arguments = |
| 6789 AbstractTypeArguments::Handle(ParseTypeArguments(type_resolution)); | 6831 AbstractTypeArguments::Handle(ParseTypeArguments(&malformed_error, |
| 6790 if (type_resolution == kIgnore) { | 6832 finalization)); |
| 6833 if (finalization == ClassFinalizer::kIgnore) { |
| 6791 return Type::DynamicType(); | 6834 return Type::DynamicType(); |
| 6792 } | 6835 } |
| 6793 AbstractType& type = AbstractType::Handle( | 6836 AbstractType& type = AbstractType::Handle( |
| 6794 Type::New(type_class, type_arguments, type_name.ident_pos)); | 6837 Type::New(type_class, type_arguments, type_name.ident_pos)); |
| 6795 if ((type_resolution == kCanResolve) || (type_resolution == kMustResolve)) { | 6838 if (!malformed_error.IsNull()) { |
| 6839 Type& parameterized_type = Type::Handle(); |
| 6840 parameterized_type ^= type.raw(); |
| 6841 parameterized_type.set_type_class(Class::Handle(Object::dynamic_class())); |
| 6842 parameterized_type.set_arguments(AbstractTypeArguments::Handle()); |
| 6843 parameterized_type.set_malformed_error(malformed_error); |
| 6844 } |
| 6845 if (finalization >= ClassFinalizer::kTryResolve) { |
| 6796 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); | 6846 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); |
| 6797 ResolveTypeFromClass(scope_class, type_resolution, &type); | 6847 ResolveTypeFromClass(scope_class, finalization, &type); |
| 6798 if (type_resolution == kMustResolve) { | 6848 if (finalization >= ClassFinalizer::kFinalize) { |
| 6799 type ^= ClassFinalizer::FinalizeType(current_class(), type); | 6849 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization); |
| 6800 } | 6850 } |
| 6801 } | 6851 } |
| 6802 return type.raw(); | 6852 return type.raw(); |
| 6803 } | 6853 } |
| 6804 | 6854 |
| 6805 | 6855 |
| 6806 void Parser::CheckConstructorCallTypeArguments( | 6856 void Parser::CheckConstructorCallTypeArguments( |
| 6807 intptr_t pos, Function& constructor, | 6857 intptr_t pos, Function& constructor, |
| 6808 const AbstractTypeArguments& type_arguments) { | 6858 const AbstractTypeArguments& type_arguments) { |
| 6809 if (!type_arguments.IsNull()) { | 6859 if (!type_arguments.IsNull()) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7150 | 7200 |
| 7151 | 7201 |
| 7152 AstNode* Parser::ParseCompoundLiteral() { | 7202 AstNode* Parser::ParseCompoundLiteral() { |
| 7153 TRACE_PARSER("ParseCompoundLiteral"); | 7203 TRACE_PARSER("ParseCompoundLiteral"); |
| 7154 bool is_const = false; | 7204 bool is_const = false; |
| 7155 if (CurrentToken() == Token::kCONST) { | 7205 if (CurrentToken() == Token::kCONST) { |
| 7156 is_const = true; | 7206 is_const = true; |
| 7157 ConsumeToken(); | 7207 ConsumeToken(); |
| 7158 } | 7208 } |
| 7159 const intptr_t type_pos = token_index_; | 7209 const intptr_t type_pos = token_index_; |
| 7160 AbstractTypeArguments& type_arguments = | 7210 Error& malformed_error = Error::Handle(); |
| 7161 AbstractTypeArguments::ZoneHandle(ParseTypeArguments(kMustResolve)); | 7211 AbstractTypeArguments& type_arguments = AbstractTypeArguments::ZoneHandle( |
| 7212 ParseTypeArguments(&malformed_error, |
| 7213 ClassFinalizer::kFinalizeWellFormed)); |
| 7162 AstNode* primary = NULL; | 7214 AstNode* primary = NULL; |
| 7163 if ((CurrentToken() == Token::kLBRACK) || | 7215 if ((CurrentToken() == Token::kLBRACK) || |
| 7164 (CurrentToken() == Token::kINDEX)) { | 7216 (CurrentToken() == Token::kINDEX)) { |
| 7165 primary = ParseListLiteral(type_pos, is_const, type_arguments); | 7217 primary = ParseListLiteral(type_pos, is_const, type_arguments); |
| 7166 } else if (CurrentToken() == Token::kLBRACE) { | 7218 } else if (CurrentToken() == Token::kLBRACE) { |
| 7167 primary = ParseMapLiteral(type_pos, is_const, type_arguments); | 7219 primary = ParseMapLiteral(type_pos, is_const, type_arguments); |
| 7168 } else { | 7220 } else { |
| 7169 ErrorMsg("unexpected token %s", Token::Str(CurrentToken())); | 7221 ErrorMsg("unexpected token %s", Token::Str(CurrentToken())); |
| 7170 } | 7222 } |
| 7171 return primary; | 7223 return primary; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7192 TRACE_PARSER("ParseNewOperator"); | 7244 TRACE_PARSER("ParseNewOperator"); |
| 7193 const intptr_t new_pos = token_index_; | 7245 const intptr_t new_pos = token_index_; |
| 7194 ASSERT((CurrentToken() == Token::kNEW) || (CurrentToken() == Token::kCONST)); | 7246 ASSERT((CurrentToken() == Token::kNEW) || (CurrentToken() == Token::kCONST)); |
| 7195 bool is_const = (CurrentToken() == Token::kCONST); | 7247 bool is_const = (CurrentToken() == Token::kCONST); |
| 7196 ConsumeToken(); | 7248 ConsumeToken(); |
| 7197 if (!IsIdentifier()) { | 7249 if (!IsIdentifier()) { |
| 7198 ErrorMsg("type name expected"); | 7250 ErrorMsg("type name expected"); |
| 7199 } | 7251 } |
| 7200 intptr_t type_pos = token_index_; | 7252 intptr_t type_pos = token_index_; |
| 7201 | 7253 |
| 7202 const AbstractType& type = AbstractType::Handle(ParseType(kMustResolve)); | 7254 const AbstractType& type = AbstractType::Handle( |
| 7255 ParseType(ClassFinalizer::kFinalizeWellFormed)); |
| 7203 if (type.IsTypeParameter()) { | 7256 if (type.IsTypeParameter()) { |
| 7204 ErrorMsg(type_pos, | 7257 ErrorMsg(type_pos, |
| 7205 "type parameter '%s' cannot be instantiated", | 7258 "type parameter '%s' cannot be instantiated", |
| 7206 String::Handle(type.Name()).ToCString()); | 7259 String::Handle(type.Name()).ToCString()); |
| 7207 } | 7260 } |
| 7208 Class& type_class = Class::Handle(type.type_class()); | 7261 Class& type_class = Class::Handle(type.type_class()); |
| 7209 String& type_class_name = String::Handle(type_class.Name()); | 7262 String& type_class_name = String::Handle(type_class.Name()); |
| 7210 AbstractTypeArguments& type_arguments = | 7263 AbstractTypeArguments& type_arguments = |
| 7211 AbstractTypeArguments::ZoneHandle(type.arguments()); | 7264 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 7212 | 7265 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7338 type_argument = type_arguments.TypeAt(i); | 7391 type_argument = type_arguments.TypeAt(i); |
| 7339 } else { | 7392 } else { |
| 7340 type_argument = Type::DynamicType(); | 7393 type_argument = Type::DynamicType(); |
| 7341 } | 7394 } |
| 7342 temp_type_arguments.SetTypeAt(i, type_argument); | 7395 temp_type_arguments.SetTypeAt(i, type_argument); |
| 7343 } | 7396 } |
| 7344 } | 7397 } |
| 7345 // TODO(regis): Temporary type should be allocated in new gen heap. | 7398 // TODO(regis): Temporary type should be allocated in new gen heap. |
| 7346 Type& temp_type = Type::Handle( | 7399 Type& temp_type = Type::Handle( |
| 7347 Type::New(constructor_class, temp_type_arguments, type.token_index())); | 7400 Type::New(constructor_class, temp_type_arguments, type.token_index())); |
| 7348 temp_type ^= ClassFinalizer::FinalizeType(current_class(), temp_type); | 7401 temp_type ^= ClassFinalizer::FinalizeType( |
| 7402 current_class(), temp_type, ClassFinalizer::kFinalize); |
| 7349 // The type argument vector may have been expanded with the type arguments | 7403 // The type argument vector may have been expanded with the type arguments |
| 7350 // of the super type when finalizing the temporary type. | 7404 // of the super type when finalizing the temporary type. |
| 7351 type_arguments = temp_type.arguments(); | 7405 type_arguments = temp_type.arguments(); |
| 7352 } | 7406 } |
| 7353 | 7407 |
| 7354 type_arguments ^= type_arguments.Canonicalize(); | 7408 type_arguments ^= type_arguments.Canonicalize(); |
| 7355 // Make the constructor call. | 7409 // Make the constructor call. |
| 7356 AstNode* new_object = NULL; | 7410 AstNode* new_object = NULL; |
| 7357 if (is_const) { | 7411 if (is_const) { |
| 7358 if (!constructor.is_const()) { | 7412 if (!constructor.is_const()) { |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7913 void Parser::SkipQualIdent() { | 7967 void Parser::SkipQualIdent() { |
| 7914 ASSERT(IsIdentifier()); | 7968 ASSERT(IsIdentifier()); |
| 7915 ConsumeToken(); | 7969 ConsumeToken(); |
| 7916 if (CurrentToken() == Token::kPERIOD) { | 7970 if (CurrentToken() == Token::kPERIOD) { |
| 7917 ConsumeToken(); // Consume the kPERIOD token. | 7971 ConsumeToken(); // Consume the kPERIOD token. |
| 7918 ExpectIdentifier("identifier expected after '.'"); | 7972 ExpectIdentifier("identifier expected after '.'"); |
| 7919 } | 7973 } |
| 7920 } | 7974 } |
| 7921 | 7975 |
| 7922 } // namespace dart | 7976 } // namespace dart |
| OLD | NEW |