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