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 4794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4805 } | 4805 } |
4806 | 4806 |
4807 | 4807 |
4808 void TypeArguments::set_instantiations(const Array& value) const { | 4808 void TypeArguments::set_instantiations(const Array& value) const { |
4809 ASSERT(!value.IsNull()); | 4809 ASSERT(!value.IsNull()); |
4810 StorePointer(&raw_ptr()->instantiations_, value.raw()); | 4810 StorePointer(&raw_ptr()->instantiations_, value.raw()); |
4811 } | 4811 } |
4812 | 4812 |
4813 | 4813 |
4814 intptr_t TypeArguments::Length() const { | 4814 intptr_t TypeArguments::Length() const { |
4815 ASSERT(!IsNull()); | 4815 if (IsNull()) return 0; |
zra
2017/05/03 15:03:25
Please use curly braces.
regis
2017/05/09 18:31:23
Done.
| |
4816 return Smi::Value(raw_ptr()->length_); | 4816 return Smi::Value(raw_ptr()->length_); |
4817 } | 4817 } |
4818 | 4818 |
4819 | 4819 |
4820 RawAbstractType* TypeArguments::TypeAt(intptr_t index) const { | 4820 RawAbstractType* TypeArguments::TypeAt(intptr_t index) const { |
4821 return *TypeAddr(index); | 4821 return *TypeAddr(index); |
4822 } | 4822 } |
4823 | 4823 |
4824 | 4824 |
4825 void TypeArguments::SetTypeAt(intptr_t index, const AbstractType& value) const { | 4825 void TypeArguments::SetTypeAt(intptr_t index, const AbstractType& value) const { |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6187 // marked as non-static, but they do not have a receiver. | 6187 // marked as non-static, but they do not have a receiver. |
6188 // Closures are handled above. | 6188 // Closures are handled above. |
6189 ASSERT((kind() != RawFunction::kClosureFunction) && | 6189 ASSERT((kind() != RawFunction::kClosureFunction) && |
6190 (kind() != RawFunction::kSignatureFunction)); | 6190 (kind() != RawFunction::kSignatureFunction)); |
6191 return 1; // Receiver. | 6191 return 1; // Receiver. |
6192 } | 6192 } |
6193 return 0; // No implicit parameters. | 6193 return 0; // No implicit parameters. |
6194 } | 6194 } |
6195 | 6195 |
6196 | 6196 |
6197 bool Function::AreValidArgumentCounts(intptr_t num_arguments, | 6197 bool Function::AreValidArgumentCounts(intptr_t num_type_arguments, |
6198 intptr_t num_arguments, | |
6198 intptr_t num_named_arguments, | 6199 intptr_t num_named_arguments, |
6199 String* error_message) const { | 6200 String* error_message) const { |
6201 if ((num_type_arguments != 0) && | |
6202 (num_type_arguments != NumTypeParameters())) { | |
6203 if (error_message != NULL) { | |
6204 const intptr_t kMessageBufferSize = 64; | |
6205 char message_buffer[kMessageBufferSize]; | |
6206 OS::SNPrint(message_buffer, kMessageBufferSize, | |
6207 "%" Pd " type arguments passed, but %" Pd " expected", | |
6208 num_type_arguments, NumTypeParameters()); | |
6209 // Allocate in old space because it can be invoked in background | |
6210 // optimizing compilation. | |
6211 *error_message = String::New(message_buffer, Heap::kOld); | |
6212 } | |
6213 return false; // Too many type arguments. | |
6214 } | |
6200 if (num_named_arguments > NumOptionalNamedParameters()) { | 6215 if (num_named_arguments > NumOptionalNamedParameters()) { |
6201 if (error_message != NULL) { | 6216 if (error_message != NULL) { |
6202 const intptr_t kMessageBufferSize = 64; | 6217 const intptr_t kMessageBufferSize = 64; |
6203 char message_buffer[kMessageBufferSize]; | 6218 char message_buffer[kMessageBufferSize]; |
6204 OS::SNPrint(message_buffer, kMessageBufferSize, | 6219 OS::SNPrint(message_buffer, kMessageBufferSize, |
6205 "%" Pd " named passed, at most %" Pd " expected", | 6220 "%" Pd " named passed, at most %" Pd " expected", |
6206 num_named_arguments, NumOptionalNamedParameters()); | 6221 num_named_arguments, NumOptionalNamedParameters()); |
6207 // Allocate in old space because it can be invoked in background | 6222 // Allocate in old space because it can be invoked in background |
6208 // optimizing compilation. | 6223 // optimizing compilation. |
6209 *error_message = String::New(message_buffer, Heap::kOld); | 6224 *error_message = String::New(message_buffer, Heap::kOld); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6246 // Allocate in old space because it can be invoked in background | 6261 // Allocate in old space because it can be invoked in background |
6247 // optimizing compilation. | 6262 // optimizing compilation. |
6248 *error_message = String::New(message_buffer, Heap::kOld); | 6263 *error_message = String::New(message_buffer, Heap::kOld); |
6249 } | 6264 } |
6250 return false; // Too few fixed and/or positional arguments. | 6265 return false; // Too few fixed and/or positional arguments. |
6251 } | 6266 } |
6252 return true; | 6267 return true; |
6253 } | 6268 } |
6254 | 6269 |
6255 | 6270 |
6256 bool Function::AreValidArguments(intptr_t num_arguments, | 6271 bool Function::AreValidArguments(intptr_t num_type_arguments, |
6272 intptr_t num_arguments, | |
6257 const Array& argument_names, | 6273 const Array& argument_names, |
6258 String* error_message) const { | 6274 String* error_message) const { |
6259 const intptr_t num_named_arguments = | 6275 const intptr_t num_named_arguments = |
6260 argument_names.IsNull() ? 0 : argument_names.Length(); | 6276 argument_names.IsNull() ? 0 : argument_names.Length(); |
6261 if (!AreValidArgumentCounts(num_arguments, num_named_arguments, | 6277 if (!AreValidArgumentCounts(num_type_arguments, num_arguments, |
6262 error_message)) { | 6278 num_named_arguments, error_message)) { |
6263 return false; | 6279 return false; |
6264 } | 6280 } |
6265 // Verify that all argument names are valid parameter names. | 6281 // Verify that all argument names are valid parameter names. |
6266 Zone* zone = Thread::Current()->zone(); | 6282 Zone* zone = Thread::Current()->zone(); |
6267 String& argument_name = String::Handle(zone); | 6283 String& argument_name = String::Handle(zone); |
6268 String& parameter_name = String::Handle(zone); | 6284 String& parameter_name = String::Handle(zone); |
6269 for (intptr_t i = 0; i < num_named_arguments; i++) { | 6285 for (intptr_t i = 0; i < num_named_arguments; i++) { |
6270 argument_name ^= argument_names.At(i); | 6286 argument_name ^= argument_names.At(i); |
6271 ASSERT(argument_name.IsSymbol()); | 6287 ASSERT(argument_name.IsSymbol()); |
6272 bool found = false; | 6288 bool found = false; |
(...skipping 20 matching lines...) Expand all Loading... | |
6293 } | 6309 } |
6294 return false; | 6310 return false; |
6295 } | 6311 } |
6296 } | 6312 } |
6297 return true; | 6313 return true; |
6298 } | 6314 } |
6299 | 6315 |
6300 | 6316 |
6301 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, | 6317 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, |
6302 String* error_message) const { | 6318 String* error_message) const { |
6319 const intptr_t num_type_arguments = args_desc.TypeArgsLen(); | |
6303 const intptr_t num_arguments = args_desc.Count(); | 6320 const intptr_t num_arguments = args_desc.Count(); |
6304 const intptr_t num_named_arguments = args_desc.NamedCount(); | 6321 const intptr_t num_named_arguments = args_desc.NamedCount(); |
6305 | 6322 |
6306 if (!AreValidArgumentCounts(num_arguments, num_named_arguments, | 6323 if (!AreValidArgumentCounts(num_type_arguments, num_arguments, |
6307 error_message)) { | 6324 num_named_arguments, error_message)) { |
6308 return false; | 6325 return false; |
6309 } | 6326 } |
6310 // Verify that all argument names are valid parameter names. | 6327 // Verify that all argument names are valid parameter names. |
6311 Zone* zone = Thread::Current()->zone(); | 6328 Zone* zone = Thread::Current()->zone(); |
6312 String& argument_name = String::Handle(zone); | 6329 String& argument_name = String::Handle(zone); |
6313 String& parameter_name = String::Handle(zone); | 6330 String& parameter_name = String::Handle(zone); |
6314 for (intptr_t i = 0; i < num_named_arguments; i++) { | 6331 for (intptr_t i = 0; i < num_named_arguments; i++) { |
6315 argument_name ^= args_desc.NameAt(i); | 6332 argument_name ^= args_desc.NameAt(i); |
6316 ASSERT(argument_name.IsSymbol()); | 6333 ASSERT(argument_name.IsSymbol()); |
6317 bool found = false; | 6334 bool found = false; |
(...skipping 17002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
23320 return UserTag::null(); | 23337 return UserTag::null(); |
23321 } | 23338 } |
23322 | 23339 |
23323 | 23340 |
23324 const char* UserTag::ToCString() const { | 23341 const char* UserTag::ToCString() const { |
23325 const String& tag_label = String::Handle(label()); | 23342 const String& tag_label = String::Handle(label()); |
23326 return tag_label.ToCString(); | 23343 return tag_label.ToCString(); |
23327 } | 23344 } |
23328 | 23345 |
23329 } // namespace dart | 23346 } // namespace dart |
OLD | NEW |