Chromium Code Reviews| Index: runtime/vm/dart_entry.h |
| diff --git a/runtime/vm/dart_entry.h b/runtime/vm/dart_entry.h |
| index 8e130ddebf623eb1b330eb46906c72d7909cc66f..88465c7a2c06217ebf9ca7220ec8a693a4c860ba 100644 |
| --- a/runtime/vm/dart_entry.h |
| +++ b/runtime/vm/dart_entry.h |
| @@ -19,10 +19,63 @@ class Instance; |
| class Integer; |
| class Library; |
| class Object; |
| +class RawArray; |
| class RawInstance; |
| class RawObject; |
| class String; |
| +// An arguments descriptor array consists of the total argument count; the |
| +// positional argument count; a sequence of (name, position) pairs, sorted |
| +// by name, for each named optional argument; and a terminating null to |
| +// simplify iterating in generated code. |
| +class ArgumentsDescriptor : public ValueObject { |
| + public: |
| + explicit ArgumentsDescriptor(RawObject* array); |
|
srdjan
2012/12/05 18:27:52
NEVER pass a raw object as argument, only handles.
regis
2012/12/05 18:39:24
You should never pass a RawObject pointer as param
Kevin Millikin (Google)
2012/12/05 19:11:23
Well, that's obviously a qualified NEVER, because
srdjan
2012/12/05 19:34:17
Yes, it is a general rule, it should be deviated f
|
| + |
| + // Accessors. |
| + intptr_t Count() const; |
|
regis
2012/12/05 18:39:24
Currently, we name integer variables holding a cou
Kevin Millikin (Google)
2012/12/05 19:11:23
I know bit it drives me nuts. It directly contrad
srdjan
2012/12/05 19:34:17
The most important thing is to be consistent, pick
|
| + intptr_t PositionalCount() const; |
| + intptr_t NamedCount() const { return Count() - PositionalCount(); } |
| + RawObject* NameAt(intptr_t index) const; |
|
srdjan
2012/12/05 18:27:52
Maybe this should be RawString*?
Kevin Millikin (Google)
2012/12/05 19:11:23
It's too annoying, because we don't have a simple
srdjan
2012/12/05 19:34:17
It is a weird API. We know we can return only RawS
|
| + |
| + // Generated code support. |
| + static intptr_t count_offset(); |
| + static intptr_t positional_count_offset(); |
| + static intptr_t first_named_entry_offset(); |
| + static intptr_t name_offset() { return kNameOffset * kWordSize; } |
| + static intptr_t position_offset() { return kPositionOffset * kWordSize; } |
| + static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; } |
| + |
| + // Allocate and return an arguments descriptor. The first |
| + // (count - optional_arguments_names.Length()) arguments are |
| + // positional and the remaining ones are named optional arguments. |
| + static RawArray* New(intptr_t count, |
| + const Array& optional_arguments_names); |
| + |
| + private: |
| + // Absolute indexes into the array. |
| + enum { |
| + kCountIndex, |
| + kPositionalCountIndex, |
| + kFirstNamedEntryIndex, |
| + }; |
| + |
| + // Relative indexes into each named argument entry. |
| + enum { |
| + kNameOffset, |
| + kPositionOffset, |
| + kNamedEntrySize, |
| + }; |
| + |
| + static intptr_t LengthFor(intptr_t count) { |
| + // Add 1 for the terminating null. |
| + return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; |
| + } |
| + |
| + const Array& array_; |
|
srdjan
2012/12/05 18:27:52
Add DISALLOW_YADA_YADA
|
| +}; |
| + |
| + |
| // DartEntry abstracts functionality needed to resolve dart functions |
| // and invoke them from C++. |
| class DartEntry : public AllStatic { |
| @@ -54,14 +107,6 @@ class DartEntry : public AllStatic { |
| const Instance& closure, |
| const GrowableArray<const Object*>& arguments, |
| const Array& optional_arguments_names); |
| - |
| - // Allocate and return an arguments descriptor. |
| - // Let 'num_names' be the length of 'optional_arguments_names'. |
| - // Treat the first 'num_arguments - num_names' arguments as positional and |
| - // treat the following 'num_names' arguments as named optional arguments. |
| - static const Array& ArgumentsDescriptor( |
| - int num_arguments, |
| - const Array& optional_arguments_names); |
| }; |