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