OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/dart_entry.h" | 5 #include "vm/dart_entry.h" |
6 | 6 |
7 #include "vm/code_generator.h" | 7 #include "vm/code_generator.h" |
8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
10 #include "vm/resolver.h" | 10 #include "vm/resolver.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 Array& descriptor = Array::Handle(Array::New(descriptor_len, Heap::kOld)); | 240 Array& descriptor = Array::Handle(Array::New(descriptor_len, Heap::kOld)); |
241 | 241 |
242 // Set total number of passed arguments. | 242 // Set total number of passed arguments. |
243 descriptor.SetAt(kCountIndex, Smi::Handle(Smi::New(num_arguments))); | 243 descriptor.SetAt(kCountIndex, Smi::Handle(Smi::New(num_arguments))); |
244 // Set number of positional arguments. | 244 // Set number of positional arguments. |
245 descriptor.SetAt(kPositionalCountIndex, Smi::Handle(Smi::New(num_pos_args))); | 245 descriptor.SetAt(kPositionalCountIndex, Smi::Handle(Smi::New(num_pos_args))); |
246 // Set alphabetically sorted entries for named arguments. | 246 // Set alphabetically sorted entries for named arguments. |
247 String& name = String::Handle(); | 247 String& name = String::Handle(); |
248 Smi& pos = Smi::Handle(); | 248 Smi& pos = Smi::Handle(); |
249 for (intptr_t i = 0; i < num_named_args; i++) { | 249 for (intptr_t i = 0; i < num_named_args; i++) { |
250 name ^= optional_arguments_names.At(i); | 250 name |= optional_arguments_names.At(i); |
251 pos = Smi::New(num_pos_args + i); | 251 pos = Smi::New(num_pos_args + i); |
252 intptr_t insert_index = kFirstNamedEntryIndex + (kNamedEntrySize * i); | 252 intptr_t insert_index = kFirstNamedEntryIndex + (kNamedEntrySize * i); |
253 // Shift already inserted pairs with "larger" names. | 253 // Shift already inserted pairs with "larger" names. |
254 String& previous_name = String::Handle(); | 254 String& previous_name = String::Handle(); |
255 Smi& previous_pos = Smi::Handle(); | 255 Smi& previous_pos = Smi::Handle(); |
256 while (insert_index > kFirstNamedEntryIndex) { | 256 while (insert_index > kFirstNamedEntryIndex) { |
257 intptr_t previous_index = insert_index - kNamedEntrySize; | 257 intptr_t previous_index = insert_index - kNamedEntrySize; |
258 previous_name ^= descriptor.At(previous_index + kNameOffset); | 258 previous_name |= descriptor.At(previous_index + kNameOffset); |
259 intptr_t result = name.CompareTo(previous_name); | 259 intptr_t result = name.CompareTo(previous_name); |
260 ASSERT(result != 0); // Duplicate argument names checked in parser. | 260 ASSERT(result != 0); // Duplicate argument names checked in parser. |
261 if (result > 0) break; | 261 if (result > 0) break; |
262 previous_pos ^= descriptor.At(previous_index + kPositionOffset); | 262 previous_pos |= descriptor.At(previous_index + kPositionOffset); |
263 descriptor.SetAt(insert_index + kNameOffset, previous_name); | 263 descriptor.SetAt(insert_index + kNameOffset, previous_name); |
264 descriptor.SetAt(insert_index + kPositionOffset, previous_pos); | 264 descriptor.SetAt(insert_index + kPositionOffset, previous_pos); |
265 insert_index = previous_index; | 265 insert_index = previous_index; |
266 } | 266 } |
267 // Insert pair in descriptor array. | 267 // Insert pair in descriptor array. |
268 descriptor.SetAt(insert_index + kNameOffset, name); | 268 descriptor.SetAt(insert_index + kNameOffset, name); |
269 descriptor.SetAt(insert_index + kPositionOffset, pos); | 269 descriptor.SetAt(insert_index + kPositionOffset, pos); |
270 } | 270 } |
271 // Set terminating null. | 271 // Set terminating null. |
272 descriptor.SetAt(descriptor_len - 1, Object::Handle()); | 272 descriptor.SetAt(descriptor_len - 1, Object::Handle()); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 String::Handle(Field::GetterName(Symbols::_id())))); | 506 String::Handle(Field::GetterName(Symbols::_id())))); |
507 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 507 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
508 ASSERT(!func.IsNull()); | 508 ASSERT(!func.IsNull()); |
509 const Array& args = Array::Handle(Array::New(1)); | 509 const Array& args = Array::Handle(Array::New(1)); |
510 args.SetAt(0, port); | 510 args.SetAt(0, port); |
511 return DartEntry::InvokeDynamic(func, args); | 511 return DartEntry::InvokeDynamic(func, args); |
512 } | 512 } |
513 | 513 |
514 | 514 |
515 } // namespace dart | 515 } // namespace dart |
OLD | NEW |