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

Side by Side Diff: vm/dart_entry.h

Issue 11613009: Changed the API in DartEntry for invoking dart code from C++ to make it more compatible with the re… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
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 #ifndef VM_DART_ENTRY_H_ 5 #ifndef VM_DART_ENTRY_H_
6 #define VM_DART_ENTRY_H_ 6 #define VM_DART_ENTRY_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 static intptr_t name_offset() { return kNameOffset * kWordSize; } 46 static intptr_t name_offset() { return kNameOffset * kWordSize; }
47 static intptr_t position_offset() { return kPositionOffset * kWordSize; } 47 static intptr_t position_offset() { return kPositionOffset * kWordSize; }
48 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; } 48 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; }
49 49
50 // Allocate and return an arguments descriptor. The first 50 // Allocate and return an arguments descriptor. The first
51 // (count - optional_arguments_names.Length()) arguments are 51 // (count - optional_arguments_names.Length()) arguments are
52 // positional and the remaining ones are named optional arguments. 52 // positional and the remaining ones are named optional arguments.
53 static RawArray* New(intptr_t count, 53 static RawArray* New(intptr_t count,
54 const Array& optional_arguments_names); 54 const Array& optional_arguments_names);
55 55
56 // Allocate and return an arguments descriptor that has no optional
57 // arguments. All arguments are positional.
58 static RawArray* New(intptr_t count);
59
56 private: 60 private:
57 // Absolute indexes into the array. 61 // Absolute indexes into the array.
58 enum { 62 enum {
59 kCountIndex, 63 kCountIndex,
60 kPositionalCountIndex, 64 kPositionalCountIndex,
61 kFirstNamedEntryIndex, 65 kFirstNamedEntryIndex,
62 }; 66 };
63 67
64 // Relative indexes into each named argument entry. 68 // Relative indexes into each named argument entry.
65 enum { 69 enum {
(...skipping 13 matching lines...) Expand all
79 }; 83 };
80 84
81 85
82 // DartEntry abstracts functionality needed to resolve dart functions 86 // DartEntry abstracts functionality needed to resolve dart functions
83 // and invoke them from C++. 87 // and invoke them from C++.
84 class DartEntry : public AllStatic { 88 class DartEntry : public AllStatic {
85 public: 89 public:
86 // On success, returns a RawInstance. On failure, a RawError. 90 // On success, returns a RawInstance. On failure, a RawError.
87 typedef RawObject* (*invokestub)(uword entry_point, 91 typedef RawObject* (*invokestub)(uword entry_point,
88 const Array& arguments_descriptor, 92 const Array& arguments_descriptor,
89 const Object** arguments, 93 const Array& arguments,
90 const Context& context); 94 const Context& context);
91 95
92 // Invokes the specified instance function on the receiver. 96 // Invokes the specified instance function on the receiver.
93 // On success, returns a RawInstance. On failure, a RawError. 97 // On success, returns a RawInstance. On failure, a RawError.
94 static RawObject* InvokeDynamic( 98 // This is used when there are no named arguments in the call.
95 const Instance& receiver, 99 static RawObject* InvokeDynamic(const Function& function,
100 const Array& arguments);
101
102 // Invokes the specified instance function on the receiver.
103 // On success, returns a RawInstance. On failure, a RawError.
104 static RawObject* InvokeDynamicWithNamedArgs(
regis 2012/12/18 16:21:28 It's great not to have to pass the arguments descr
siva 2012/12/18 21:18:13 Agree, I have changed the name to just InvokeDynam
96 const Function& function, 105 const Function& function,
97 const GrowableArray<const Object*>& arguments, 106 const Array& arguments_descriptor,
98 const Array& optional_arguments_names); 107 const Array& arguments);
99 108
100 // Invoke the specified static function. 109 // Invoke the specified static function.
101 // On success, returns a RawInstance. On failure, a RawError. 110 // On success, returns a RawInstance. On failure, a RawError.
102 static RawObject* InvokeStatic( 111 // This is used when there are no named arguments in the call.
112 static RawObject* InvokeStatic(const Function& function,
113 const Array& arguments);
114
115 // Invoke the specified static function.
116 // On success, returns a RawInstance. On failure, a RawError.
117 static RawObject* InvokeStaticWithNamedArgs(
regis 2012/12/18 16:21:28 Overload "InvokeStatic" and swap arguments?
siva 2012/12/18 21:18:13 Done.
103 const Function& function, 118 const Function& function,
104 const GrowableArray<const Object*>& arguments, 119 const Array& arguments_descriptor,
105 const Array& optional_arguments_names); 120 const Array& arguments);
106 121
107 // Invoke the specified closure object. 122 // Invoke the specified closure object.
108 // On success, returns a RawInstance. On failure, a RawError. 123 // On success, returns a RawInstance. On failure, a RawError.
109 static RawObject* InvokeClosure( 124 // This is used when there are no named arguments in the call.
125 static RawObject* InvokeClosure(const Instance& closure,
regis 2012/12/18 16:21:28 The closure is the first argument and does not nee
siva 2012/12/18 21:18:13 I thought about that too, but somehow felt it is m
regis 2012/12/18 21:34:46 Sure. It is definitely more readable to repeat the
126 const Array& arguments);
127
128 // Invoke the specified closure object.
129 // On success, returns a RawInstance. On failure, a RawError.
130 static RawObject* InvokeClosureWithNamedArgs(
regis 2012/12/18 16:21:28 Overload "InvokeClosure" and swap arguments?
siva 2012/12/18 21:18:13 Swapped the arguments but retained the closure par
110 const Instance& closure, 131 const Instance& closure,
111 const GrowableArray<const Object*>& arguments, 132 const Array& arguments_descriptor,
112 const Array& optional_arguments_names); 133 const Array& arguments);
113 }; 134 };
114 135
115 136
116 // Utility functions to call from VM into Dart bootstrap libraries. 137 // Utility functions to call from VM into Dart bootstrap libraries.
117 // Each may return an exception object. 138 // Each may return an exception object.
118 class DartLibraryCalls : public AllStatic { 139 class DartLibraryCalls : public AllStatic {
119 public: 140 public:
120 // On success, returns a RawInstance. On failure, a RawError. 141 // On success, returns a RawInstance. On failure, a RawError.
121 static RawObject* ExceptionCreate( 142 static RawObject* ExceptionCreate(
122 const Library& library, 143 const Library& library,
(...skipping 23 matching lines...) Expand all
146 167
147 // Gets the _id field of a SendPort/ReceivePort. 168 // Gets the _id field of a SendPort/ReceivePort.
148 // 169 //
149 // Returns the value of _id on success, a RawError on failure. 170 // Returns the value of _id on success, a RawError on failure.
150 static RawObject* PortGetId(const Instance& port); 171 static RawObject* PortGetId(const Instance& port);
151 }; 172 };
152 173
153 } // namespace dart 174 } // namespace dart
154 175
155 #endif // VM_DART_ENTRY_H_ 176 #endif // VM_DART_ENTRY_H_
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/dart_entry.cc » ('j') | vm/dart_entry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698