Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 426 lines (308 sloc) 11.23 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 Bernhard Schmalhofer [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 Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
22
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
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>_attribu...
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 Valgrind...
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 Valgrind...
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 Valgrind...
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 Valgrind...
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 fix...
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. */
101 ATTR void *func; /* Function pointer to what we'll call. */
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
102 ATTR void *orig_func; /* Function pointer used to create func*/
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
103 ATTR STRING *pcc_params_signature; /* The signature. */
104 ATTR INTVAL arity; /* Cached arity of the NCI. */
105 ATTR INTVAL jitted; /* Is this a jitted NCI stub. */
26f7d7b cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
106 ATTR PMC *multi_sig; /* type tuple array (?) */
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
107
c64e58f pmc docs update 3
Michael Scott authored
108 /*
109
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
110 =item C<METHOD get_multisig()>
1415cda add introspection method get_multisig
Leopold Toetsch authored
111
112 Return the MMD signature PMC, if any or a Null PMC.
113
114 =cut
115
116 */
117
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
118 METHOD get_multisig() {
26f7d7b cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
119 PMC *sig;
120 GET_ATTR_multi_sig(INTERP, SELF, sig);
121 if (sig == PMCNULL)
122 sig = PMCNULL;
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
123 RETURN(PMC *sig);
1415cda add introspection method get_multisig
Leopold Toetsch authored
124 }
125
126 /*
127
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
128 =item C<METHOD set_raw_nci_ptr(void *func)>
d1c84dd tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored
129
130 Sets the specified function pointer and raw flag.
131
132 =cut
133
134 */
135
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
136 METHOD make_raw_nci(PMC *func) {
137 VTABLE_set_pointer(interp, SELF, (void *)func);
d1c84dd tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored
138 }
139
140 /*
141
c64e58f pmc docs update 3
Michael Scott authored
142 =item C<void init()>
143
144 Initializes the NCI with a C<NULL> function pointer.
145
146 =cut
147
148 */
149
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
150 VTABLE void init() {
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
151 PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
152
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
153 /* Mark that we're not a raw NCI. */
d1c84dd tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored
154 PObj_flag_CLEAR(private2, SELF);
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
155 PObj_custom_mark_SET(SELF);
0176661 chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes a n...
chromatic authored
156 PObj_active_destroy_SET(SELF);
f7fc86b nci
Leopold Toetsch authored
157 }
158
c64e58f pmc docs update 3
Michael Scott authored
159 /*
160
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
161 =item C<void set_pointer_keyed_str(STRING *key, void *func)>
c64e58f pmc docs update 3
Michael Scott authored
162
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
163 Sets the specified function pointer and signature (C<*key>).
c64e58f pmc docs update 3
Michael Scott authored
164
165 =cut
166
167 */
168
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
169 VTABLE void set_pointer(void *ptr) {
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
170 SET_ATTR_orig_func(INTERP, SELF, ptr);
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
171 PObj_flag_SET(private2, SELF);
172 }
173
174 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
175 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
3bb127b cotto [style] a bunch of consting
cotto authored
176 int jitted = 0;
b6bc0c3 allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
177 char * const key_c = Parrot_str_to_cstring(INTERP, key);
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
178
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
179 /* Store the original function and signature. */
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
180 SET_ATTR_orig_func(INTERP, SELF, func);
03918bc chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgrind...
chromatic authored
181 nci_info->signature = string_make(interp, key_c, strlen(key_c),
182 NULL, PObj_constant_FLAG);
b6bc0c3 allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
183 Parrot_str_free_cstring(key_c);
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
184 pcc_params(INTERP, key, nci_info);
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
185
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
186 /* 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
187 nci_info->arity = Parrot_str_byte_length(INTERP, key) - 1;
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
188
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
189 /* Build call function. */
03918bc chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgrind...
chromatic authored
190 nci_info->func = (PMC *)(build_call_func(INTERP, SELF,
191 key, &jitted));
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
192 nci_info->jitted = jitted;
193 }
03918bc chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgrind...
chromatic authored
194
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
195 /*
196
197 =item C<void mark()>
198
199 Mark any referenced strings and PMCs.
200
201 =cut
202
203 */
204 VTABLE void mark() {
205 if (PARROT_NCI(SELF)) {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
206 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
207
208 if (nci_info->signature)
209 pobject_lives(interp, (PObj*)nci_info->signature);
210 if (nci_info->pcc_params_signature)
211 pobject_lives(interp, (PObj*)nci_info->pcc_params_signature);
212 }
65bd9bf eval #1
Leopold Toetsch authored
213 }
11b723d fixed memory leak in jitted i386 nci code; clone nci
Leopold Toetsch authored
214
c64e58f pmc docs update 3
Michael Scott authored
215 /*
216
217 =item C<void destroy()>
218
219 Destroys the NCI, freeing any allocated memory.
220
221 =cut
222
223 */
224
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
225 VTABLE void destroy() {
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
226 if (PMC_data(SELF)) {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
227 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
0176661 chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes a n...
chromatic authored
228
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
229 mem_sys_free(nci_info);
0176661 chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes a n...
chromatic authored
230 PMC_data(SELF) = NULL;
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
231 }
11b723d fixed memory leak in jitted i386 nci code; clone nci
Leopold Toetsch authored
232 }
233
c64e58f pmc docs update 3
Michael Scott authored
234 /*
235
236 =item C<PMC *clone()>
237
238 Creates and returns a clone of the NCI.
239
240 =cut
241
242 */
243
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
244 VTABLE PMC *clone() {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
245 Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
246 Parrot_NCI_attributes *nci_info_ret;
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
247 void *orig_func;
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
248
26f7d7b cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
249 PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
250 PMC_data(ret) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
251 nci_info_ret = PARROT_NCI(ret);
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
252
c64e58f pmc docs update 3
Michael Scott authored
253 /* FIXME if data is malloced (JIT/i386!) then we need
254 * the length of data here, to memcpy it
255 * ManagedStruct or Buffer?
256 */
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
257 nci_info_ret->func = nci_info_self->func;
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
258 nci_info_ret->orig_func = nci_info_self->orig_func;
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
259 nci_info_ret->signature = nci_info_self->signature;
260 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
261 nci_info_ret->arity = nci_info_self->arity;
37fe639 chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also fix...
chromatic authored
262 nci_info_ret->jitted = nci_info_self->jitted;
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
263 PObj_get_FLAGS(ret) |= (PObj_get_FLAGS(SELF) & 0x7);
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
264
c64e58f pmc docs update 3
Michael Scott authored
265 return ret;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
266 }
267
c64e58f pmc docs update 3
Michael Scott authored
268 /*
269
270 =item C<INTVAL defined()>
271
272 Returns whether the NCI is defined.
273
274 =cut
275
276 */
277
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
278 VTABLE INTVAL defined() {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
279 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
280 return nci_info->func != NULL;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
281 }
282
c64e58f pmc docs update 3
Michael Scott authored
283 /*
284
0ae5d55 Paul Cochrane Patch courtesy of Steve Peters <steve at fisharerojo dot org>, his comme...
paultcochrane authored
285 =item C<opcode_t *invoke(void *next)>
c64e58f pmc docs update 3
Michael Scott authored
286
8838c7f builtins 1 - first shot
Leopold Toetsch authored
287 Calls the associated C function, returning C<*next>. If
288 the invocant is a class, the PMC arguments are
289 shifted down.
c64e58f pmc docs update 3
Michael Scott authored
290
291 =cut
292
293 */
294
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
295 VTABLE opcode_t *invoke(void *next) {
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
296
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
297 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
298 nci_sub_t func;
299 void *orig_func;
300 PMC *cont;
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
301
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
302 GET_ATTR_orig_func(INTERP, SELF, orig_func);
303 func = PObj_flag_TEST(private2, SELF)
304 ? (nci_sub_t) D2FPTR(orig_func)
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
305 : (nci_sub_t) D2FPTR(nci_info->func);
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
306
b9b6c03 fix MMD wrapping for __is_equal
Leopold Toetsch authored
307 if (!func)
2255840 allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
308 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
b9b6c03 fix MMD wrapping for __is_equal
Leopold Toetsch authored
309 "attempt to call NULL function");
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
310
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
311 if (nci_info->jitted) {
312
313 nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
314
811a7df cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386 ji...
cotto authored
315 /* XXX: Some i386 jit code depends on this. If t/pmc/nci.t passes
316 * without it, the next line is safe to remove. */
317 PMC_struct_val(SELF) = nci_info->orig_func;
318
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
319 /* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
37fe639 chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also fix...
chromatic authored
320 jit_func(INTERP, SELF,
321 (char *) nci_info->pcc_params_signature->strstart);
2646951 tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
322 }
323 else {
324 if (PObj_flag_TEST(private2, SELF)) {
325 /* Parrot_eprintf(interp, "RAW NCI CALL\n"); */
326 }
327 else {
328 /* Parrot_eprintf(interp, "HACKED %S\n", nci_info->signature); */
329 }
330 func(INTERP, SELF);
331 }
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
332 cont = INTERP->current_cont;
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
333
8838c7f builtins 1 - first shot
Leopold Toetsch authored
334 /*
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
335 * If the NCI function was tailcalled, the return result
336 * is already passed back to the caller of this frame
337 * - see Parrot_init_ret_nci(). We therefore invoke the
338 * return continuation here, which gets rid of this frame
339 * and returns the real return address
8838c7f builtins 1 - first shot
Leopold Toetsch authored
340 */
bf41b66 Jerry Gay [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored
341 if (cont && cont != NEED_CONTINUATION &&
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
342 (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
637cc2a chromatic [src] Changed CONTEXT(interp->ctx) to CONTEXT(interp), which seems clear...
chromatic authored
343 cont = CONTEXT(interp)->current_cont;
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
344 next = VTABLE_invoke(INTERP, cont, next);
345 }
82c7cf6 chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
346
e063e49 chromatic Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
chromatic authored
347 return (opcode_t *)next;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
348 }
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
349
c64e58f pmc docs update 3
Michael Scott authored
350 /*
351
352 =item C<INTVAL get_integer()>
353
354 Returns the function pointer as an integer.
355
356 =cut
357
358 */
359
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
360 VTABLE INTVAL get_integer() {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
361 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f Jonathan Worthington Refactor the NCI PMC to have an underlying structure, in preparation for...
jnthn authored
362 return (INTVAL)nci_info->func;
3168931 Forth can now generate code for words on the fly and execute them.
Dan Sugalski authored
363 }
364
f35b03c Sam Ruby Initial support for sort
rubys authored
365 /*
366
367 =item C<INTVAL get_bool()>
368
369 Returns the boolean value of the pointer.
370
371 =cut
372
373 */
374
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
375 VTABLE INTVAL get_bool() {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
376 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
377 return (0 != (INTVAL)nci_info->func);
f35b03c Sam Ruby Initial support for sort
rubys authored
378 }
379
6586a2c Jonathan Worthington Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
380 /*
381
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
382 =item C<METHOD arity()>
6586a2c Jonathan Worthington Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
383
384 Return the arity of the NCI (the number of arugments).
385
386 =cut
387
388 */
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
389 METHOD arity() {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
390 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
48d2796 NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
391 INTVAL arity = 0;
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
392
48d2796 NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
393 if (nci_info && nci_info->func)
394 arity = nci_info->arity;
62e3049 Andy Lester consting, and fixed embedded tabs
petdance authored
395 else
37fe639 chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also fix...
chromatic authored
396 Parrot_ex_throw_from_c_args(INTERP, NULL,
397 EXCEPTION_INVALID_OPERATION,
2255840 allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
398 "You cannot get the arity of an undefined NCI.");
6586a2c Jonathan Worthington Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
399
48d2796 NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
400 RETURN(INTVAL arity);
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
401 }
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
402 }
c64e58f pmc docs update 3
Michael Scott authored
403
404 /*
405
406 =back
407
408 =head1 SEE ALSO
409
410 F<docs/pdds/pdd03_calling_conventions.pod>.
411
412 =head1 HISTORY
413
414 Initial revision by sean 2002/08/04.
415
416 =cut
417
418 */
419
0eb3eb3 added formatting footer and detabbed
Michael Scott authored
420 /*
421 * Local variables:
72575ae Bernhard Schmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored
422 * c-file-style: "parrot"
0eb3eb3 added formatting footer and detabbed
Michael Scott authored
423 * End:
424 * vim: expandtab shiftwidth=4:
72575ae Bernhard Schmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored
425 */
Something went wrong with that request. Please try again.