Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: runtime/vm/object.cc

Issue 2859673002: Pass type argument vector to generic functions (if --reify-generic-functions is (Closed)
Patch Set: address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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()) {
4816 return 0;
4817 }
4816 return Smi::Value(raw_ptr()->length_); 4818 return Smi::Value(raw_ptr()->length_);
4817 } 4819 }
4818 4820
4819 4821
4820 RawAbstractType* TypeArguments::TypeAt(intptr_t index) const { 4822 RawAbstractType* TypeArguments::TypeAt(intptr_t index) const {
4821 return *TypeAddr(index); 4823 return *TypeAddr(index);
4822 } 4824 }
4823 4825
4824 4826
4825 void TypeArguments::SetTypeAt(intptr_t index, const AbstractType& value) const { 4827 void TypeArguments::SetTypeAt(intptr_t index, const AbstractType& value) const {
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
6187 // marked as non-static, but they do not have a receiver. 6189 // marked as non-static, but they do not have a receiver.
6188 // Closures are handled above. 6190 // Closures are handled above.
6189 ASSERT((kind() != RawFunction::kClosureFunction) && 6191 ASSERT((kind() != RawFunction::kClosureFunction) &&
6190 (kind() != RawFunction::kSignatureFunction)); 6192 (kind() != RawFunction::kSignatureFunction));
6191 return 1; // Receiver. 6193 return 1; // Receiver.
6192 } 6194 }
6193 return 0; // No implicit parameters. 6195 return 0; // No implicit parameters.
6194 } 6196 }
6195 6197
6196 6198
6197 bool Function::AreValidArgumentCounts(intptr_t num_arguments, 6199 bool Function::AreValidArgumentCounts(intptr_t num_type_arguments,
6200 intptr_t num_arguments,
6198 intptr_t num_named_arguments, 6201 intptr_t num_named_arguments,
6199 String* error_message) const { 6202 String* error_message) const {
6203 if ((num_type_arguments != 0) &&
6204 (num_type_arguments != NumTypeParameters())) {
6205 if (error_message != NULL) {
6206 const intptr_t kMessageBufferSize = 64;
6207 char message_buffer[kMessageBufferSize];
6208 OS::SNPrint(message_buffer, kMessageBufferSize,
6209 "%" Pd " type arguments passed, but %" Pd " expected",
6210 num_type_arguments, NumTypeParameters());
6211 // Allocate in old space because it can be invoked in background
6212 // optimizing compilation.
6213 *error_message = String::New(message_buffer, Heap::kOld);
6214 }
6215 return false; // Too many type arguments.
6216 }
6200 if (num_named_arguments > NumOptionalNamedParameters()) { 6217 if (num_named_arguments > NumOptionalNamedParameters()) {
6201 if (error_message != NULL) { 6218 if (error_message != NULL) {
6202 const intptr_t kMessageBufferSize = 64; 6219 const intptr_t kMessageBufferSize = 64;
6203 char message_buffer[kMessageBufferSize]; 6220 char message_buffer[kMessageBufferSize];
6204 OS::SNPrint(message_buffer, kMessageBufferSize, 6221 OS::SNPrint(message_buffer, kMessageBufferSize,
6205 "%" Pd " named passed, at most %" Pd " expected", 6222 "%" Pd " named passed, at most %" Pd " expected",
6206 num_named_arguments, NumOptionalNamedParameters()); 6223 num_named_arguments, NumOptionalNamedParameters());
6207 // Allocate in old space because it can be invoked in background 6224 // Allocate in old space because it can be invoked in background
6208 // optimizing compilation. 6225 // optimizing compilation.
6209 *error_message = String::New(message_buffer, Heap::kOld); 6226 *error_message = String::New(message_buffer, Heap::kOld);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6246 // Allocate in old space because it can be invoked in background 6263 // Allocate in old space because it can be invoked in background
6247 // optimizing compilation. 6264 // optimizing compilation.
6248 *error_message = String::New(message_buffer, Heap::kOld); 6265 *error_message = String::New(message_buffer, Heap::kOld);
6249 } 6266 }
6250 return false; // Too few fixed and/or positional arguments. 6267 return false; // Too few fixed and/or positional arguments.
6251 } 6268 }
6252 return true; 6269 return true;
6253 } 6270 }
6254 6271
6255 6272
6256 bool Function::AreValidArguments(intptr_t num_arguments, 6273 bool Function::AreValidArguments(intptr_t num_type_arguments,
6274 intptr_t num_arguments,
6257 const Array& argument_names, 6275 const Array& argument_names,
6258 String* error_message) const { 6276 String* error_message) const {
6259 const intptr_t num_named_arguments = 6277 const intptr_t num_named_arguments =
6260 argument_names.IsNull() ? 0 : argument_names.Length(); 6278 argument_names.IsNull() ? 0 : argument_names.Length();
6261 if (!AreValidArgumentCounts(num_arguments, num_named_arguments, 6279 if (!AreValidArgumentCounts(num_type_arguments, num_arguments,
6262 error_message)) { 6280 num_named_arguments, error_message)) {
6263 return false; 6281 return false;
6264 } 6282 }
6265 // Verify that all argument names are valid parameter names. 6283 // Verify that all argument names are valid parameter names.
6266 Zone* zone = Thread::Current()->zone(); 6284 Zone* zone = Thread::Current()->zone();
6267 String& argument_name = String::Handle(zone); 6285 String& argument_name = String::Handle(zone);
6268 String& parameter_name = String::Handle(zone); 6286 String& parameter_name = String::Handle(zone);
6269 for (intptr_t i = 0; i < num_named_arguments; i++) { 6287 for (intptr_t i = 0; i < num_named_arguments; i++) {
6270 argument_name ^= argument_names.At(i); 6288 argument_name ^= argument_names.At(i);
6271 ASSERT(argument_name.IsSymbol()); 6289 ASSERT(argument_name.IsSymbol());
6272 bool found = false; 6290 bool found = false;
(...skipping 20 matching lines...) Expand all
6293 } 6311 }
6294 return false; 6312 return false;
6295 } 6313 }
6296 } 6314 }
6297 return true; 6315 return true;
6298 } 6316 }
6299 6317
6300 6318
6301 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, 6319 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc,
6302 String* error_message) const { 6320 String* error_message) const {
6321 const intptr_t num_type_arguments = args_desc.TypeArgsLen();
6303 const intptr_t num_arguments = args_desc.Count(); 6322 const intptr_t num_arguments = args_desc.Count();
6304 const intptr_t num_named_arguments = args_desc.NamedCount(); 6323 const intptr_t num_named_arguments = args_desc.NamedCount();
6305 6324
6306 if (!AreValidArgumentCounts(num_arguments, num_named_arguments, 6325 if (!AreValidArgumentCounts(num_type_arguments, num_arguments,
6307 error_message)) { 6326 num_named_arguments, error_message)) {
6308 return false; 6327 return false;
6309 } 6328 }
6310 // Verify that all argument names are valid parameter names. 6329 // Verify that all argument names are valid parameter names.
6311 Zone* zone = Thread::Current()->zone(); 6330 Zone* zone = Thread::Current()->zone();
6312 String& argument_name = String::Handle(zone); 6331 String& argument_name = String::Handle(zone);
6313 String& parameter_name = String::Handle(zone); 6332 String& parameter_name = String::Handle(zone);
6314 for (intptr_t i = 0; i < num_named_arguments; i++) { 6333 for (intptr_t i = 0; i < num_named_arguments; i++) {
6315 argument_name ^= args_desc.NameAt(i); 6334 argument_name ^= args_desc.NameAt(i);
6316 ASSERT(argument_name.IsSymbol()); 6335 ASSERT(argument_name.IsSymbol());
6317 bool found = false; 6336 bool found = false;
(...skipping 17002 matching lines...) Expand 10 before | Expand all | Expand 10 after
23320 return UserTag::null(); 23339 return UserTag::null();
23321 } 23340 }
23322 23341
23323 23342
23324 const char* UserTag::ToCString() const { 23343 const char* UserTag::ToCString() const {
23325 const String& tag_label = String::Handle(label()); 23344 const String& tag_label = String::Handle(label());
23326 return tag_label.ToCString(); 23345 return tag_label.ToCString();
23327 } 23346 }
23328 23347
23329 } // namespace dart 23348 } // namespace dart
OLDNEW
« runtime/lib/mirrors.cc ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698