Mercurial > repos > rhope
annotate runtime/object.h @ 24:8b2b3f4a2a58
Some fixes to parser_old.rhope
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 24 Jun 2009 23:56:49 -0400 |
parents | 31f8182f3433 |
children | 914ad38f9b59 |
rev | line source |
---|---|
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
1 #ifndef OBJECT_H_ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
2 #define OBJECT_H_ |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include "plat_types.h" |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "thread.h" |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
6 #include "func.h" |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 typedef struct{ |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 rhope_func *method_lookup; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 rhope_func *getter_lookup; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 rhope_func *setter_lookup; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 rhope_func *convert_to; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 rhope_func *convert_from; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 special_func init; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 special_func copy; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 special_func cleanup; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 struct object *name; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 uint32_t first_methodid; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 uint32_t last_methodid; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 uint32_t first_getfieldid; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 uint32_t last_getfieldid; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 uint32_t first_setfieldid; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 uint32_t last_setfieldid; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 uint32_t first_convertto; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 uint32_t last_convertto; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 uint32_t first_convertfrom; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 uint32_t last_convertfrom; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 uint32_t size; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 uint32_t boxed_size; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 } blueprint; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 typedef struct object { |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 rh_atomic32(refcount); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 blueprint *bprint; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 } object; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 typedef struct { |
10
0f2c4ee070fe
Changes to calldata struct for stack unwind
Mike Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
38 object base; |
0f2c4ee070fe
Changes to calldata struct for stack unwind
Mike Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
39 uint32_t size; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 } multisize; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 typedef struct calldata { |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
44 rhope_func tail_func; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
45 struct context *ct; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
46 void *locals; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
47 struct calldata *call; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
48 uint32_t original_methodid; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
49 uint16_t num_params; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
50 uint16_t resume; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
51 object *params[1]; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 } calldata; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 #define OBegin typedef struct { object header; |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
55 #define Object(name) } t_ ## name; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 #define MOBegin typedef struct { multisize header; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 #define get_blueprint(object) (object)->bprint |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
61 #define add_ref(object) (rh_atomic_add((object), refcount, 1),object) |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 returntype call_method(uint32_t methodid, calldata * params); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 returntype set_field(uint32_t setfieldid, calldata * params); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 returntype get_field(uint32_t getfieldid, calldata * params); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 object * alloc_object(blueprint * bp); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 void * alloc_variable(uint32_t size); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 object * new_object(uint32_t type); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 multisize * new_multisize(uint32_t type, uint32_t size); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 void release_ref(object * obj); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 blueprint * register_type_byid(uint32_t type, uint32_t size, special_func init, special_func copy, special_func cleanup); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 blueprint * new_blueprint(uint32_t type, uint32_t size, special_func init, special_func copy, special_func cleanup); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 void add_method(blueprint * bp, uint32_t methodid, rhope_func impl); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 returntype convert_to(uint32_t convertto, calldata * params); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 returntype convert_from(uint32_t convertfrom, calldata * params); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 object * copy_object(object * tocopy); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 returntype coerce_value(uint32_t type, calldata * params); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 #define INITIAL_TYPE_STORAGE 32 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 #define INITIAL_METHOD_LOOKUP 8 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 #define BELOW_INITIAL_METHOD 3 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
83 #endif //OBJECT_H_ |