| 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; |
| 22 class String; | 23 class String; |
| 23 | 24 |
| 24 // DartEntry abstracts functionality needed to resolve dart functions | 25 // DartEntry abstracts functionality needed to resolve dart functions |
| 25 // and invoke them from C++. | 26 // 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. | |
| 33 class DartEntry : public AllStatic { | 27 class DartEntry : public AllStatic { |
| 34 public: | 28 public: |
| 35 typedef RawInstance* (*invokestub)(uword entry_point, | 29 // On success, returns a RawInstance. On failure, a RawError. |
| 36 const Array& arguments_descriptor, | 30 typedef RawObject* (*invokestub)(uword entry_point, |
| 37 const Object** arguments, | 31 const Array& arguments_descriptor, |
| 38 const Context& context); | 32 const Object** arguments, |
| 33 const Context& context); |
| 39 | 34 |
| 40 // Invoke the specified instance function on the receiver. | 35 // Invokes the specified instance function on the receiver. |
| 41 // Returns object returned by the dart instance function. | 36 // On success, returns a RawInstance. On failure, a RawError. |
| 42 static RawInstance* InvokeDynamic( | 37 static RawObject* InvokeDynamic( |
| 43 const Instance& receiver, | 38 const Instance& receiver, |
| 44 const Function& function, | 39 const Function& function, |
| 45 const GrowableArray<const Object*>& arguments, | 40 const GrowableArray<const Object*>& arguments, |
| 46 const Array& optional_arguments_names); | 41 const Array& optional_arguments_names); |
| 47 | 42 |
| 48 // Invoke the specified static function. | 43 // Invoke the specified static function. |
| 49 // Returns object returned by the dart static function. | 44 // On success, returns a RawInstance. On failure, a RawError. |
| 50 static RawInstance* InvokeStatic( | 45 static RawObject* InvokeStatic( |
| 51 const Function& function, | 46 const Function& function, |
| 52 const GrowableArray<const Object*>& arguments, | 47 const GrowableArray<const Object*>& arguments, |
| 53 const Array& optional_arguments_names); | 48 const Array& optional_arguments_names); |
| 54 | 49 |
| 55 // Invoke the specified closure object. | 50 // Invoke the specified closure object. |
| 56 // Returns object returned by the closure. | 51 // On success, returns a RawInstance. On failure, a RawError. |
| 57 static RawInstance* InvokeClosure( | 52 static RawObject* InvokeClosure( |
| 58 const Closure& closure, | 53 const Closure& closure, |
| 59 const GrowableArray<const Object*>& arguments, | 54 const GrowableArray<const Object*>& arguments, |
| 60 const Array& optional_arguments_names); | 55 const Array& optional_arguments_names); |
| 61 }; | 56 }; |
| 62 | 57 |
| 63 | 58 |
| 64 // Utility functions to call from VM into Dart bootstrap libraries. | 59 // Utility functions to call from VM into Dart bootstrap libraries. |
| 65 // Each may return an exception object. | 60 // Each may return an exception object. |
| 66 class DartLibraryCalls : public AllStatic { | 61 class DartLibraryCalls : public AllStatic { |
| 67 public: | 62 public: |
| 68 static RawInstance* ExceptionCreate( | 63 // On success, returns a RawInstance. On failure, a RawError. |
| 64 static RawObject* ExceptionCreate( |
| 69 const String& exception_name, | 65 const String& exception_name, |
| 70 const GrowableArray<const Object*>& arguments); | 66 const GrowableArray<const Object*>& arguments); |
| 71 static RawInstance* ToString(const Instance& receiver); | |
| 72 static RawInstance* Equals(const Instance& left, const Instance& right); | |
| 73 | 67 |
| 74 // Returns either an unhandled exception or null. | 68 // On success, returns a RawInstance. On failure, a RawError. |
| 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 |