Mercurial > repos > rhope
comparison runtime/builtin.c @ 186:ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 07 Oct 2011 00:10:02 -0700 |
parents | f2cb85c53ced |
children |
comparison
equal
deleted
inserted
replaced
185:4580c08fd4e8 | 186:ba35ab624ec2 |
---|---|
102 return ret; | 102 return ret; |
103 } | 103 } |
104 | 104 |
105 object * make_String(char * text) | 105 object * make_String(char * text) |
106 { | 106 { |
107 #ifdef RAW_FUNC | |
108 returntype ret; | |
109 #endif | |
107 object * params[1]; | 110 object * params[1]; |
108 t_Array * arr = (t_Array *)_internal_array_allocnaked(strlen(text), make_Blueprint(TYPE_UINT8)); | 111 t_Array * arr = (t_Array *)_internal_array_allocnaked(strlen(text), make_Blueprint(TYPE_UINT8)); |
109 arr->payload.Length = arr->payload.Storage; | 112 arr->payload.Length = arr->payload.Storage; |
110 memcpy(((char *)arr) + sizeof(t_Array), text, arr->payload.Length); | 113 memcpy(((char *)arr) + sizeof(t_Array), text, arr->payload.Length); |
111 | 114 |
112 params[0] = (object *)arr; | 115 params[0] = (object *)arr; |
116 #ifdef RAW_FUNC | |
117 ret = f_String(1, params); | |
118 return ret.retvals[0]; | |
119 #else | |
113 rhope(FUNC_String, params, 1, 1); | 120 rhope(FUNC_String, params, 1, 1); |
114 | |
115 return params[0]; | 121 return params[0]; |
122 #endif | |
116 } | 123 } |
117 | 124 |
118 object * make_Bool(int32_t val) | 125 object * make_Bool(int32_t val) |
119 { | 126 { |
120 t_Boolean * b = (t_Boolean *)new_object(TYPE_BOOLEAN); | 127 t_Boolean * b = (t_Boolean *)new_object(TYPE_BOOLEAN); |
137 return (object *)worker; | 144 return (object *)worker; |
138 } | 145 } |
139 | 146 |
140 object * make_List(int32_t numels,...) | 147 object * make_List(int32_t numels,...) |
141 { | 148 { |
149 #ifdef RAW_FUNC | |
150 returntype ret; | |
151 #endif | |
142 int32_t idx, elidx; | 152 int32_t idx, elidx; |
143 object * inout[3]; | 153 object * inout[3]; |
144 va_list args; | 154 va_list args; |
145 | 155 |
146 va_start(args, numels); | 156 va_start(args, numels); |
157 #ifdef RAW_FUNC | |
158 ret = f_List(1, inout); | |
159 inout[0] = ret.retvals[0]; | |
160 #else | |
147 rhope(FUNC_List, inout, 0, 1); | 161 rhope(FUNC_List, inout, 0, 1); |
162 #endif | |
148 | 163 |
149 for (idx = 0; idx < numels; ++idx) | 164 for (idx = 0; idx < numels; ++idx) |
150 { | 165 { |
151 elidx = va_arg(args, int32_t); | 166 elidx = va_arg(args, int32_t); |
152 inout[1] = make_Int32(elidx); | 167 inout[1] = make_Int32(elidx); |
153 inout[2] = va_arg(args, object *); | 168 inout[2] = va_arg(args, object *); |
169 #ifdef RAW_FUNC | |
170 ret = f_Append(3, inout); | |
171 inout[0] = ret.retvals[0]; | |
172 #else | |
173 rhope(FUNC_Append, inout, 3, 3); | |
174 #endif | |
154 } | 175 } |
155 return inout[0]; | 176 return inout[0]; |
156 } | 177 } |
157 | 178 |
158 | 179 |