| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2811 ExpectSemicolon(); | 2811 ExpectSemicolon(); |
| 2812 } else if (func.is_external()) { | 2812 } else if (func.is_external()) { |
| 2813 // Body of an external method contains a single throw. | 2813 // Body of an external method contains a single throw. |
| 2814 const String& function_name = String::ZoneHandle(func.name()); | 2814 const String& function_name = String::ZoneHandle(func.name()); |
| 2815 // TODO(regis): For an instance function, pass the receiver to | 2815 // TODO(regis): For an instance function, pass the receiver to |
| 2816 // NoSuchMethodError. | 2816 // NoSuchMethodError. |
| 2817 current_block_->statements->Add( | 2817 current_block_->statements->Add( |
| 2818 ThrowNoSuchMethodError(TokenPos(), | 2818 ThrowNoSuchMethodError(TokenPos(), |
| 2819 current_class(), | 2819 current_class(), |
| 2820 function_name, | 2820 function_name, |
| 2821 NULL, // No arguments. |
| 2821 func.is_static() ? | 2822 func.is_static() ? |
| 2822 InvocationMirror::kStatic : | 2823 InvocationMirror::kStatic : |
| 2823 InvocationMirror::kDynamic, | 2824 InvocationMirror::kDynamic, |
| 2824 InvocationMirror::kMethod)); | 2825 InvocationMirror::kMethod)); |
| 2825 end_token_pos = TokenPos(); | 2826 end_token_pos = TokenPos(); |
| 2826 } else { | 2827 } else { |
| 2827 UnexpectedToken(); | 2828 UnexpectedToken(); |
| 2828 } | 2829 } |
| 2829 ASSERT(func.end_token_pos() == func.token_pos() || | 2830 ASSERT(func.end_token_pos() == func.token_pos() || |
| 2830 func.end_token_pos() == end_token_pos); | 2831 func.end_token_pos() == end_token_pos); |
| (...skipping 4368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7199 ASSERT(is_malbounded); | 7200 ASSERT(is_malbounded); |
| 7200 } | 7201 } |
| 7201 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( | 7202 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
| 7202 Symbols::New(error.ToErrorCString())))); | 7203 Symbols::New(error.ToErrorCString())))); |
| 7203 return MakeStaticCall(Symbols::TypeError(), | 7204 return MakeStaticCall(Symbols::TypeError(), |
| 7204 PrivateCoreLibName(Symbols::ThrowNew()), | 7205 PrivateCoreLibName(Symbols::ThrowNew()), |
| 7205 arguments); | 7206 arguments); |
| 7206 } | 7207 } |
| 7207 | 7208 |
| 7208 | 7209 |
| 7209 // TODO(regis): Providing the argument values is not always feasible, since | |
| 7210 // evaluating them could throw an error. | |
| 7211 // Should NoSuchMethodError reflect the argument count and names instead of | |
| 7212 // argument values? Or should the spec specify a different evaluation order? | |
| 7213 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, | 7210 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, |
| 7214 const Class& cls, | 7211 const Class& cls, |
| 7215 const String& function_name, | 7212 const String& function_name, |
| 7213 ArgumentListNode* function_arguments, |
| 7216 InvocationMirror::Call im_call, | 7214 InvocationMirror::Call im_call, |
| 7217 InvocationMirror::Type im_type) { | 7215 InvocationMirror::Type im_type) { |
| 7218 ArgumentListNode* arguments = new ArgumentListNode(call_pos); | 7216 ArgumentListNode* arguments = new ArgumentListNode(call_pos); |
| 7219 // Object receiver. | 7217 // Object receiver. |
| 7220 // TODO(regis): For now, we pass a class literal of the unresolved | 7218 // TODO(regis): For now, we pass a class literal of the unresolved |
| 7221 // method's owner, but this is not specified and will probably change. | 7219 // method's owner, but this is not specified and will probably change. |
| 7222 Type& type = Type::ZoneHandle( | 7220 Type& type = Type::ZoneHandle( |
| 7223 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); | 7221 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); |
| 7224 type ^= ClassFinalizer::FinalizeType( | 7222 type ^= ClassFinalizer::FinalizeType( |
| 7225 current_class(), type, ClassFinalizer::kCanonicalize); | 7223 current_class(), type, ClassFinalizer::kCanonicalize); |
| 7226 arguments->Add(new LiteralNode(call_pos, type)); | 7224 arguments->Add(new LiteralNode(call_pos, type)); |
| 7227 // String memberName. | 7225 // String memberName. |
| 7228 arguments->Add(new LiteralNode( | 7226 arguments->Add(new LiteralNode( |
| 7229 call_pos, String::ZoneHandle(Symbols::New(function_name)))); | 7227 call_pos, String::ZoneHandle(Symbols::New(function_name)))); |
| 7230 // Smi invocation_type. | 7228 // Smi invocation_type. |
| 7231 if (cls.IsTopLevel()) { | 7229 if (cls.IsTopLevel()) { |
| 7232 ASSERT(im_call == InvocationMirror::kStatic || | 7230 ASSERT(im_call == InvocationMirror::kStatic || |
| 7233 im_call == InvocationMirror::kTopLevel); | 7231 im_call == InvocationMirror::kTopLevel); |
| 7234 im_call = InvocationMirror::kTopLevel; | 7232 im_call = InvocationMirror::kTopLevel; |
| 7235 } | 7233 } |
| 7236 arguments->Add(new LiteralNode(call_pos, Smi::ZoneHandle( | 7234 arguments->Add(new LiteralNode(call_pos, Smi::ZoneHandle( |
| 7237 Smi::New(InvocationMirror::EncodeType(im_call, im_type))))); | 7235 Smi::New(InvocationMirror::EncodeType(im_call, im_type))))); |
| 7238 // List arguments. | 7236 // List arguments. |
| 7239 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 7237 if (function_arguments == NULL) { |
| 7238 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
| 7239 } else { |
| 7240 ArrayNode* array = new ArrayNode(call_pos, |
| 7241 Type::ZoneHandle(Type::ArrayType()), |
| 7242 function_arguments->nodes()); |
| 7243 arguments->Add(array); |
| 7244 } |
| 7240 // List argumentNames. | 7245 // List argumentNames. |
| 7241 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 7246 if (function_arguments == NULL) { |
| 7247 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
| 7248 } else { |
| 7249 arguments->Add(new LiteralNode(call_pos, function_arguments->names())); |
| 7250 } |
| 7242 // List existingArgumentNames. | 7251 // List existingArgumentNames. |
| 7243 // Check if there exists a function with the same name. | 7252 // Check if there exists a function with the same name. |
| 7244 Function& function = | 7253 Function& function = |
| 7245 Function::Handle(cls.LookupStaticFunction(function_name)); | 7254 Function::Handle(cls.LookupStaticFunction(function_name)); |
| 7246 if (function.IsNull()) { | 7255 if (function.IsNull()) { |
| 7247 // TODO(srdjan): Store argument values into the argument list. | |
| 7248 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 7256 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
| 7249 } else { | 7257 } else { |
| 7250 const int total_num_parameters = function.NumParameters(); | 7258 const int total_num_parameters = function.NumParameters(); |
| 7251 Array& array = | 7259 Array& array = |
| 7252 Array::ZoneHandle(Array::New(total_num_parameters, Heap::kOld)); | 7260 Array::ZoneHandle(Array::New(total_num_parameters, Heap::kOld)); |
| 7253 // Skip receiver. | 7261 // Skip receiver. |
| 7254 for (int i = 0; i < total_num_parameters; i++) { | 7262 for (int i = 0; i < total_num_parameters; i++) { |
| 7255 array.SetAt(i, String::Handle(function.ParameterNameAt(i))); | 7263 array.SetAt(i, String::Handle(function.ParameterNameAt(i))); |
| 7256 } | 7264 } |
| 7257 arguments->Add(new LiteralNode(call_pos, array)); | 7265 arguments->Add(new LiteralNode(call_pos, array)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7537 original->IsLoadLocalNode() || | 7545 original->IsLoadLocalNode() || |
| 7538 original->IsLoadStaticFieldNode())) { | 7546 original->IsLoadStaticFieldNode())) { |
| 7539 name = left_ident->raw(); | 7547 name = left_ident->raw(); |
| 7540 } | 7548 } |
| 7541 if (name.IsNull()) { | 7549 if (name.IsNull()) { |
| 7542 ErrorMsg(left_pos, "expression is not assignable"); | 7550 ErrorMsg(left_pos, "expression is not assignable"); |
| 7543 } | 7551 } |
| 7544 result = ThrowNoSuchMethodError(original->token_pos(), | 7552 result = ThrowNoSuchMethodError(original->token_pos(), |
| 7545 current_class(), | 7553 current_class(), |
| 7546 name, | 7554 name, |
| 7555 NULL, // No arguments. |
| 7547 InvocationMirror::kStatic, | 7556 InvocationMirror::kStatic, |
| 7548 InvocationMirror::kSetter); | 7557 InvocationMirror::kSetter); |
| 7549 } else if (result->IsStoreIndexedNode() || | 7558 } else if (result->IsStoreIndexedNode() || |
| 7550 result->IsInstanceSetterNode() || | 7559 result->IsInstanceSetterNode() || |
| 7551 result->IsStaticSetterNode() || | 7560 result->IsStaticSetterNode() || |
| 7552 result->IsStoreStaticFieldNode() || | 7561 result->IsStoreStaticFieldNode() || |
| 7553 result->IsStoreLocalNode()) { | 7562 result->IsStoreLocalNode()) { |
| 7554 // Ensure that the expression temp is allocated for nodes that may need it. | 7563 // Ensure that the expression temp is allocated for nodes that may need it. |
| 7555 EnsureExpressionTemp(); | 7564 EnsureExpressionTemp(); |
| 7556 } | 7565 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7741 TRACE_PARSER("ParseActualParameters"); | 7750 TRACE_PARSER("ParseActualParameters"); |
| 7742 ASSERT(CurrentToken() == Token::kLPAREN); | 7751 ASSERT(CurrentToken() == Token::kLPAREN); |
| 7743 const bool saved_mode = SetAllowFunctionLiterals(true); | 7752 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 7744 ArgumentListNode* arguments; | 7753 ArgumentListNode* arguments; |
| 7745 if (implicit_arguments == NULL) { | 7754 if (implicit_arguments == NULL) { |
| 7746 arguments = new ArgumentListNode(TokenPos()); | 7755 arguments = new ArgumentListNode(TokenPos()); |
| 7747 } else { | 7756 } else { |
| 7748 arguments = implicit_arguments; | 7757 arguments = implicit_arguments; |
| 7749 } | 7758 } |
| 7750 const GrowableObjectArray& names = | 7759 const GrowableObjectArray& names = |
| 7751 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 7760 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
| 7752 bool named_argument_seen = false; | 7761 bool named_argument_seen = false; |
| 7753 if (LookaheadToken(1) != Token::kRPAREN) { | 7762 if (LookaheadToken(1) != Token::kRPAREN) { |
| 7754 String& arg_name = String::Handle(); | 7763 String& arg_name = String::Handle(); |
| 7755 do { | 7764 do { |
| 7756 ASSERT((CurrentToken() == Token::kLPAREN) || | 7765 ASSERT((CurrentToken() == Token::kLPAREN) || |
| 7757 (CurrentToken() == Token::kCOMMA)); | 7766 (CurrentToken() == Token::kCOMMA)); |
| 7758 ConsumeToken(); | 7767 ConsumeToken(); |
| 7759 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) { | 7768 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) { |
| 7760 named_argument_seen = true; | 7769 named_argument_seen = true; |
| 7761 // The canonicalization of the arguments descriptor array built in | 7770 // The canonicalization of the arguments descriptor array built in |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7830 } | 7839 } |
| 7831 } else { | 7840 } else { |
| 7832 EnsureSavedCurrentContext(); | 7841 EnsureSavedCurrentContext(); |
| 7833 closure = GenerateStaticFieldLookup(field, call_pos); | 7842 closure = GenerateStaticFieldLookup(field, call_pos); |
| 7834 return new ClosureCallNode(call_pos, closure, arguments); | 7843 return new ClosureCallNode(call_pos, closure, arguments); |
| 7835 } | 7844 } |
| 7836 // Could not resolve static method: throw a NoSuchMethodError. | 7845 // Could not resolve static method: throw a NoSuchMethodError. |
| 7837 return ThrowNoSuchMethodError(ident_pos, | 7846 return ThrowNoSuchMethodError(ident_pos, |
| 7838 cls, | 7847 cls, |
| 7839 func_name, | 7848 func_name, |
| 7849 arguments, |
| 7840 InvocationMirror::kStatic, | 7850 InvocationMirror::kStatic, |
| 7841 InvocationMirror::kMethod); | 7851 InvocationMirror::kMethod); |
| 7842 } else if (cls.IsTopLevel() && | 7852 } else if (cls.IsTopLevel() && |
| 7843 (cls.library() == Library::CoreLibrary()) && | 7853 (cls.library() == Library::CoreLibrary()) && |
| 7844 (func.name() == Symbols::Identical().raw())) { | 7854 (func.name() == Symbols::Identical().raw())) { |
| 7845 // This is the predefined toplevel function identical(a,b). Create | 7855 // This is the predefined toplevel function identical(a,b). Create |
| 7846 // a comparison node instead. | 7856 // a comparison node instead. |
| 7847 ASSERT(num_arguments == 2); | 7857 ASSERT(num_arguments == 2); |
| 7848 return new ComparisonNode(ident_pos, | 7858 return new ComparisonNode(ident_pos, |
| 7849 Token::kEQ_STRICT, | 7859 Token::kEQ_STRICT, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7930 func = Resolver::ResolveStatic(cls, | 7940 func = Resolver::ResolveStatic(cls, |
| 7931 setter_name, | 7941 setter_name, |
| 7932 kNumArguments, | 7942 kNumArguments, |
| 7933 Object::empty_array(), | 7943 Object::empty_array(), |
| 7934 Resolver::kIsQualified); | 7944 Resolver::kIsQualified); |
| 7935 if (func.IsNull()) { | 7945 if (func.IsNull()) { |
| 7936 // No field or explicit setter function, throw a NoSuchMethodError. | 7946 // No field or explicit setter function, throw a NoSuchMethodError. |
| 7937 return ThrowNoSuchMethodError(ident_pos, | 7947 return ThrowNoSuchMethodError(ident_pos, |
| 7938 cls, | 7948 cls, |
| 7939 field_name, | 7949 field_name, |
| 7950 NULL, // No arguments. |
| 7940 InvocationMirror::kStatic, | 7951 InvocationMirror::kStatic, |
| 7941 InvocationMirror::kField); | 7952 InvocationMirror::kField); |
| 7942 } | 7953 } |
| 7943 | 7954 |
| 7944 // Explicit setter function for the field found, field does not exist. | 7955 // Explicit setter function for the field found, field does not exist. |
| 7945 // Create a getter node first in case it is needed. If getter node | 7956 // Create a getter node first in case it is needed. If getter node |
| 7946 // is used as part of, e.g., "+=", and the explicit getter does not | 7957 // is used as part of, e.g., "+=", and the explicit getter does not |
| 7947 // exist, and error will be reported by the code generator. | 7958 // exist, and error will be reported by the code generator. |
| 7948 access = new StaticGetterNode(call_pos, | 7959 access = new StaticGetterNode(call_pos, |
| 7949 NULL, | 7960 NULL, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7974 Resolver::kIsQualified); | 7985 Resolver::kIsQualified); |
| 7975 if (func.IsNull()) { | 7986 if (func.IsNull()) { |
| 7976 // We might be referring to an implicit closure, check to see if | 7987 // We might be referring to an implicit closure, check to see if |
| 7977 // there is a function of the same name. | 7988 // there is a function of the same name. |
| 7978 func = cls.LookupStaticFunction(field_name); | 7989 func = cls.LookupStaticFunction(field_name); |
| 7979 if (func.IsNull()) { | 7990 if (func.IsNull()) { |
| 7980 // No field or explicit getter function, throw a NoSuchMethodError. | 7991 // No field or explicit getter function, throw a NoSuchMethodError. |
| 7981 return ThrowNoSuchMethodError(ident_pos, | 7992 return ThrowNoSuchMethodError(ident_pos, |
| 7982 cls, | 7993 cls, |
| 7983 field_name, | 7994 field_name, |
| 7995 NULL, // No arguments. |
| 7984 InvocationMirror::kStatic, | 7996 InvocationMirror::kStatic, |
| 7985 InvocationMirror::kGetter); | 7997 InvocationMirror::kGetter); |
| 7986 } | 7998 } |
| 7987 access = CreateImplicitClosureNode(func, call_pos, NULL); | 7999 access = CreateImplicitClosureNode(func, call_pos, NULL); |
| 7988 } else { | 8000 } else { |
| 7989 ASSERT(func.kind() != RawFunction::kImplicitStaticFinalGetter); | 8001 ASSERT(func.kind() != RawFunction::kImplicitStaticFinalGetter); |
| 7990 access = new StaticGetterNode(call_pos, | 8002 access = new StaticGetterNode(call_pos, |
| 7991 NULL, | 8003 NULL, |
| 7992 false, | 8004 false, |
| 7993 Class::ZoneHandle(cls.raw()), | 8005 Class::ZoneHandle(cls.raw()), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8013 // In a static method, evaluation of an unresolved identifier causes a | 8025 // In a static method, evaluation of an unresolved identifier causes a |
| 8014 // NoSuchMethodError to be thrown. | 8026 // NoSuchMethodError to be thrown. |
| 8015 // In an instance method, we convert this into a getter call | 8027 // In an instance method, we convert this into a getter call |
| 8016 // for a field (which may be defined in a subclass.) | 8028 // for a field (which may be defined in a subclass.) |
| 8017 String& name = String::CheckedZoneHandle(primary->primary().raw()); | 8029 String& name = String::CheckedZoneHandle(primary->primary().raw()); |
| 8018 if (current_function().is_static() || | 8030 if (current_function().is_static() || |
| 8019 current_function().IsInFactoryScope()) { | 8031 current_function().IsInFactoryScope()) { |
| 8020 return ThrowNoSuchMethodError(primary->token_pos(), | 8032 return ThrowNoSuchMethodError(primary->token_pos(), |
| 8021 current_class(), | 8033 current_class(), |
| 8022 name, | 8034 name, |
| 8035 NULL, // No arguments. |
| 8023 InvocationMirror::kStatic, | 8036 InvocationMirror::kStatic, |
| 8024 InvocationMirror::kField); | 8037 InvocationMirror::kField); |
| 8025 } else { | 8038 } else { |
| 8026 AstNode* receiver = LoadReceiver(primary->token_pos()); | 8039 AstNode* receiver = LoadReceiver(primary->token_pos()); |
| 8027 return CallGetter(node->token_pos(), receiver, name); | 8040 return CallGetter(node->token_pos(), receiver, name); |
| 8028 } | 8041 } |
| 8029 } | 8042 } |
| 8030 return primary; | 8043 return primary; |
| 8031 } | 8044 } |
| 8032 | 8045 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8184 } else if (primary->primary().IsString()) { | 8197 } else if (primary->primary().IsString()) { |
| 8185 // Primary is an unresolved name. | 8198 // Primary is an unresolved name. |
| 8186 if (primary->IsSuper()) { | 8199 if (primary->IsSuper()) { |
| 8187 ErrorMsg(primary->token_pos(), "illegal use of super"); | 8200 ErrorMsg(primary->token_pos(), "illegal use of super"); |
| 8188 } | 8201 } |
| 8189 String& name = String::CheckedZoneHandle(primary->primary().raw()); | 8202 String& name = String::CheckedZoneHandle(primary->primary().raw()); |
| 8190 if (current_function().is_static()) { | 8203 if (current_function().is_static()) { |
| 8191 selector = ThrowNoSuchMethodError(primary->token_pos(), | 8204 selector = ThrowNoSuchMethodError(primary->token_pos(), |
| 8192 current_class(), | 8205 current_class(), |
| 8193 name, | 8206 name, |
| 8207 NULL, // No arguments. |
| 8194 InvocationMirror::kStatic, | 8208 InvocationMirror::kStatic, |
| 8195 InvocationMirror::kMethod); | 8209 InvocationMirror::kMethod); |
| 8196 } else { | 8210 } else { |
| 8197 // Treat as call to unresolved (instance) method. | 8211 // Treat as call to unresolved (instance) method. |
| 8198 AstNode* receiver = LoadReceiver(primary->token_pos()); | 8212 AstNode* receiver = LoadReceiver(primary->token_pos()); |
| 8199 selector = ParseInstanceCall(receiver, name); | 8213 selector = ParseInstanceCall(receiver, name); |
| 8200 } | 8214 } |
| 8201 } else if (primary->primary().IsTypeParameter()) { | 8215 } else if (primary->primary().IsTypeParameter()) { |
| 8202 const String& name = String::ZoneHandle( | 8216 const String& name = String::ZoneHandle( |
| 8203 Symbols::New(primary->Name())); | 8217 Symbols::New(primary->Name())); |
| 8204 selector = ThrowNoSuchMethodError(primary->token_pos(), | 8218 selector = ThrowNoSuchMethodError(primary->token_pos(), |
| 8205 current_class(), | 8219 current_class(), |
| 8206 name, | 8220 name, |
| 8221 NULL, // No arguments. |
| 8207 InvocationMirror::kStatic, | 8222 InvocationMirror::kStatic, |
| 8208 InvocationMirror::kMethod); | 8223 InvocationMirror::kMethod); |
| 8209 } else if (primary->primary().IsClass()) { | 8224 } else if (primary->primary().IsClass()) { |
| 8210 const Class& type_class = Class::Cast(primary->primary()); | 8225 const Class& type_class = Class::Cast(primary->primary()); |
| 8211 Type& type = Type::ZoneHandle( | 8226 Type& type = Type::ZoneHandle( |
| 8212 Type::New(type_class, TypeArguments::Handle(), | 8227 Type::New(type_class, TypeArguments::Handle(), |
| 8213 primary->token_pos(), Heap::kOld)); | 8228 primary->token_pos(), Heap::kOld)); |
| 8214 type ^= ClassFinalizer::FinalizeType( | 8229 type ^= ClassFinalizer::FinalizeType( |
| 8215 current_class(), type, ClassFinalizer::kCanonicalize); | 8230 current_class(), type, ClassFinalizer::kCanonicalize); |
| 8216 ASSERT(!type.IsMalformed()); | 8231 ASSERT(!type.IsMalformed()); |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9095 if (primary->primary().IsString()) { | 9110 if (primary->primary().IsString()) { |
| 9096 // We got an unresolved name. If we are compiling a static | 9111 // We got an unresolved name. If we are compiling a static |
| 9097 // method, evaluation of an unresolved identifier causes a | 9112 // method, evaluation of an unresolved identifier causes a |
| 9098 // NoSuchMethodError to be thrown. In an instance method, we convert | 9113 // NoSuchMethodError to be thrown. In an instance method, we convert |
| 9099 // the unresolved name to an instance field access, since a | 9114 // the unresolved name to an instance field access, since a |
| 9100 // subclass might define a field with this name. | 9115 // subclass might define a field with this name. |
| 9101 if (current_function().is_static()) { | 9116 if (current_function().is_static()) { |
| 9102 resolved = ThrowNoSuchMethodError(ident_pos, | 9117 resolved = ThrowNoSuchMethodError(ident_pos, |
| 9103 current_class(), | 9118 current_class(), |
| 9104 ident, | 9119 ident, |
| 9120 NULL, // No arguments. |
| 9105 InvocationMirror::kStatic, | 9121 InvocationMirror::kStatic, |
| 9106 InvocationMirror::kField); | 9122 InvocationMirror::kField); |
| 9107 } else { | 9123 } else { |
| 9108 // Treat as call to unresolved instance field. | 9124 // Treat as call to unresolved instance field. |
| 9109 resolved = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); | 9125 resolved = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); |
| 9110 } | 9126 } |
| 9111 } else if (primary->primary().IsFunction()) { | 9127 } else if (primary->primary().IsFunction()) { |
| 9112 if (allow_closure_names) { | 9128 if (allow_closure_names) { |
| 9113 resolved = LoadClosure(primary); | 9129 resolved = LoadClosure(primary); |
| 9114 } else { | 9130 } else { |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9752 call_pos, | 9768 call_pos, |
| 9753 "class '%s' has no constructor or factory named '%s'", | 9769 "class '%s' has no constructor or factory named '%s'", |
| 9754 String::Handle(type_class.Name()).ToCString(), | 9770 String::Handle(type_class.Name()).ToCString(), |
| 9755 external_constructor_name.ToCString()); | 9771 external_constructor_name.ToCString()); |
| 9756 const Error& error = Error::Handle(type.malformed_error()); | 9772 const Error& error = Error::Handle(type.malformed_error()); |
| 9757 ErrorMsg(error); | 9773 ErrorMsg(error); |
| 9758 } | 9774 } |
| 9759 return ThrowNoSuchMethodError(call_pos, | 9775 return ThrowNoSuchMethodError(call_pos, |
| 9760 type_class, | 9776 type_class, |
| 9761 external_constructor_name, | 9777 external_constructor_name, |
| 9778 arguments, |
| 9762 InvocationMirror::kConstructor, | 9779 InvocationMirror::kConstructor, |
| 9763 InvocationMirror::kMethod); | 9780 InvocationMirror::kMethod); |
| 9764 } else if (constructor.IsRedirectingFactory()) { | 9781 } else if (constructor.IsRedirectingFactory()) { |
| 9765 ClassFinalizer::ResolveRedirectingFactory(type_class, constructor); | 9782 ClassFinalizer::ResolveRedirectingFactory(type_class, constructor); |
| 9766 Type& redirect_type = Type::Handle(constructor.RedirectionType()); | 9783 Type& redirect_type = Type::Handle(constructor.RedirectionType()); |
| 9767 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) { | 9784 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) { |
| 9768 // The type arguments of the redirection type are instantiated from the | 9785 // The type arguments of the redirection type are instantiated from the |
| 9769 // type arguments of the parsed type of the 'new' or 'const' expression. | 9786 // type arguments of the parsed type of the 'new' or 'const' expression. |
| 9770 Error& malformed_error = Error::Handle(); | 9787 Error& malformed_error = Error::Handle(); |
| 9771 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, | 9788 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9819 ErrorMsg(call_pos, | 9836 ErrorMsg(call_pos, |
| 9820 "invalid arguments passed to constructor '%s' " | 9837 "invalid arguments passed to constructor '%s' " |
| 9821 "for class '%s': %s", | 9838 "for class '%s': %s", |
| 9822 external_constructor_name.ToCString(), | 9839 external_constructor_name.ToCString(), |
| 9823 String::Handle(type_class.Name()).ToCString(), | 9840 String::Handle(type_class.Name()).ToCString(), |
| 9824 error_message.ToCString()); | 9841 error_message.ToCString()); |
| 9825 } | 9842 } |
| 9826 return ThrowNoSuchMethodError(call_pos, | 9843 return ThrowNoSuchMethodError(call_pos, |
| 9827 type_class, | 9844 type_class, |
| 9828 external_constructor_name, | 9845 external_constructor_name, |
| 9846 arguments, |
| 9829 InvocationMirror::kConstructor, | 9847 InvocationMirror::kConstructor, |
| 9830 InvocationMirror::kMethod); | 9848 InvocationMirror::kMethod); |
| 9831 } | 9849 } |
| 9832 | 9850 |
| 9833 // Return a throw in case of a malformed type or report a compile-time error | 9851 // Return a throw in case of a malformed type or report a compile-time error |
| 9834 // if the constructor is const. | 9852 // if the constructor is const. |
| 9835 if (type.IsMalformed()) { | 9853 if (type.IsMalformed()) { |
| 9836 if (is_const) { | 9854 if (is_const) { |
| 9837 const Error& error = Error::Handle(type.malformed_error()); | 9855 const Error& error = Error::Handle(type.malformed_error()); |
| 9838 ErrorMsg(error); | 9856 ErrorMsg(error); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10472 void Parser::SkipQualIdent() { | 10490 void Parser::SkipQualIdent() { |
| 10473 ASSERT(IsIdentifier()); | 10491 ASSERT(IsIdentifier()); |
| 10474 ConsumeToken(); | 10492 ConsumeToken(); |
| 10475 if (CurrentToken() == Token::kPERIOD) { | 10493 if (CurrentToken() == Token::kPERIOD) { |
| 10476 ConsumeToken(); // Consume the kPERIOD token. | 10494 ConsumeToken(); // Consume the kPERIOD token. |
| 10477 ExpectIdentifier("identifier expected after '.'"); | 10495 ExpectIdentifier("identifier expected after '.'"); |
| 10478 } | 10496 } |
| 10479 } | 10497 } |
| 10480 | 10498 |
| 10481 } // namespace dart | 10499 } // namespace dart |
| OLD | NEW |