| 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/become.h" | 10 #include "vm/become.h" |
| (...skipping 4798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4809 } | 4809 } |
| 4810 | 4810 |
| 4811 | 4811 |
| 4812 void TypeArguments::set_instantiations(const Array& value) const { | 4812 void TypeArguments::set_instantiations(const Array& value) const { |
| 4813 ASSERT(!value.IsNull()); | 4813 ASSERT(!value.IsNull()); |
| 4814 StorePointer(&raw_ptr()->instantiations_, value.raw()); | 4814 StorePointer(&raw_ptr()->instantiations_, value.raw()); |
| 4815 } | 4815 } |
| 4816 | 4816 |
| 4817 | 4817 |
| 4818 intptr_t TypeArguments::Length() const { | 4818 intptr_t TypeArguments::Length() const { |
| 4819 ASSERT(!IsNull()); | 4819 if (IsNull()) { |
| 4820 return 0; |
| 4821 } |
| 4820 return Smi::Value(raw_ptr()->length_); | 4822 return Smi::Value(raw_ptr()->length_); |
| 4821 } | 4823 } |
| 4822 | 4824 |
| 4823 | 4825 |
| 4824 RawAbstractType* TypeArguments::TypeAt(intptr_t index) const { | 4826 RawAbstractType* TypeArguments::TypeAt(intptr_t index) const { |
| 4825 return *TypeAddr(index); | 4827 return *TypeAddr(index); |
| 4826 } | 4828 } |
| 4827 | 4829 |
| 4828 | 4830 |
| 4829 void TypeArguments::SetTypeAt(intptr_t index, const AbstractType& value) const { | 4831 void TypeArguments::SetTypeAt(intptr_t index, const AbstractType& value) const { |
| (...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6191 // marked as non-static, but they do not have a receiver. | 6193 // marked as non-static, but they do not have a receiver. |
| 6192 // Closures are handled above. | 6194 // Closures are handled above. |
| 6193 ASSERT((kind() != RawFunction::kClosureFunction) && | 6195 ASSERT((kind() != RawFunction::kClosureFunction) && |
| 6194 (kind() != RawFunction::kSignatureFunction)); | 6196 (kind() != RawFunction::kSignatureFunction)); |
| 6195 return 1; // Receiver. | 6197 return 1; // Receiver. |
| 6196 } | 6198 } |
| 6197 return 0; // No implicit parameters. | 6199 return 0; // No implicit parameters. |
| 6198 } | 6200 } |
| 6199 | 6201 |
| 6200 | 6202 |
| 6201 bool Function::AreValidArgumentCounts(intptr_t num_arguments, | 6203 bool Function::AreValidArgumentCounts(intptr_t num_type_arguments, |
| 6204 intptr_t num_arguments, |
| 6202 intptr_t num_named_arguments, | 6205 intptr_t num_named_arguments, |
| 6203 String* error_message) const { | 6206 String* error_message) const { |
| 6207 if ((num_type_arguments != 0) && |
| 6208 (num_type_arguments != NumTypeParameters())) { |
| 6209 if (error_message != NULL) { |
| 6210 const intptr_t kMessageBufferSize = 64; |
| 6211 char message_buffer[kMessageBufferSize]; |
| 6212 OS::SNPrint(message_buffer, kMessageBufferSize, |
| 6213 "%" Pd " type arguments passed, but %" Pd " expected", |
| 6214 num_type_arguments, NumTypeParameters()); |
| 6215 // Allocate in old space because it can be invoked in background |
| 6216 // optimizing compilation. |
| 6217 *error_message = String::New(message_buffer, Heap::kOld); |
| 6218 } |
| 6219 return false; // Too many type arguments. |
| 6220 } |
| 6204 if (num_named_arguments > NumOptionalNamedParameters()) { | 6221 if (num_named_arguments > NumOptionalNamedParameters()) { |
| 6205 if (error_message != NULL) { | 6222 if (error_message != NULL) { |
| 6206 const intptr_t kMessageBufferSize = 64; | 6223 const intptr_t kMessageBufferSize = 64; |
| 6207 char message_buffer[kMessageBufferSize]; | 6224 char message_buffer[kMessageBufferSize]; |
| 6208 OS::SNPrint(message_buffer, kMessageBufferSize, | 6225 OS::SNPrint(message_buffer, kMessageBufferSize, |
| 6209 "%" Pd " named passed, at most %" Pd " expected", | 6226 "%" Pd " named passed, at most %" Pd " expected", |
| 6210 num_named_arguments, NumOptionalNamedParameters()); | 6227 num_named_arguments, NumOptionalNamedParameters()); |
| 6211 // Allocate in old space because it can be invoked in background | 6228 // Allocate in old space because it can be invoked in background |
| 6212 // optimizing compilation. | 6229 // optimizing compilation. |
| 6213 *error_message = String::New(message_buffer, Heap::kOld); | 6230 *error_message = String::New(message_buffer, Heap::kOld); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6250 // Allocate in old space because it can be invoked in background | 6267 // Allocate in old space because it can be invoked in background |
| 6251 // optimizing compilation. | 6268 // optimizing compilation. |
| 6252 *error_message = String::New(message_buffer, Heap::kOld); | 6269 *error_message = String::New(message_buffer, Heap::kOld); |
| 6253 } | 6270 } |
| 6254 return false; // Too few fixed and/or positional arguments. | 6271 return false; // Too few fixed and/or positional arguments. |
| 6255 } | 6272 } |
| 6256 return true; | 6273 return true; |
| 6257 } | 6274 } |
| 6258 | 6275 |
| 6259 | 6276 |
| 6260 bool Function::AreValidArguments(intptr_t num_arguments, | 6277 bool Function::AreValidArguments(intptr_t num_type_arguments, |
| 6278 intptr_t num_arguments, |
| 6261 const Array& argument_names, | 6279 const Array& argument_names, |
| 6262 String* error_message) const { | 6280 String* error_message) const { |
| 6263 const intptr_t num_named_arguments = | 6281 const intptr_t num_named_arguments = |
| 6264 argument_names.IsNull() ? 0 : argument_names.Length(); | 6282 argument_names.IsNull() ? 0 : argument_names.Length(); |
| 6265 if (!AreValidArgumentCounts(num_arguments, num_named_arguments, | 6283 if (!AreValidArgumentCounts(num_type_arguments, num_arguments, |
| 6266 error_message)) { | 6284 num_named_arguments, error_message)) { |
| 6267 return false; | 6285 return false; |
| 6268 } | 6286 } |
| 6269 // Verify that all argument names are valid parameter names. | 6287 // Verify that all argument names are valid parameter names. |
| 6270 Zone* zone = Thread::Current()->zone(); | 6288 Zone* zone = Thread::Current()->zone(); |
| 6271 String& argument_name = String::Handle(zone); | 6289 String& argument_name = String::Handle(zone); |
| 6272 String& parameter_name = String::Handle(zone); | 6290 String& parameter_name = String::Handle(zone); |
| 6273 for (intptr_t i = 0; i < num_named_arguments; i++) { | 6291 for (intptr_t i = 0; i < num_named_arguments; i++) { |
| 6274 argument_name ^= argument_names.At(i); | 6292 argument_name ^= argument_names.At(i); |
| 6275 ASSERT(argument_name.IsSymbol()); | 6293 ASSERT(argument_name.IsSymbol()); |
| 6276 bool found = false; | 6294 bool found = false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6297 } | 6315 } |
| 6298 return false; | 6316 return false; |
| 6299 } | 6317 } |
| 6300 } | 6318 } |
| 6301 return true; | 6319 return true; |
| 6302 } | 6320 } |
| 6303 | 6321 |
| 6304 | 6322 |
| 6305 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, | 6323 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, |
| 6306 String* error_message) const { | 6324 String* error_message) const { |
| 6325 const intptr_t num_type_arguments = args_desc.TypeArgsLen(); |
| 6307 const intptr_t num_arguments = args_desc.Count(); | 6326 const intptr_t num_arguments = args_desc.Count(); |
| 6308 const intptr_t num_named_arguments = args_desc.NamedCount(); | 6327 const intptr_t num_named_arguments = args_desc.NamedCount(); |
| 6309 | 6328 |
| 6310 if (!AreValidArgumentCounts(num_arguments, num_named_arguments, | 6329 if (!AreValidArgumentCounts(num_type_arguments, num_arguments, |
| 6311 error_message)) { | 6330 num_named_arguments, error_message)) { |
| 6312 return false; | 6331 return false; |
| 6313 } | 6332 } |
| 6314 // Verify that all argument names are valid parameter names. | 6333 // Verify that all argument names are valid parameter names. |
| 6315 Zone* zone = Thread::Current()->zone(); | 6334 Zone* zone = Thread::Current()->zone(); |
| 6316 String& argument_name = String::Handle(zone); | 6335 String& argument_name = String::Handle(zone); |
| 6317 String& parameter_name = String::Handle(zone); | 6336 String& parameter_name = String::Handle(zone); |
| 6318 for (intptr_t i = 0; i < num_named_arguments; i++) { | 6337 for (intptr_t i = 0; i < num_named_arguments; i++) { |
| 6319 argument_name ^= args_desc.NameAt(i); | 6338 argument_name ^= args_desc.NameAt(i); |
| 6320 ASSERT(argument_name.IsSymbol()); | 6339 ASSERT(argument_name.IsSymbol()); |
| 6321 bool found = false; | 6340 bool found = false; |
| (...skipping 17010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23332 return UserTag::null(); | 23351 return UserTag::null(); |
| 23333 } | 23352 } |
| 23334 | 23353 |
| 23335 | 23354 |
| 23336 const char* UserTag::ToCString() const { | 23355 const char* UserTag::ToCString() const { |
| 23337 const String& tag_label = String::Handle(label()); | 23356 const String& tag_label = String::Handle(label()); |
| 23338 return tag_label.ToCString(); | 23357 return tag_label.ToCString(); |
| 23339 } | 23358 } |
| 23340 | 23359 |
| 23341 } // namespace dart | 23360 } // namespace dart |
| OLD | NEW |