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 #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 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Forward declarations. | 13 // Forward declarations. |
14 class Array; | 14 class Array; |
15 class Closure; | 15 class Closure; |
16 class Context; | 16 class Context; |
17 class Function; | 17 class Function; |
18 class Instance; | 18 class Instance; |
19 class Integer; | 19 class Integer; |
20 class Object; | 20 class Object; |
21 class RawInstance; | 21 class RawInstance; |
22 class RawObject; | |
23 class String; | 22 class String; |
24 | 23 |
25 // DartEntry abstracts functionality needed to resolve dart functions | 24 // DartEntry abstracts functionality needed to resolve dart functions |
26 // and invoke them from C++. | 25 // and invoke them from C++. |
| 26 // |
| 27 // TODO(turnidge): Make these functions assert that there is an active |
| 28 // setjmp. Or make these functions do the setjmps themselves and |
| 29 // represent compile errors with an explict object type. |
| 30 // |
| 31 // TODO(turnidge): Make these functions return RawObject instead of |
| 32 // RawInstance. |
27 class DartEntry : public AllStatic { | 33 class DartEntry : public AllStatic { |
28 public: | 34 public: |
29 // On success, returns a RawInstance. On failure, a RawError. | 35 typedef RawInstance* (*invokestub)(uword entry_point, |
30 typedef RawObject* (*invokestub)(uword entry_point, | 36 const Array& arguments_descriptor, |
31 const Array& arguments_descriptor, | 37 const Object** arguments, |
32 const Object** arguments, | 38 const Context& context); |
33 const Context& context); | |
34 | 39 |
35 // Invokes the specified instance function on the receiver. | 40 // Invoke the specified instance function on the receiver. |
36 // On success, returns a RawInstance. On failure, a RawError. | 41 // Returns object returned by the dart instance function. |
37 static RawObject* InvokeDynamic( | 42 static RawInstance* InvokeDynamic( |
38 const Instance& receiver, | 43 const Instance& receiver, |
39 const Function& function, | 44 const Function& function, |
40 const GrowableArray<const Object*>& arguments, | 45 const GrowableArray<const Object*>& arguments, |
41 const Array& optional_arguments_names); | 46 const Array& optional_arguments_names); |
42 | 47 |
43 // Invoke the specified static function. | 48 // Invoke the specified static function. |
44 // On success, returns a RawInstance. On failure, a RawError. | 49 // Returns object returned by the dart static function. |
45 static RawObject* InvokeStatic( | 50 static RawInstance* InvokeStatic( |
46 const Function& function, | 51 const Function& function, |
47 const GrowableArray<const Object*>& arguments, | 52 const GrowableArray<const Object*>& arguments, |
48 const Array& optional_arguments_names); | 53 const Array& optional_arguments_names); |
49 | 54 |
50 // Invoke the specified closure object. | 55 // Invoke the specified closure object. |
51 // On success, returns a RawInstance. On failure, a RawError. | 56 // Returns object returned by the closure. |
52 static RawObject* InvokeClosure( | 57 static RawInstance* InvokeClosure( |
53 const Closure& closure, | 58 const Closure& closure, |
54 const GrowableArray<const Object*>& arguments, | 59 const GrowableArray<const Object*>& arguments, |
55 const Array& optional_arguments_names); | 60 const Array& optional_arguments_names); |
56 }; | 61 }; |
57 | 62 |
58 | 63 |
59 // Utility functions to call from VM into Dart bootstrap libraries. | 64 // Utility functions to call from VM into Dart bootstrap libraries. |
60 // Each may return an exception object. | 65 // Each may return an exception object. |
61 class DartLibraryCalls : public AllStatic { | 66 class DartLibraryCalls : public AllStatic { |
62 public: | 67 public: |
63 // On success, returns a RawInstance. On failure, a RawError. | 68 static RawInstance* ExceptionCreate( |
64 static RawObject* ExceptionCreate( | |
65 const String& exception_name, | 69 const String& exception_name, |
66 const GrowableArray<const Object*>& arguments); | 70 const GrowableArray<const Object*>& arguments); |
| 71 static RawInstance* ToString(const Instance& receiver); |
| 72 static RawInstance* Equals(const Instance& left, const Instance& right); |
67 | 73 |
68 // On success, returns a RawInstance. On failure, a RawError. | 74 // Returns either an unhandled exception or null. |
69 static RawObject* ToString(const Instance& receiver); | |
70 | |
71 // On success, returns a RawInstance. On failure, a RawError. | |
72 static RawObject* Equals(const Instance& left, const Instance& right); | |
73 | |
74 // Returns null on success, a RawError on failure. | |
75 static RawObject* HandleMessage(Dart_Port dest_port_id, | 75 static RawObject* HandleMessage(Dart_Port dest_port_id, |
76 Dart_Port reply_port_id, | 76 Dart_Port reply_port_id, |
77 const Instance& dart_message); | 77 const Instance& dart_message); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace dart | 80 } // namespace dart |
81 | 81 |
82 #endif // VM_DART_ENTRY_H_ | 82 #endif // VM_DART_ENTRY_H_ |
OLD | NEW |