Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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