Skip to content
Newer
Older
100644 481 lines (414 sloc) 14.8 KB
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
1 /*
2 Copyright (C) 2010, Parrot Foundation.
3
4 =head1 NAME
5
6 src/embed/api.c - TO COME
7
8 =head1 DESCRIPTION
9
10 TO COME.
11
12 =cut
13
14 */
15
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
16 #include "parrot/parrot.h"
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
17 #include "parrot/runcore_api.h"
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
18 #include "parrot/embed.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
19 #include "parrot/api.h"
1b6d1ce @Whiteknight start breaking up the embedding stuff into multiple files. Add embed_…
Whiteknight authored
20 #include "embed_private.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
21
3f8ed92 @Whiteknight fix some file references and run headerizer to see my work so far
Whiteknight authored
22 /* HEADERIZER HFILE: include/parrot/api.h */
23
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
24 PARROT_API
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
25 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
26 Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
27 ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code),
28 ARGOUT(Parrot_String * errmsg))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
29 {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
30 EMBED_API_CALLIN(interp_pmc, interp)
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
31 *exit_code = interp->exit_code;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
32 *exception = interp->final_exception;
33 if (PMC_IS_NULL(exception)) {
34 *is_error = 0;
35 *errmsg = STRINGNULL;
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
36 }
37 else {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
38 *is_error = !interp->exit_code;
39 *errmsg = VTABLE_get_string(interp, *exception);
40 }
41 interp->final_exception = PMCNULL;
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
42 interp->exit_code = 0;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
43 EMBED_API_CALLOUT(interp_pmc, interp)
44 }
45
46 PARROT_API
47 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
48 Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
49 Parrot_PMC exception, ARGOUT(Parrot_String * bt))
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
50 {
51 EMBED_API_CALLIN(interp_pmc, interp)
52 STRING * const bts = Parrot_dbg_get_exception_backtrace(interp, exception);
53 *bt = bts;
54 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
55 }
56
57 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
58 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
59 Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
60 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
61 {
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
62 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
63 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
64 Parrot_Interp interp_raw;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
65 void *stacktop_ptr = &alt_stacktop;
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
66 PMC * iglobals;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to s…
Whiteknight authored
67 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
68 interp_raw = allocate_interpreter(parent_raw, flags);
69 if (args) {
70 if (args->stacktop)
71 stacktop_ptr = args->stacktop;
72 if (args->gc_system)
73 Parrot_gc_set_system_type(interp_raw, args->gc_system);
74 if (args->gc_threshold)
75 interp_raw->gc_threshold = args->gc_threshold;
76 if (args->hash_seed)
77 interp_raw->hash_seed = args->hash_seed;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
78 }
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
79 initialize_interpreter(interp_raw, stacktop_ptr);
80 iglobals = interp_raw->iglobals;
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
81 *interp = VTABLE_get_pmc_keyed_int(
82 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
83 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
84 }
85
86 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
87 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
88 Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
89 Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
90 {
91 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
92 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
93 if (trace) {
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
94 Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
95 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
96 }
97 else {
372f8f7 @bluescreen10 Make bounds runcore available
bluescreen10 authored
98 if (!strcmp(corename, "slow") || !strcmp(corename, "bounds"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
99 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
100 else if (!strcmp(corename, "fast") ||
101 !strcmp(corename, "jit") || !strcmp(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
102 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
103 else if (!strcmp(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
104 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
105 else if (!strcmp(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
106 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
107 else if (!strcmp(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
108 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
109 else if (!strcmp(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
110 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
111 else
112 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
113 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
114 EMBED_API_CALLOUT(interp_pmc, interp)
115 }
116
117 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
118 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
119 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
120 {
121 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
122 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
123 if (set)
124 interp->debug_flags |= flags;
125 else
126 interp->debug_flags &= ~flags;
127 EMBED_API_CALLOUT(interp_pmc, interp);
128 }
129
130 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
131 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
132 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
133 {
134 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
135 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
136 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
137 Interp_flags_SET(interp, flags);
138 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
139 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
140 }
141 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
142 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
143 EMBED_API_CALLOUT(interp_pmc, interp);
144 }
145
146 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
147 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
148 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
149 {
150 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
151 EMBED_API_CALLIN(interp_pmc, interp)
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for…
Whiteknight authored
152 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
153 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
154 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
155 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
156 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
157 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
158 }
159
160 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
161 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
162 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
163 {
164 ASSERT_ARGS(Parrot_api_destroy_interpreter)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
165 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
166 Parrot_destroy(interp);
ae620cc @Whiteknight changes necessary so we build. Run fails horribly, but we build
Whiteknight authored
167 Parrot_x_exit(interp, 0);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
168 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
169 }
170
171 /*
172
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
173 =over 4
174
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
175 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc, const
176 char *filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
177
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
178 Load a bytecode file and return a bytecode PMC.
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
179
180 =cut
181
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
182 // TODO: This only works with the inital bytecode. After this we should use
183 // Parrot_append_bytecode or something similar
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
184
185 */
186
187
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
188 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
189 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
190 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
191 ARGIN(const char *filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
192 {
193 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
194 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
195 PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
196 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
197 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
198 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
199 *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
200 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
201 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
202 }
203
204 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
205 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
206 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
207 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
208 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
209 {
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
210 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
211 PackFile * const pf = PackFile_new(interp, 0);
212 if (!pf)
213 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not create packfile");
214
215 if (!PackFile_unpack(interp, pf, (const opcode_t *)pbc, bytecode_size))
216 Parrot_ex_throw_from_c_args(interp, NULL, 1, "could not unpack packfile");
217 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
218 *pbcpmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
219 VTABLE_set_pointer(interp, *pbcpmc, pf);
220 EMBED_API_CALLOUT(interp_pmc, interp);
221 }
222
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
223 /*
224 *
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
225 // Load the bytecode into the interpreter, but don't execute it
226 // TODO: This only works with the inital bytecode. After this we should use
227 // Parrot_append_bytecode or something similar
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
228
229 */
230
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
231 PARROT_API
232 Parrot_Int
233 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
234 ARGOUT(Parrot_PMC *main_sub))
235 {
236 EMBED_API_CALLIN(interp_pmc, interp)
237 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
238
239 /* Debugging mode nonsense. */
240 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
241 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
242 interp->run_core->name);
243 }
244
245 if (!pf)
246 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
247 if (pf->cur_cs != NULL)
248 Parrot_pbc_load(interp, pf);
249 PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
250 PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
251 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
252 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
253 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
254 EMBED_API_CALLOUT(interp_pmc, interp)
255 }
256
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
257 PARROT_API
258 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
259 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
260 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
261 {
262 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
263 EMBED_API_CALLIN(interp_pmc, interp)
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. pa…
Whiteknight authored
264 PMC * main_sub = NULL;
265
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
266 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
267
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
268 /* Debugging mode nonsense. */
269 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
270 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
271 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
272 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
273
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
274 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
275 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
276 if (pf->cur_cs != NULL)
277 Parrot_pbc_load(interp, pf);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
278 PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
279 PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
280 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
281 main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
282
283 /* if no sub was marked being :main, we create a dummy sub with offset 0 */
284
285 if (!main_sub)
286 main_sub = set_current_sub(interp);
287
288 Parrot_pcc_set_sub(interp, CURRENT_CONTEXT(interp), NULL);
289 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
290
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c…
Whiteknight authored
291 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST, mainargs);
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. pa…
Whiteknight authored
292 Parrot_ext_call(interp, main_sub, "P->", mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
293 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
294 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
295
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
296 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
297 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
298 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
299 ARGIN(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
300 {
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
301 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
302 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
303 if (!pf)
304 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
305 if (pf->cur_cs != NULL)
306 Parrot_pbc_load(interp, pf);
307 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
308 EMBED_API_CALLOUT(interp_pmc, interp);
309 }
310
311 PARROT_API
312 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
313 Parrot_api_build_argv_array(Parrot_PMC interp_pmc, Parrot_Int argc,
314 ARGIN(char ** argv), ARGOUT(Parrot_PMC * args))
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
315 {
316 ASSERT_ARGS(Parrot_api_build_argv_array)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
317 EMBED_API_CALLIN(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
318 PMC * const userargv = Parrot_pmc_new(interp, enum_class_ResizableStringArray);
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
319 Parrot_Int i;
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
320
321 for (i = 0; i < argc; ++i) {
322 /* Run through argv, adding everything to the array */
323 STRING * const arg = Parrot_str_new_init(interp, argv[i], strlen(argv[i]),
324 Parrot_utf8_encoding_ptr, PObj_external_FLAG);
325 VTABLE_push_string(interp, userargv, arg);
326 }
327 *args = userargv;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
328 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
329 }
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
330
331 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
332 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
333 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
334 {
335 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
336 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
337 /* 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
338 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
339 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
340 }
341
342 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
343 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
344 Parrot_api_set_output_file(Parrot_PMC interp_pmc,
345 ARGIN_NULLOK(const char * filename))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
346 {
347 ASSERT_ARGS(Parrot_api_set_output_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
348 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
349 if (!filename && !interp->output_file)
350 interp->output_file = "-";
351 else
352 interp->output_file = filename;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
353 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
354 }
355
356 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
357 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
358 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
359 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
360 {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
361 //ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
362 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
363 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
364 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
365 }
366
367 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
368 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
369 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
370 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
371 {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
372 //ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
373 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
374 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
375 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
376 }
377
378 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
379 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
380 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
381 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
382 {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
383 //ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
384 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
385 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
386 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
387 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
388
389 /*
390
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
391 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
392 stdin, Parrot_Int stdout, Parrot_Int stderr)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
393
394 Set the std file descriptors for the embedded interpreter. Any file descriptor
395 passed as argument and set to C<PIO_INVALID_HANDLE> is ignored.
396
397 =cut
398
399 */
400
401 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
402 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
403 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int stdin,
404 Parrot_Int stdout, Parrot_Int stderr)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
405 {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
406 ASSERT_ARGS(Parrot_api_set_stdhandles)
407 EMBED_API_CALLIN(interp_pmc, interp)
408 void *dummy;
409
410 if(PIO_INVALID_HANDLE != (PIOHANDLE)stdin) {
411 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
412 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)stdin);
413 dummy = (void *)Parrot_io_stdhandle(interp,PIO_STDIN_FILENO,pmc);
414 }
415
416 if(PIO_INVALID_HANDLE != (PIOHANDLE)stdout) {
417 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
418 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)stdout);
419 dummy = (void *)Parrot_io_stdhandle(interp,PIO_STDOUT_FILENO,pmc);
420 }
421
422 if(PIO_INVALID_HANDLE != (PIOHANDLE)stderr) {
423 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
424 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)stderr);
425 dummy = (void *)Parrot_io_stdhandle(interp,PIO_STDERR_FILENO,pmc);
426 }
427
428 EMBED_API_CALLOUT(interp_pmc, interp)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
429 }
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
430
431 PARROT_API
432 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
433 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
434 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
435 {
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
436 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
437 *runtime = Parrot_get_runtime_path(interp);
438 EMBED_API_CALLOUT(interp_pmc, interp);
439 }
440
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
441 PARROT_API
442 Parrot_Int
443 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
444 {
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
445 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
446 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts tha…
Whiteknight authored
447 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
448 EMBED_API_CALLOUT(interp_pmc, interp);
449 }
450
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
451 /*
452 This is an evil hack to provide a wrapper around IMCC to catch unhandled
453 exceptions without having to assume IMCC is linked in with libparrot. Delete
454 this as soon as we don't need it anymore.
455 */
456
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
457 PARROT_API
458 Parrot_Int
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
459 Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char * sourcefile,
460 int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
461 imcc_hack_func_t func)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
462 {
463 EMBED_API_CALLIN(interp_pmc, interp)
464 *result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
465 EMBED_API_CALLOUT(interp_pmc, interp)
466 }
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
467
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
468 /*
469
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
470 =back
471
472 =cut
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
473 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
474
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
475 /*
476 * Local variables:
477 * c-file-style: "parrot"
478 * End:
479 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
480 */
Something went wrong with that request. Please try again.