Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 433 lines (313 sloc) 11.379 kb
c64e58f pmc docs update 3
Michael Scott authored
1 /*
0e36289 @allisonrandal [cage] Updating all copyrights in src/ to Parrot Foundation.
allisonrandal authored
2 Copyright (C) 2001-2008, Parrot Foundation.
c64e58f pmc docs update 3
Michael Scott authored
3 $Id$
4
5 =head1 NAME
6
f474cd7 @bschmalhofer [perl #38235] Rename (dyn)?classes to (dyn)?pmc
bschmalhofer authored
7 src/pmc/nci.pmc - Native Call Interface
c64e58f pmc docs update 3
Michael Scott authored
8
9 =head1 DESCRIPTION
10
11 The vtable functions for the native C call functions.
12
13 =head2 Methods
14
15 =over 4
16
17 =cut
18
19 */
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
20
21 #include "parrot/parrot.h"
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
22
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
23 typedef INTVAL (*nci_sub_t)(PARROT_INTERP, PMC *);
24 typedef INTVAL (*nci_jit_sub_t)(PARROT_INTERP, PMC *, char *);
25
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
26 void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info);
27 void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info) {
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
28 char *sig_c = Parrot_str_to_cstring(interp, sig);
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
29 size_t sig_length = strlen(sig_c);
30 char *param_sig = mem_allocate_n_zeroed_typed(sig_length, char);
31 size_t j = 0;
32 size_t i;
33
34 for (i = 1; i < sig_length; i++) {
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
35 switch (sig_c[i]) {
36 case '0': /* null ptr or such - doesn't consume a reg */
37 break;
38 case 'f':
39 case 'N':
40 case 'd':
41 param_sig[j++] = 'N';
42 break;
43 case 'I': /* INTVAL */
44 case 'l': /* long */
45 case 'i': /* int */
46 case 's': /* short */
47 case 'c': /* char */
48 param_sig[j++] = 'I';
49 break;
50 case 'S':
51 case 't': /* string, pass a cstring */
52 param_sig[j++] = 'S';
53 break;
54 case 'J': /* interpreter */
55 break;
56 case 'p': /* push pmc->data */
57 case 'O': /* push PMC * object in P2 */
58 case 'P': /* push PMC * */
59 case 'V': /* push PMC * */
60 param_sig[j++] = 'P';
61 case 'v':
62 break;
63 /* I have no idea how to handle these */
64 case '2':
65 case '3':
66 case '4':
67 param_sig[j++] = 'I';
68 break;
69 case '@':
4d00214 @tewk [jitted NCI] fixed "@" signature bug
tewk authored
70 param_sig[j++] = '@';
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
71 break;
72 case 'b': /* buffer (void*) pass PObj_bufstart(SReg) */
73 case 'B': /* buffer (void**) pass &PObj_bufstart(SReg) */
74 param_sig[j++] = 'S';
75 break;
76 default:
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
77 Parrot_ex_throw_from_c_args(interp, NULL,
78 EXCEPTION_JIT_ERROR,
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
79 "Unknown param Signature %c\n", sig_c[i]);
80 break;
81 }
82 }
83
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
84 PARROT_ASSERT(j <= sig_length);
33d35c5 @tewk [NCI] ensure that nci_info members are CONSTANT STRINGS
tewk authored
85
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
86 /* use only the signature-significant part of the string buffer */
87 if (j) {
88 nci_info->pcc_params_signature = string_make(interp, param_sig, j,
89 NULL, PObj_constant_FLAG);
90 }
91 else
92 nci_info->pcc_params_signature = CONST_STRING(interp, "");
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
93
37fe639 @chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also …
chromatic authored
94 mem_sys_free(param_sig);
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
95 Parrot_str_free_cstring(sig_c);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
96 }
97
98
0c0850c use need_ext flag
Leopold Toetsch authored
99 pmclass NCI need_ext {
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
100 ATTR STRING *signature; /* The signature. */
9ed2bdc @chromatic [MMD] Changed MULTI initialization to delay generating type typles of…
chromatic authored
101 ATTR void *func; /* Function pointer to call. */
102 ATTR void *orig_func; /* Function pointer
103 * used to create func */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
104 ATTR STRING *pcc_params_signature; /* The signature. */
9ed2bdc @chromatic [MMD] Changed MULTI initialization to delay generating type typles of…
chromatic authored
105 ATTR STRING *long_signature; /* The full signature. */
106 ATTR PMC *multi_sig; /* type tuple array (?) */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
107 ATTR INTVAL arity; /* Cached arity of the NCI. */
108 ATTR INTVAL jitted; /* Is this a jitted NCI stub. */
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
109
c64e58f pmc docs update 3
Michael Scott authored
110 /*
111
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
112 =item C<METHOD get_multisig()>
1415cda add introspection method get_multisig
Leopold Toetsch authored
113
114 Return the MMD signature PMC, if any or a Null PMC.
115
116 =cut
117
118 */
119
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
120 METHOD get_multisig() {
26f7d7b @cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
121 PMC *sig;
122 GET_ATTR_multi_sig(INTERP, SELF, sig);
123 if (sig == PMCNULL)
124 sig = PMCNULL;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
125 RETURN(PMC *sig);
1415cda add introspection method get_multisig
Leopold Toetsch authored
126 }
127
128 /*
129
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
130 =item C<METHOD set_raw_nci_ptr(void *func)>
d1c84dd @tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored
131
132 Sets the specified function pointer and raw flag.
133
134 =cut
135
136 */
137
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
138 METHOD make_raw_nci(PMC *func) {
139 VTABLE_set_pointer(interp, SELF, (void *)func);
d1c84dd @tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored
140 }
141
142 /*
143
c64e58f pmc docs update 3
Michael Scott authored
144 =item C<void init()>
145
146 Initializes the NCI with a C<NULL> function pointer.
147
148 =cut
149
150 */
151
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
152 VTABLE void init() {
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
153 PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
154
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
155 /* Mark that we're not a raw NCI. */
d1c84dd @tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored
156 PObj_flag_CLEAR(private2, SELF);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
157 PObj_custom_mark_SET(SELF);
0176661 @chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes …
chromatic authored
158 PObj_active_destroy_SET(SELF);
f7fc86b nci
Leopold Toetsch authored
159 }
160
c64e58f pmc docs update 3
Michael Scott authored
161 /*
162
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
163 =item C<void set_pointer_keyed_str(STRING *key, void *func)>
c64e58f pmc docs update 3
Michael Scott authored
164
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
165 Sets the specified function pointer and signature (C<*key>).
c64e58f pmc docs update 3
Michael Scott authored
166
167 =cut
168
169 */
170
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
171 VTABLE void set_pointer(void *ptr) {
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
172 SET_ATTR_orig_func(INTERP, SELF, ptr);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
173 PObj_flag_SET(private2, SELF);
174 }
175
4108fd8 @cotto [JIT] remove undocumented dependency of jit code on PMC internals, fi…
cotto authored
176 VTABLE void *get_pointer() {
177 return PARROT_NCI(SELF)->orig_func;
178 }
179
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
180 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
181 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
3bb127b @cotto [style] a bunch of consting
cotto authored
182 int jitted = 0;
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
183
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
184 /* Store the original function and signature. */
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
185 SET_ATTR_orig_func(INTERP, SELF, func);
c4cd281 @chromatic [PMC] Avoided an unnecessary STRING copying and creation in NCI's
chromatic authored
186
187 /* ensure that the STRING signature is constant */
188 if (!PObj_constant_TEST(key)) {
189 char * const key_c = Parrot_str_to_cstring(INTERP, key);
190 key = string_make(interp, key_c, strlen(key_c),
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
191 NULL, PObj_constant_FLAG);
c4cd281 @chromatic [PMC] Avoided an unnecessary STRING copying and creation in NCI's
chromatic authored
192 Parrot_str_free_cstring(key_c);
193 }
194
195 nci_info->signature = key;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
196 pcc_params(INTERP, key, nci_info);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
197
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
198 /* Arity is length of that string minus one (the return type). */
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
199 nci_info->arity = Parrot_str_byte_length(INTERP, key) - 1;
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
200
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
201 /* Build call function. */
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
202 nci_info->func = (PMC *)(build_call_func(INTERP, SELF,
203 key, &jitted));
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
204 nci_info->jitted = jitted;
205 }
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
206
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
207 /*
208
209 =item C<void mark()>
210
211 Mark any referenced strings and PMCs.
212
213 =cut
214
215 */
216 VTABLE void mark() {
217 if (PARROT_NCI(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
218 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
219
220 if (nci_info->signature)
b354cdb @Whiteknight [gc_api] Behold! Parrot is entering an age of slightly less lousy GC!…
Whiteknight authored
221 Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->signature);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
222 if (nci_info->pcc_params_signature)
b354cdb @Whiteknight [gc_api] Behold! Parrot is entering an age of slightly less lousy GC!…
Whiteknight authored
223 Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->pcc_params_signature);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
224 }
65bd9bf eval #1
Leopold Toetsch authored
225 }
11b723d fixed memory leak in jitted i386 nci code; clone nci
Leopold Toetsch authored
226
c64e58f pmc docs update 3
Michael Scott authored
227 /*
228
229 =item C<void destroy()>
230
231 Destroys the NCI, freeing any allocated memory.
232
233 =cut
234
235 */
236
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
237 VTABLE void destroy() {
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
238 if (PMC_data(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
239 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
0176661 @chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes …
chromatic authored
240
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
241 mem_sys_free(nci_info);
0176661 @chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes …
chromatic authored
242 PMC_data(SELF) = NULL;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
243 }
11b723d fixed memory leak in jitted i386 nci code; clone nci
Leopold Toetsch authored
244 }
245
c64e58f pmc docs update 3
Michael Scott authored
246 /*
247
248 =item C<PMC *clone()>
249
250 Creates and returns a clone of the NCI.
251
252 =cut
253
254 */
255
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
256 VTABLE PMC *clone() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
257 Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
258 Parrot_NCI_attributes *nci_info_ret;
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
259 void *orig_func;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
260
26f7d7b @cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
261 PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
262 PMC_data(ret) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
263 nci_info_ret = PARROT_NCI(ret);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
264
c64e58f pmc docs update 3
Michael Scott authored
265 /* FIXME if data is malloced (JIT/i386!) then we need
266 * the length of data here, to memcpy it
267 * ManagedStruct or Buffer?
268 */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
269 nci_info_ret->func = nci_info_self->func;
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
270 nci_info_ret->orig_func = nci_info_self->orig_func;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
271 nci_info_ret->signature = nci_info_self->signature;
272 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
273 nci_info_ret->arity = nci_info_self->arity;
37fe639 @chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also …
chromatic authored
274 nci_info_ret->jitted = nci_info_self->jitted;
4108fd8 @cotto [JIT] remove undocumented dependency of jit code on PMC internals, fi…
cotto authored
275 PObj_get_FLAGS(ret) |= (PObj_get_FLAGS(SELF) & 0x7);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
276
c64e58f pmc docs update 3
Michael Scott authored
277 return ret;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
278 }
279
c64e58f pmc docs update 3
Michael Scott authored
280 /*
281
282 =item C<INTVAL defined()>
283
284 Returns whether the NCI is defined.
285
286 =cut
287
288 */
289
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
290 VTABLE INTVAL defined() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
291 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
292 return nci_info->func != NULL;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
293 }
294
c64e58f pmc docs update 3
Michael Scott authored
295 /*
296
0ae5d55 @paultcochrane Patch courtesy of Steve Peters <steve at fisharerojo dot org>, his co…
paultcochrane authored
297 =item C<opcode_t *invoke(void *next)>
c64e58f pmc docs update 3
Michael Scott authored
298
8838c7f builtins 1 - first shot
Leopold Toetsch authored
299 Calls the associated C function, returning C<*next>. If
300 the invocant is a class, the PMC arguments are
301 shifted down.
c64e58f pmc docs update 3
Michael Scott authored
302
303 =cut
304
305 */
306
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
307 VTABLE opcode_t *invoke(void *next) {
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
308
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
309 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
310 nci_sub_t func;
311 void *orig_func;
312 PMC *cont;
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
313
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
314 GET_ATTR_orig_func(INTERP, SELF, orig_func);
315 func = PObj_flag_TEST(private2, SELF)
316 ? (nci_sub_t) D2FPTR(orig_func)
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
317 : (nci_sub_t) D2FPTR(nci_info->func);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
318
b9b6c03 fix MMD wrapping for __is_equal
Leopold Toetsch authored
319 if (!func)
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
320 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
b9b6c03 fix MMD wrapping for __is_equal
Leopold Toetsch authored
321 "attempt to call NULL function");
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
322
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
323 if (nci_info->jitted) {
324
325 nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
326
327 /* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
4108fd8 @cotto [JIT] remove undocumented dependency of jit code on PMC internals, fi…
cotto authored
328 jit_func(INTERP, SELF, (char *) nci_info->pcc_params_signature->strstart);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
329 }
330 else {
331 if (PObj_flag_TEST(private2, SELF)) {
332 /* Parrot_eprintf(interp, "RAW NCI CALL\n"); */
333 }
334 else {
335 /* Parrot_eprintf(interp, "HACKED %S\n", nci_info->signature); */
336 }
337 func(INTERP, SELF);
338 }
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
339 cont = INTERP->current_cont;
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
340
8838c7f builtins 1 - first shot
Leopold Toetsch authored
341 /*
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
342 * If the NCI function was tailcalled, the return result
343 * is already passed back to the caller of this frame
344 * - see Parrot_init_ret_nci(). We therefore invoke the
345 * return continuation here, which gets rid of this frame
346 * and returns the real return address
8838c7f builtins 1 - first shot
Leopold Toetsch authored
347 */
bf41b66 @particle [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored
348 if (cont && cont != NEED_CONTINUATION &&
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
349 (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
637cc2a @chromatic [src] Changed CONTEXT(interp->ctx) to CONTEXT(interp), which seems cl…
chromatic authored
350 cont = CONTEXT(interp)->current_cont;
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
351 next = VTABLE_invoke(INTERP, cont, next);
352 }
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
353
e063e49 @chromatic Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
chromatic authored
354 return (opcode_t *)next;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
355 }
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
356
c64e58f pmc docs update 3
Michael Scott authored
357 /*
358
359 =item C<INTVAL get_integer()>
360
361 Returns the function pointer as an integer.
362
363 =cut
364
365 */
366
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
367 VTABLE INTVAL get_integer() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
368 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
369 return (INTVAL)nci_info->func;
3168931 Forth can now generate code for words on the fly and execute them.
Dan Sugalski authored
370 }
371
f35b03c @rubys Initial support for sort
rubys authored
372 /*
373
374 =item C<INTVAL get_bool()>
375
376 Returns the boolean value of the pointer.
377
378 =cut
379
380 */
381
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
382 VTABLE INTVAL get_bool() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
383 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
384 return (0 != (INTVAL)nci_info->func);
f35b03c @rubys Initial support for sort
rubys authored
385 }
386
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
387 /*
388
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
389 =item C<METHOD arity()>
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
390
01e804c @Util [pmc] Typo corrections
Util authored
391 Return the arity of the NCI (the number of arguments).
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
392
393 =cut
394
395 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
396 METHOD arity() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
397 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
398 INTVAL arity = 0;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
399
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
400 if (nci_info && nci_info->func)
401 arity = nci_info->arity;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
402 else
37fe639 @chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also …
chromatic authored
403 Parrot_ex_throw_from_c_args(INTERP, NULL,
404 EXCEPTION_INVALID_OPERATION,
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
405 "You cannot get the arity of an undefined NCI.");
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
406
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
407 RETURN(INTVAL arity);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
408 }
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
409 }
c64e58f pmc docs update 3
Michael Scott authored
410
411 /*
412
413 =back
414
415 =head1 SEE ALSO
416
417 F<docs/pdds/pdd03_calling_conventions.pod>.
418
419 =head1 HISTORY
420
421 Initial revision by sean 2002/08/04.
422
423 =cut
424
425 */
426
0eb3eb3 added formatting footer and detabbed
Michael Scott authored
427 /*
428 * Local variables:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored
429 * c-file-style: "parrot"
0eb3eb3 added formatting footer and detabbed
Michael Scott authored
430 * End:
431 * vim: expandtab shiftwidth=4:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored
432 */
Something went wrong with that request. Please try again.