Mercurial > repos > rhope
annotate runtime/builtin.c @ 180:c40e0faa1c92
Add Call to Dict and List
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 19 Jun 2011 10:43:11 -0700 |
parents | f2cb85c53ced |
children | ba35ab624ec2 |
rev | line source |
---|---|
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "builtin.h" |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include "object.h" |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include "integer.h" |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
4 #include "bool.h" |
141
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
5 #include "context.h" |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #include <stddef.h> |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
7 #include <stdio.h> |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
8 #include <stdlib.h> |
52
079200bc3e75
String literals almost working. Print moved out of C runtime.
Mike Pavone <pavone@retrodev.com>
parents:
50
diff
changeset
|
9 #include <string.h> |
99
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
10 #include <stdarg.h> |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
11 #include <stdint.h> |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 void register_builtin_type(uint32_t type) |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 { |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 blueprint * bp; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 switch(type) |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 { |
36
495dddadd058
User defined types work in the compiler now
Mike Pavone <pavone@retrodev.com>
parents:
30
diff
changeset
|
18 case TYPE_BLUEPRINT: |
495dddadd058
User defined types work in the compiler now
Mike Pavone <pavone@retrodev.com>
parents:
30
diff
changeset
|
19 bp = register_type_byid(TYPE_BLUEPRINT, sizeof(blueprint *), NULL, NULL, NULL); |
495dddadd058
User defined types work in the compiler now
Mike Pavone <pavone@retrodev.com>
parents:
30
diff
changeset
|
20 break; |
140
c14698c512f1
Untested addition of Pause/Resume
Mike Pavone <pavone@retrodev.com>
parents:
99
diff
changeset
|
21 case TYPE_CONTEXT: |
c14698c512f1
Untested addition of Pause/Resume
Mike Pavone <pavone@retrodev.com>
parents:
99
diff
changeset
|
22 register_type_byid(TYPE_CONTEXT, sizeof(context *), NULL, NULL, NULL); |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 } |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 void register_builtin_types() |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 { |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 uint32_t i; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 for(i = 0; i < TYPE_FIRST_USER; ++i) |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 register_builtin_type(i); |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
31 } |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
32 object * make_Int64(int64_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
33 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
34 t_Int64 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
35 object * ret = new_object(TYPE_INT64); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
36 obj = (t_Int64 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
37 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
38 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
39 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
40 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
41 |
48
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
42 object * make_Int32(int32_t val) |
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
43 { |
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
44 t_Int32 * obj; |
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
45 object * ret = new_object(TYPE_INT32); |
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
46 obj = (t_Int32 *)ret; |
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
47 obj->Num = val; |
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
48 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
49 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
50 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
51 object * make_Int16(int16_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
52 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
53 t_Int16 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
54 object * ret = new_object(TYPE_INT16); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
55 obj = (t_Int16 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
56 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
57 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
58 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
59 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
60 object * make_Int8(int8_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
61 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
62 t_Int8 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
63 object * ret = new_object(TYPE_INT8); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
64 obj = (t_Int8 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
65 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
66 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
67 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
68 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
69 object * make_UInt64(uint64_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
70 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
71 t_UInt64 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
72 object * ret = new_object(TYPE_UINT64); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
73 obj = (t_UInt64 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
74 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
75 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
76 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
77 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
78 object * make_UInt32(uint32_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
79 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
80 t_UInt32 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
81 object * ret = new_object(TYPE_UINT32); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
82 obj = (t_UInt32 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
83 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
84 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
85 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
86 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
87 object * make_UInt16(uint16_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
88 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
89 t_UInt16 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
90 object * ret = new_object(TYPE_UINT16); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
91 obj = (t_UInt16 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
92 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
93 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
94 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
95 |
50
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
96 object * make_UInt8(uint8_t val) |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
97 { |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
98 t_UInt8 * obj; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
99 object * ret = new_object(TYPE_UINT8); |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
100 obj = (t_UInt8 *)ret; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
101 obj->Num = val; |
689fb73e7612
Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
102 return ret; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
103 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
104 |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
105 object * make_String(char * text) |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
106 { |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
107 object * params[1]; |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
108 t_Array * arr = (t_Array *)_internal_array_allocnaked(strlen(text), make_Blueprint(TYPE_UINT8)); |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
109 arr->payload.Length = arr->payload.Storage; |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
110 memcpy(((char *)arr) + sizeof(t_Array), text, arr->payload.Length); |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
111 |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
112 params[0] = (object *)arr; |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
113 rhope(FUNC_String, params, 1, 1); |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
114 |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
115 return params[0]; |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
116 } |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
117 |
72
f7bcf3db1342
Add =@String, fix bool bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
118 object * make_Bool(int32_t val) |
f7bcf3db1342
Add =@String, fix bool bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
119 { |
f7bcf3db1342
Add =@String, fix bool bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
120 t_Boolean * b = (t_Boolean *)new_object(TYPE_BOOLEAN); |
f7bcf3db1342
Add =@String, fix bool bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
121 b->Val = val != 0; |
f7bcf3db1342
Add =@String, fix bool bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
122 return (object*)b; |
99
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
123 } |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
124 |
141
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
125 object * make_Context(context * ct) |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
126 { |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
127 t_Context * c = (t_Context *)new_object(TYPE_CONTEXT); |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
128 c->ct = ct; |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
129 return (object *)c; |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
130 } |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
131 |
99
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
132 object * make_Worker(int32_t index, int16_t initialsize, int16_t initialcount) |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
133 { |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
134 t_Worker * worker = (t_Worker *)_internal_worker_alloc(initialsize); |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
135 worker->payload.Index = index; |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
136 worker->payload.Count = initialcount; |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
137 return (object *)worker; |
72
f7bcf3db1342
Add =@String, fix bool bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
138 } |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
139 |
99
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
140 object * make_List(int32_t numels,...) |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
141 { |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
142 int32_t idx, elidx; |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
143 object * inout[3]; |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
144 va_list args; |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
145 |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
146 va_start(args, numels); |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
147 rhope(FUNC_List, inout, 0, 1); |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
148 |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
149 for (idx = 0; idx < numels; ++idx) |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
150 { |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
151 elidx = va_arg(args, int32_t); |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
152 inout[1] = make_Int32(elidx); |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
153 inout[2] = va_arg(args, object *); |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
154 } |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
155 return inout[0]; |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
156 } |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
157 |
e09c2d1d6d5b
Got dataflow graph code working in compiler (nworker_c.rhope)
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
158 |