Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 818 lines (626 sloc) 23.53 kB
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
1 /*
2 Copyright (C) 2010, Parrot Foundation.
3
4 =head1 NAME
5
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
6 src/embed/api.c - The Parrot embedding interface
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
7
8 =head1 DESCRIPTION
9
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
10 This file implements functions of the Parrot embedding interface.
11
12 =head2 Functions
13
14 =over 4
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
15
16 =cut
17
18 */
19
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
20 #include "parrot/parrot.h"
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
21 #include "parrot/runcore_api.h"
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
22 #include "parrot/embed.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
23 #include "parrot/api.h"
1b6d1ce @Whiteknight start breaking up the embedding stuff into multiple files. Add embed_…
Whiteknight authored
24 #include "embed_private.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
25
3f8ed92 @Whiteknight fix some file references and run headerizer to see my work so far
Whiteknight authored
26 /* HEADERIZER HFILE: include/parrot/api.h */
27
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
28
29 /*
30
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
31 =item C<Parrot_Int Parrot_api_get_result(Parrot_PMC interp_pmc, Parrot_Int
32 *is_error, Parrot_PMC * exception, Parrot_Int *exit_code, Parrot_String *
33 errmsg)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
34
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
35 Gets the results of the last API function call and stores the results in
36 C<is_error>, C<exception>, C<exit_code> and C<errmsg>. This function returns
37 a true value if this call is successful and false value otherwise. The stored
38 information is as follow:
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
39
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
40 C<is_error> a true value if an unhandled exception was thrown or the program
41 terminated with an error condition and a false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
42
43 C<exception> the last exception thrown.
44
45 C<exit_code> the exit code of the running program.
46
47 C<errmsg> contains an string with the last error message.
48
49 =cut
50
51 */
52
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
53 PARROT_API
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
54 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
55 Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
56 ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code),
57 ARGOUT(Parrot_String * errmsg))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
58 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
59 ASSERT_ARGS(Parrot_api_get_result)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
60 EMBED_API_CALLIN(interp_pmc, interp)
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
61 *exit_code = interp->exit_code;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
62 *exception = interp->final_exception;
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
63 if (PMC_IS_NULL(*exception)) {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
64 *is_error = 0;
65 *errmsg = STRINGNULL;
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
66 }
67 else {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
68 *is_error = !interp->exit_code;
69 *errmsg = VTABLE_get_string(interp, *exception);
70 }
71 interp->final_exception = PMCNULL;
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
72 interp->exit_code = 0;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
73 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
74 }
75
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
76 /*
77
78 =item C<Parrot_Int Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
79 Parrot_PMC exception, Parrot_String * bt)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
80
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
81 Gets the backtrace of the interpreter's call chain for the given exception
82 C<expcetion> and stores the results in string C<bt>. This function returns a
83 true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
84
85 =cut
86
87 */
88
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
89 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
90 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
91 Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
92 Parrot_PMC exception, ARGOUT(Parrot_String * bt))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
93 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
94 ASSERT_ARGS(Parrot_api_get_exception_backtrace)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
95 EMBED_API_CALLIN(interp_pmc, interp)
96 STRING * const bts = Parrot_dbg_get_exception_backtrace(interp, exception);
97 *bt = bts;
98 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
99 }
100
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
101
102 /*
103
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
104 =item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int
105 flags, Parrot_Init_Args *args, Parrot_PMC *interp)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
106
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
107 Creates a new interpreter and stores it in C<interp>. It takes three optional
108 parameters the new interpreter's C<flags>, the initialization paremeters C<args>
109 and the C<parent> interpreter. This function returns a true value if this call
110 is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
111
112 =cut
113
114 */
115
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
116 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
117 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
118 Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
119 ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(Parrot_PMC *interp))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
120 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
121 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
122 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
123 Parrot_Interp interp_raw;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
124 void *stacktop_ptr = &alt_stacktop;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to s…
Whiteknight authored
125 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
126 interp_raw = allocate_interpreter(parent_raw, flags);
127 if (args) {
128 if (args->stacktop)
129 stacktop_ptr = args->stacktop;
130 if (args->gc_system)
131 Parrot_gc_set_system_type(interp_raw, args->gc_system);
132 if (args->gc_threshold)
133 interp_raw->gc_threshold = args->gc_threshold;
134 if (args->hash_seed)
135 interp_raw->hash_seed = args->hash_seed;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
136 }
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
137 initialize_interpreter(interp_raw, stacktop_ptr);
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
138 *interp = VTABLE_get_pmc_keyed_int(
139 interp_raw, interp_raw->iglobals, (Parrot_Int)IGLOBALS_INTERPRETER);
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
140 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
141 }
142
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
143 /*
144
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
145 =item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, const char *
146 corename, Parrot_UInt trace)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
147
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
148 Sets the C<interp_pmc>'s bytecode running core, the core is specified by the
149 C<corename>. This function returns a true value if this call is successful and
150 false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
151
152 =cut
153
154 */
155
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
156 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
157 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
158 Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
159 Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
160 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
161 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
162 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
163 if (trace) {
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
164 Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
165 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
166 }
167 else {
372f8f7 @bluescreen10 Make bounds runcore available
bluescreen10 authored
168 if (!strcmp(corename, "slow") || !strcmp(corename, "bounds"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
169 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
170 else if (!strcmp(corename, "fast") ||
171 !strcmp(corename, "jit") || !strcmp(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
172 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
173 else if (!strcmp(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
174 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
175 else if (!strcmp(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
176 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
177 else if (!strcmp(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
178 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
179 else if (!strcmp(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
180 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "gcdebug"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
181 else
182 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
183 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
184 EMBED_API_CALLOUT(interp_pmc, interp)
185 }
186
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
187 /*
188
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
189 =item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
190 flags, Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
191
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
192 Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
193 flags are set otherwise debug flags are cleared. This function returns a true
194 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
195
196 =cut
197
198 */
199
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
200 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
201 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
202 Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
203 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
204 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
205 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
206 if (set)
207 interp->debug_flags |= flags;
208 else
209 interp->debug_flags &= ~flags;
210 EMBED_API_CALLOUT(interp_pmc, interp);
211 }
212
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
213 /*
214
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
215 =item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
216 Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
217
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
218 Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
219 flags are set otherwise passed flags are cleared. This function returns a true
220 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
221
222 =cut
223
224 */
225
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
226 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
227 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
228 Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
229 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
230 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
231 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
232 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
233 Interp_flags_SET(interp, flags);
234 if (flags & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG))
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
235 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
236 }
237 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
238 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
239 EMBED_API_CALLOUT(interp_pmc, interp);
240 }
241
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
242 /*
243
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
244 =item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
245 char * name)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
246
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
247 Sets the executable name for the C<interp_pmc> interpreter. This function returns
248 a true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
249
250 =cut
251
252 */
253
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
254 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
255 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
256 Parrot_api_set_executable_name(Parrot_PMC interp_pmc, ARGIN(const char * name))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
257 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
258 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
259 EMBED_API_CALLIN(interp_pmc, interp)
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for…
Whiteknight authored
260 STRING * const name_str = Parrot_str_new(interp, name, 0);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
261 PMC * const name_pmc = Parrot_pmc_new(interp, enum_class_String);
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for…
Whiteknight authored
262 VTABLE_set_string_native(interp, name_pmc, name_str);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
263 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
264 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
265 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
266 }
267
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
268 /*
269
270 =item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
271
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
272 Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
273 for it. This function returns a true value if this call is successful and false
274 value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
275
276 =cut
277
278 */
279
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
280 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
281 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
282 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
283 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
284 ASSERT_ARGS(Parrot_api_destroy_interpreter)
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
285 void * _oldtop;
286 Parrot_jump_buff env;
287 Interp * const interp = GET_INTERP(interp_pmc);
288 _oldtop = interp->lo_var_ptr;
289 if (_oldtop == NULL)
290 interp->lo_var_ptr = &_oldtop;
291 interp->api_jmp_buf = &env;
292 if (setjmp(env)) {
293 /* We can't check for potential errors because the interpreter
294 * might have been destroyed. */
295 return 1;
296 }
297 else {
298 Parrot_destroy(interp);
299 Parrot_x_exit(interp, 0);
300 /* Never reached, x_exit calls longjmp */
301 return 1;
302 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
303 }
304
305 /*
306
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
307 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc, const
308 char *filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
309
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
310 Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
311 returns a true value if this call is successful and false value otherwise.
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
312
313 =cut
314
315 */
316
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
317 /* TODO: This only works with the inital bytecode. After this we should use
318 Parrot_append_bytecode or something similar */
319
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
320 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
321 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
322 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
323 ARGIN(const char *filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
324 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
325 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
326 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
327 PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
328 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
329 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not load packfile");
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
330 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
950d701 @Whiteknight Packfile PMCs don't do what I need them to do (yet). Use UnManagedStr…
Whiteknight authored
331 *pbc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
332 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
333 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
334 }
335
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
336 /*
337
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
338 =item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
339 unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
340
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
341 Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
342 the resulting bytecode in C<pbcpmc>. This function returns a true value if this
343 call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
344
345 =cut
346
347 */
348
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
349 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
350 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
351 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
352 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
353 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
354 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
355 ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
356 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
357 PackFile * const pf = PackFile_new(interp, 0);
358 if (!pf)
359 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not create packfile");
360
361 if (!PackFile_unpack(interp, pf, (const opcode_t *)pbc, bytecode_size))
362 Parrot_ex_throw_from_c_args(interp, NULL, 1, "could not unpack packfile");
363 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
364 *pbcpmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
365 VTABLE_set_pointer(interp, *pbcpmc, pf);
366 EMBED_API_CALLOUT(interp_pmc, interp);
367 }
368
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
369 /* Load the bytecode into the interpreter, but don't execute it */
370 /* TODO: This only works with the inital bytecode. After this we should use
371 Parrot_append_bytecode or something similar */
372
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
373 /*
374
375 =item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
376 pbc, Parrot_PMC *main_sub)>
377
378 Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
379 C<main_sub>. This function returns a true value if this call is successful and
380 false value otherwise.
381
382 =cut
383
384 */
385
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
386 PARROT_API
387 Parrot_Int
388 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
389 ARGOUT(Parrot_PMC *main_sub))
390 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
391 ASSERT_ARGS(Parrot_api_ready_bytecode)
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
392 EMBED_API_CALLIN(interp_pmc, interp)
393 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
394
395 /* Debugging mode nonsense. */
396 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
397 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
398 interp->run_core->name);
399 }
400
401 if (!pf)
402 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
403 if (pf->cur_cs != NULL)
404 Parrot_pbc_load(interp, pf);
405 PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
406 PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
407 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
408 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
409 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
410 EMBED_API_CALLOUT(interp_pmc, interp)
411 }
412
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
413
414 /*
415
416 =item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
417 pbc, Parrot_PMC mainargs)>
418
419 Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
420 returns a true value if this call is successful and false value otherwise.
421
422 =cut
423
424 */
425
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
426 PARROT_API
427 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
428 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
429 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
430 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
431 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
432 EMBED_API_CALLIN(interp_pmc, interp)
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. pa…
Whiteknight authored
433 PMC * main_sub = NULL;
434
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
435 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c…
Whiteknight authored
436
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
437 /* Debugging mode nonsense. */
438 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
439 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
440 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
441 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
442
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
443 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
444 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
445 if (pf->cur_cs != NULL)
446 Parrot_pbc_load(interp, pf);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
447 PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
448 PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
449 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. pa…
Whiteknight authored
450 main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
451
452 /* if no sub was marked being :main, we create a dummy sub with offset 0 */
453
454 if (!main_sub)
455 main_sub = set_current_sub(interp);
456
457 Parrot_pcc_set_sub(interp, CURRENT_CONTEXT(interp), NULL);
458 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
459
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c…
Whiteknight authored
460 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST, mainargs);
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
461 Parrot_pcc_invoke_sub_from_c_args(interp, main_sub, "P->", mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
462 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
463 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
464
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
465 /*
466
467 =item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
468 Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
469
470 Disassembles and prints out the C<pbc> bytecode. This function returns a true
471 value if this call is successful and false value otherwise.
472
473 =cut
474
475 */
476
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
477 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
478 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
479 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
480 ARGIN_NULLOK(const char * const outfile), Parrot_Int opts)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
481 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
482 ASSERT_ARGS(Parrot_api_disassemble_bytecode)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
483 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
484 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
485 if (!pf)
486 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
487 if (pf->cur_cs != NULL)
488 Parrot_pbc_load(interp, pf);
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
489 /* TODO: Break up the dependency with emebed.c */
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
490 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
491 EMBED_API_CALLOUT(interp_pmc, interp);
492 }
493
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
494 /*
495
496 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
497 flags)>
498
499 Enables C<inter_pmc>'s warning messages the type of warning information to be
500 print out is specified by C<flags>. This function returns a true value if this
501 call is successful and false value otherwise.
502
503 =cut
504
505 */
506
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
507 PARROT_API
508 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
509 Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
510 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
511 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
512 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
513 /* Activates the given warnings. (Macro from warnings.h.) */
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
514 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
515 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
516 }
517
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
518 /*
519
520 =item C<Parrot_Int Parrot_api_set_output_file(Parrot_PMC interp_pmc, const char
521 * filename)>
522
523 Sets the C<interp_pmc>'s output file name specified by C<filename>. This function
524 returns a true value if this call is successful and false value otherwise.
525
526 =cut
527
528 */
529
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
530 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
531 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
532 Parrot_api_set_output_file(Parrot_PMC interp_pmc,
533 ARGIN_NULLOK(const char * filename))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
534 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
535 ASSERT_ARGS(Parrot_api_set_output_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
536 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
537 if (!filename && !interp->output_file)
538 interp->output_file = "-";
539 else
540 interp->output_file = filename;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
541 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
542 }
543
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
544 /*
545
546 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
547 const char *path)>
548
549 Adds C<path> to the C<inter_pmc>'s library search path list. This function
550 returns a true value if this call is successful and false value otherwise.
551
552 =cut
553
554 */
555
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
556 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
557 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
558 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
559 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
560 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
561 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
562 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
563 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
564 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
565 }
566
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
567 /*
568
569 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
570 const char *path)>
571
572 Adds C<path> to the C<inter_pmc>'s include search path list. This function
573 returns a true value if this call is successful and false value otherwise.
574
575 =cut
576
577 */
578
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
579 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
580 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
581 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
582 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
583 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
584 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
585 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
586 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
587 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
588 }
589
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
590 /*
591
592 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
593 const char *path)>
594
595 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
596 returns a true value if this call is successful and false value otherwise.
597
598 =cut
599
600 */
601
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
602 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
603 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
604 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
605 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
606 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
607 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
608 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
609 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
610 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
611 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
612
613 /*
614
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
615 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
616 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
617
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
618 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
619 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
620 a true value if this call is successful and false value otherwise.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
621
622 =cut
623
624 */
625
626 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
627 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
628 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
629 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
630 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
631 ASSERT_ARGS(Parrot_api_set_stdhandles)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
632 EMBED_API_CALLIN(interp_pmc, interp)
633 void *dummy;
634
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
635 if (PIO_INVALID_HANDLE != (PIOHANDLE)in) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
636 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
637 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)in);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
638 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDIN_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
639 }
640
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
641 if (PIO_INVALID_HANDLE != (PIOHANDLE)out) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
642 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
643 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)out);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
644 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDOUT_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
645 }
646
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
647 if (PIO_INVALID_HANDLE != (PIOHANDLE)err) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
648 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
649 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)err);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
650 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDERR_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
651 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
652 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
653
654 EMBED_API_CALLOUT(interp_pmc, interp)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
655 }
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
656
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
657 /*
658
659 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
660 Parrot_String *runtime)>
661
662 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
663 true value if this call is successful and false value otherwise.
664
665 =cut
666
667 */
668
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
669 PARROT_API
670 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
671 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
672 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
673 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
674 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
675 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
676 *runtime = Parrot_get_runtime_path(interp);
677 EMBED_API_CALLOUT(interp_pmc, interp);
678 }
679
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
680 /*
681
682 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
683 Parrot_PMC confighash)>
684
685 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
686 function returns a true value if this call is successful and false value
687 otherwise.
688
689 =cut
690
691 */
692
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
693 PARROT_API
694 Parrot_Int
695 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
696 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
697 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
698 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
699 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts tha…
Whiteknight authored
700 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
701 EMBED_API_CALLOUT(interp_pmc, interp);
702 }
703
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
704 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
705
706 =item C<Parrot_Int Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char *
707 sourcefile, int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
708 imcc_hack_func_t func)>
709
710 WARNING: This is an evil hack to provide a wrapper around IMCC to catch unhandled
711 exceptions without having to assume IMCC is linked in with libparrot. Delete this
712 as soon as we don't need it anymore.
713
714 This function returns a true value if this call is successful and false value
715 otherwise.
716
717 =cut
718
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
719 */
720
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
721 PARROT_API
722 Parrot_Int
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
723 Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char * sourcefile,
724 int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
725 imcc_hack_func_t func)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
726 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
727 ASSERT_ARGS(Parrot_api_wrap_imcc_hack)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
728 EMBED_API_CALLIN(interp_pmc, interp)
729 *result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
730 EMBED_API_CALLOUT(interp_pmc, interp)
731 }
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
732
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
733 /*
734
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
735 =item C<Parrot_Int Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
736 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
737
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
738 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
739 function returns a true value if this call is successful and false value
740 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
741
742 =cut
743
744 */
745
746 PARROT_API
747 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
748 Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
749 {
750 ASSERT_ARGS(Parrot_api_load_language)
751 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
752 Parrot_load_language(interp, lang);
753 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
754 }
755
756 /*
757
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
758 =item C<Parrot_Int Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
759 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
760
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
761 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
762 value if this call is successful and false value otherwise.
763
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
764 =cut
765
766 */
767
768 PARROT_API
769 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
770 Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
771 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
772 {
773 ASSERT_ARGS(Parrot_api_get_compiler)
774 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
775 *compiler = Parrot_get_compiler(interp, type);
776 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
777 }
778
779 /*
780
781 =item C<Parrot_Int Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
782 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
783
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
784 Sets the C<compiler> object for the C<type> files. This function returns a true
785 value if this call is successful and false value otherwise.
786
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
787 =cut
788
789 */
790
791 PARROT_API
792 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
793 Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
794 Parrot_PMC compiler)
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
795 {
796 ASSERT_ARGS(Parrot_api_set_compiler)
797 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
798 Parrot_set_compiler(interp, type, compiler);
799 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
800 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
801
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a …
nol888 authored
802
0814f94 Merged changes with branch
Mariano Wahlmann authored
803 /*
804
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
805 =back
806
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
807 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
808
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
809 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
810
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
811 /*
812 * Local variables:
813 * c-file-style: "parrot"
814 * End:
815 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
816 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
817
Something went wrong with that request. Please try again.