diff --git a/compilers/imcc/main.c b/compilers/imcc/main.c index 2440723c96..0bd5b6055c 100644 --- a/compilers/imcc/main.c +++ b/compilers/imcc/main.c @@ -651,7 +651,7 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc, pf_raw = Parrot_pbc_read(interp, sourcefile, 0); if (!pf_raw) IMCC_fatal_standalone(interp, 1, "main: Packfile loading failed\n"); - Parrot_pbc_load(interp, pf); + Parrot_pbc_load(interp, pf_raw); } else pf_raw = compile_to_bytecode(interp, sourcefile, output_file, yyscanner); @@ -689,7 +689,7 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc, yylex_destroy(yyscanner); if (pf_raw) { - PMC * const _pbcpmc = Parrot_pmc_new(interp, enum_class_PackFile); + PMC * const _pbcpmc = Parrot_pmc_new(interp, enum_class_Packfile); VTABLE_set_pointer(interp, _pbcpmc, pf_raw); *pbcpmc = _pbcpmc; } diff --git a/config/gen/makefiles/root.in b/config/gen/makefiles/root.in index 3ab210db85..1e562a87a0 100644 --- a/config/gen/makefiles/root.in +++ b/config/gen/makefiles/root.in @@ -454,6 +454,7 @@ INTERP_O_FILES = \ src/dynext$(O) \ src/embed$(O) \ src/embed/api$(O) \ + src/embed/strings$(O) \ src/string/encoding$(O) \ src/exceptions$(O) \ src/exit$(O) \ @@ -1590,6 +1591,12 @@ src/embed$(O) : $(PARROT_H_HEADERS) $(INC_DIR)/embed.h \ compilers/imcc/unit.h \ include/pmc/pmc_sub.h +src/embed/api$(O) : $(PARROT_H_HEADERS) $(INC_DIR)/api.h \ + src/embed/api.c + +src/embed/strings$(O) : $(PARROT_H_HEADERS) $(INC_DIR)/api.h \ + src/embed/strings.c + src/dataypes$(O) : $(GENERAL_H_FILES) src/dataypes.c src/exit$(O) : $(PARROT_H_HEADERS) src/exit.c diff --git a/include/parrot/api.h b/include/parrot/api.h index 7f01f37e7d..89f40b7a12 100644 --- a/include/parrot/api.h +++ b/include/parrot/api.h @@ -9,26 +9,54 @@ #ifndef PARROT_API_H_GUARD #define PARROT_API_H_GUARD +#include "parrot/compiler.h" #include "parrot/config.h" #include "parrot/core_types.h" -#include "pmc/pmc_parrotinterpreter.h" #define PARROT_API PARROT_EXPORT +/* having a modified version of PARROT_ASSERT which resolves as an integer + * rvalue lets us put ASSERT_ARGS() at the top of the list of local variables. + * Thus, we can catch bad pointers before any of the local initialization + * logic is run. And it always returns 0, so headerizer can chain them in + * ASSERT_ARGS_* macros like: + * int _ASSERT_ARGS = PARROT_ASSERT_ARG(a) || PARROT_ASSERT_ARG(b) || ... + */ +#ifdef NDEBUG +# define PARROT_ASSERT(x) /*@-noeffect@*/((void)0)/*@=noeffect@*/ +# define PARROT_ASSERT_ARG(x) (0) +# define PARROT_FAILURE(x) /*@-noeffect@*/((void)0)/*@=noeffect@*/ +# define PARROT_ASSERT_MSG(x, s) /*@-noeffect@*/((void)0)/*@=noeffect@*/ +# define ASSERT_ARGS(a) +#else +# define PARROT_ASSERT(x) (x) ? ((void)0) : Parrot_confess(#x, __FILE__, __LINE__) +# define PARROT_ASSERT_ARG(x) ((x) ? (0) : (Parrot_confess(#x, __FILE__, __LINE__), 0)) +# define PARROT_FAILURE(x) Parrot_confess((x), __FILE__, __LINE__) +# define PARROT_ASSERT_MSG(x, s) ((x) ? (0) : (Parrot_confess(s, __FILE__, __LINE__), 0)) + +# ifdef __GNUC__ +# define ASSERT_ARGS(a) ASSERT_ARGS_ ## a ; +# else +# define ASSERT_ARGS(a) +# endif /* __GNUC__ */ + +#endif /* NDEBUG */ + + typedef struct _Parrot_Init_Args { void *stacktop; char * gc_system; - INTVAL gc_threshold; - INTVAL hash_seed; + Parrot_Int gc_threshold; + Parrot_Int hash_seed; } Parrot_Init_Args; /* HEADERIZER BEGIN: src/embed/api.c */ /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ PARROT_API -INTVAL Parrot_api_build_argv_array( +Parrot_Int Parrot_api_build_argv_array( ARGMOD(PMC *interp_pmc), - INTVAL argc, + Parrot_Int argc, ARGIN(char **argv), ARGOUT(PMC **args)) __attribute__nonnull__(1) @@ -38,15 +66,24 @@ INTVAL Parrot_api_build_argv_array( FUNC_MODIFIES(*args); PARROT_API -INTVAL Parrot_api_destroy_interpreter(ARGIN(PMC *interp_pmc)) - __attribute__nonnull__(1); +Parrot_Int Parrot_api_debug_flag( + ARGMOD(PMC *interp_pmc), + Parrot_Int flags, + Parrot_Int set) + __attribute__nonnull__(1) + FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrot_api_exit_interpreter(ARGIN(PMC *interp_pmc)) +Parrot_Int Parrot_api_destroy_interpreter(ARGIN(PMC *interp_pmc)) __attribute__nonnull__(1); PARROT_API -INTVAL Parrot_api_load_bytecode_file( +Parrot_Int Parrot_api_flag(ARGMOD(PMC *interp_pmc), Parrot_Int flags, Parrot_Int set) + __attribute__nonnull__(1) + FUNC_MODIFIES(*interp_pmc); + +PARROT_API +Parrot_Int Parrot_api_load_bytecode_file( ARGMOD(PMC *interp_pmc), ARGIN(const char *filename), ARGOUT(PMC **pbc)) @@ -59,16 +96,16 @@ INTVAL Parrot_api_load_bytecode_file( PARROT_API PARROT_CANNOT_RETURN_NULL PARROT_MALLOC -INTVAL Parrot_api_make_interpreter( +Parrot_Int Parrot_api_make_interpreter( ARGIN_NULLOK(PMC *parent), - INTVAL flags, + Parrot_Int flags, ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(PMC **interp)) __attribute__nonnull__(4) FUNC_MODIFIES(*interp); PARROT_API -INTVAL Parrot_api_run_bytecode( +Parrot_Int Parrot_api_run_bytecode( ARGMOD(PMC *interp_pmc), ARGIN(PMC *pbc), ARGIN(PMC *mainargs)) @@ -78,14 +115,15 @@ INTVAL Parrot_api_run_bytecode( FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrot_api_set_executable_name( - ARGIN(PMC *interp_pmc), - ARGIN(Parrot_String) name) +Parrot_Int Parrot_api_set_executable_name( + ARGMOD(PMC *interp_pmc), + ARGIN(const char * name)) __attribute__nonnull__(1) - __attribute__nonnull__(2); + __attribute__nonnull__(2) + FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrot_api_set_output_file( +Parrot_Int Parrot_api_set_output_file( ARGMOD(PMC *interp_pmc), ARGIN(const char * filename)) __attribute__nonnull__(1) @@ -93,27 +131,27 @@ INTVAL Parrot_api_set_output_file( FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrot_api_set_runcore( +Parrot_Int Parrot_api_set_runcore( ARGIN(PMC *interp_pmc), Parrot_Run_core_t core, Parrot_UInt trace) __attribute__nonnull__(1); PARROT_API -INTVAL Parrot_api_set_stdhandles( +Parrot_Int Parrot_api_set_stdhandles( ARGIN(PMC *interp_pmc), - INTVAL stdin, - INTVAL stdout, - INTVAL stderr) + Parrot_Int stdin, + Parrot_Int stdout, + Parrot_Int stderr) __attribute__nonnull__(1); PARROT_API -INTVAL Parrot_api_set_warnings(ARGMOD(PMC *interp_pmc), INTVAL flags) +Parrot_Int Parrot_api_set_warnings(ARGMOD(PMC *interp_pmc), Parrot_Int flags) __attribute__nonnull__(1) FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrt_api_add_dynext_search_path( +Parrot_Int Parrt_api_add_dynext_search_path( ARGMOD(PMC *interp_pmc), ARGIN(const char *path)) __attribute__nonnull__(1) @@ -121,7 +159,7 @@ INTVAL Parrt_api_add_dynext_search_path( FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrt_api_add_include_search_path( +Parrot_Int Parrt_api_add_include_search_path( ARGMOD(PMC *interp_pmc), ARGIN(const char *path)) __attribute__nonnull__(1) @@ -129,7 +167,7 @@ INTVAL Parrt_api_add_include_search_path( FUNC_MODIFIES(*interp_pmc); PARROT_API -INTVAL Parrt_api_add_library_search_path( +Parrot_Int Parrt_api_add_library_search_path( ARGMOD(PMC *interp_pmc), ARGIN(const char *path)) __attribute__nonnull__(1) @@ -140,10 +178,12 @@ INTVAL Parrt_api_add_library_search_path( PARROT_ASSERT_ARG(interp_pmc) \ , PARROT_ASSERT_ARG(argv) \ , PARROT_ASSERT_ARG(args)) +#define ASSERT_ARGS_Parrot_api_debug_flag __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ + PARROT_ASSERT_ARG(interp_pmc)) #define ASSERT_ARGS_Parrot_api_destroy_interpreter \ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp_pmc)) -#define ASSERT_ARGS_Parrot_api_exit_interpreter __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ +#define ASSERT_ARGS_Parrot_api_flag __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp_pmc)) #define ASSERT_ARGS_Parrot_api_load_bytecode_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp_pmc) \ @@ -158,7 +198,7 @@ INTVAL Parrt_api_add_library_search_path( #define ASSERT_ARGS_Parrot_api_set_executable_name \ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp_pmc) \ - , PARROT_ASSERT_ARG(Parrot_String)) + , PARROT_ASSERT_ARG(name)) #define ASSERT_ARGS_Parrot_api_set_output_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp_pmc) \ , PARROT_ASSERT_ARG(filename)) diff --git a/include/parrot/imcc.h b/include/parrot/imcc.h index fff86a2929..7d868d5a37 100644 --- a/include/parrot/imcc.h +++ b/include/parrot/imcc.h @@ -5,7 +5,7 @@ #ifndef PARROT_IMCC_H_GUARD #define PARROT_IMCC_H_GUARD -PARROT_EXPORT int imcc_run(PARROT_INTERP, const char *sourcefile, int argc, const char **argv); +PARROT_EXPORT int imcc_run(PARROT_INTERP, const char *sourcefile, int argc, const char **argv, ARGOUT(PMC **pbcpmc)); PARROT_EXPORT void imcc_run_pbc(PARROT_INTERP, const char *outputfile, int argc, const char **argv); #endif /* PARROT_IMCC_H_GUARD */ diff --git a/src/embed/api.c b/src/embed/api.c index 3cda5048c7..d56f23124d 100644 --- a/src/embed/api.c +++ b/src/embed/api.c @@ -1,4 +1,5 @@ #include "parrot/parrot.h" +#include "parrot/embed.h" #include "parrot/api.h" #include "embed_private.h" @@ -6,45 +7,38 @@ PARROT_API PARROT_CANNOT_RETURN_NULL -PARROT_MALLOC -INTVAL -Parrot_api_make_interpreter(ARGIN_NULLOK(PMC *parent), INTVAL flags, ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(PMC **interp)) +Parrot_Int +Parrot_api_make_interpreter(ARGIN_NULLOK(PMC *parent), Parrot_Int flags, ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(PMC **interp)) { ASSERT_ARGS(Parrot_api_make_interpreter) int alt_stacktop; - Parrot_Interp * const interp_raw; - PMC * interp_pmc; + struct parrot_interp_t * interp_raw; void *stacktop_ptr = &alt_stacktop; + PMC * iglobals; - //SHOULD Parrot_set_config_hash(); - //BE Parrot_set_config_internal_hash(); + Parrot_set_config_hash(); { - Parrot_Interp * const parent_raw; - parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent); + Parrot_Interp * const parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent); interp_raw = allocate_interpreter(parent_raw, flags); if (args) { if (args->stacktop) stacktop_ptr = args->stacktop; - if (args->gc_system) { - const INTVAL sysid = Parrot_gc_get_system_id(interp, args->gc_system); - if (sysid == -1) - // EMBED_API_FAILURE(interp_pmc, interp); - // This doesn't works without EMBED_API_CALLIN - interp->gc_sys->sys_type = sysid; - } + if (args->gc_system) + Parrot_gc_set_system_type(interp_raw, args->gc_system); if (args->gc_threshold) - interp->gc_threshold = args->gc_threshold; + interp_raw->gc_threshold = args->gc_threshold; if (args->hash_seed) - interp->hash_seed = args->hash_seed; + interp_raw->hash_seed = args->hash_seed; } } - initialize_interpreter(interp_raw, stacktop); - *interp_pmc = VTABLE_get_pmc_keyed_int(interp, iglobals, (INTVAL)IGLOBALS_INTERPRETER); + initialize_interpreter(interp_raw, stacktop_ptr); + iglobals = interp_raw->iglobals; + *interp = VTABLE_get_pmc_keyed_int(interp, iglobals, (Parrot_Int)IGLOBALS_INTERPRETER); return !PMC_IS_NULL(*interp); } PARROT_API -INTVAL +Parrot_Int Parrot_api_set_runcore(ARGIN(PMC *interp_pmc), Parrot_Run_core_t core, Parrot_UInt trace) { ASSERT_ARGS(Parrot_api_set_runcore) @@ -57,8 +51,8 @@ Parrot_api_set_runcore(ARGIN(PMC *interp_pmc), Parrot_Run_core_t core, Parrot_UI } PARROT_API -INTVAL -Parrot_api_debug_flag(ARGMOD(PMC *interp_pmc), INTVAL flags, INTVAL set) +Parrot_Int +Parrot_api_debug_flag(ARGMOD(PMC *interp_pmc), Parrot_Int flags, Parrot_Int set) { ASSERT_ARGS(Parrot_api_debug_flag) EMBED_API_CALLIN(interp_pmc, interp); @@ -70,23 +64,23 @@ Parrot_api_debug_flag(ARGMOD(PMC *interp_pmc), INTVAL flags, INTVAL set) } PARROT_API -INTVAL -Parrot_api_flag(ARGMOD(PMC *interp_pmc), INTVAL flags, INTVAL set) +Parrot_Int +Parrot_api_flag(ARGMOD(PMC *interp_pmc), Parrot_Int flags, Parrot_Int set) { ASSERT_ARGS(Parrot_api_flag) EMBED_API_CALLIN(interp_pmc, interp); if (set) { - Interp_flags_SET(interp, flag); - if (flag & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG)) + Interp_flags_SET(interp, flags); + if (flags & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG)) Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow")); } else - Interp_flags_CLEAR(interp, flag); + Interp_flags_CLEAR(interp, flags); EMBED_API_CALLOUT(interp_pmc, interp); } PARROT_API -INTVAL +Parrot_Int Parrot_api_set_executable_name(ARGMOD(PMC *interp_pmc), ARGIN(const char * name)) { ASSERT_ARGS(Parrot_api_set_executable_name) @@ -100,7 +94,7 @@ Parrot_api_set_executable_name(ARGMOD(PMC *interp_pmc), ARGIN(const char * name) } PARROT_API -INTVAL +Parrot_Int Parrot_api_destroy_interpreter(ARGIN(PMC *interp_pmc)) { ASSERT_ARGS(Parrot_api_destroy_interpreter) @@ -112,8 +106,8 @@ Parrot_api_destroy_interpreter(ARGIN(PMC *interp_pmc)) /* -=item C +=item C Load a bytecode file and return a bytecode PMC. @@ -122,7 +116,7 @@ Load a bytecode file and return a bytecode PMC. */ PARROT_API -INTVAL +Parrot_Int Parrot_api_load_bytecode_file(ARGMOD(PMC *interp_pmc), ARGIN(const char *filename), ARGOUT(PMC **pbc)) { ASSERT_ARGS(Parrot_api_load_bytecode_file) @@ -130,13 +124,13 @@ Parrot_api_load_bytecode_file(ARGMOD(PMC *interp_pmc), ARGIN(const char *filenam PackFile * const pf = Parrot_pbc_read(interp, filename, 0); if (!pf) EMBED_API_FAILURE(interp_pmc, interp); - *pbc = Parrot_pmc_new(interp, enum_class_PackFile); + *pbc = Parrot_pmc_new(interp, enum_class_Packfile); VTABLE_set_pointer(interp, *pbc, pf); EMBED_API_CALLOUT(interp_pmc, interp); } PARROT_API -INTVAL +Parrot_Int Parrot_api_run_bytecode(ARGMOD(PMC *interp_pmc), ARGIN(PMC *pbc), ARGIN(PMC *mainargs)) { ASSERT_ARGS(Parrot_api_run_bytecode) @@ -152,13 +146,13 @@ Parrot_api_run_bytecode(ARGMOD(PMC *interp_pmc), ARGIN(PMC *pbc), ARGIN(PMC *mai } PARROT_API -INTVAL -Parrot_api_build_argv_array(ARGMOD(PMC *interp_pmc), INTVAL argc, ARGIN(char **argv), ARGOUT(PMC **args)) +Parrot_Int +Parrot_api_build_argv_array(ARGMOD(PMC *interp_pmc), Parrot_Int argc, ARGIN(char **argv), ARGOUT(PMC **args)) { ASSERT_ARGS(Parrot_api_build_argv_array) EMBED_API_CALLIN(interp_pmc, interp); PMC * const userargv = Parrot_pmc_new(interp, enum_class_ResizableStringArray); - INTVAL i; + Parrot_Int i; for (i = 0; i < argc; ++i) { /* Run through argv, adding everything to the array */ @@ -167,22 +161,22 @@ Parrot_api_build_argv_array(ARGMOD(PMC *interp_pmc), INTVAL argc, ARGIN(char **a VTABLE_push_string(interp, userargv, arg); } *args = userargv; - EMBED_API_CALLIN(interp_pmc, interp); + EMBED_API_CALLOUT(interp_pmc, interp); } PARROT_API -INTVAL -Parrot_api_set_warnings(ARGMOD(PMC *interp_pmc), INTVAL flags) +Parrot_Int +Parrot_api_set_warnings(ARGMOD(PMC *interp_pmc), Parrot_Int flags) { ASSERT_ARGS(Parrot_api_set_warnings) EMBED_API_CALLIN(interp_pmc, interp); /* Activates the given warnings. (Macro from warnings.h.) */ - PARROT_WARNINGS_on(interp, (Parrot_warnclass)flags); + PARROT_WARNINGS_on(interp, flags); EMBED_API_CALLOUT(interp_pmc, interp); } PARROT_API -INTVAL +Parrot_Int Parrot_api_set_output_file(ARGMOD(PMC *interp_pmc), ARGIN(const char * filename)) { ASSERT_ARGS(Parrot_api_set_output_file) @@ -195,30 +189,30 @@ Parrot_api_set_output_file(ARGMOD(PMC *interp_pmc), ARGIN(const char * filename) } PARROT_API -INTVAL +Parrot_Int Parrt_api_add_library_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path)) { - ASSERT_ARGS(Parrot_api_add_library_search_path) + //ASSERT_ARGS(Parrot_api_add_library_search_path) EMBED_API_CALLIN(interp_pmc, interp); Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY); EMBED_API_CALLOUT(interp_pmc, interp); } PARROT_API -INTVAL +Parrot_Int Parrt_api_add_include_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path)) { - ASSERT_ARGS(Parrot_api_add_include_search_path) + //ASSERT_ARGS(Parrot_api_add_include_search_path) EMBED_API_CALLIN(interp_pmc, interp); Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE); EMBED_API_CALLOUT(interp_pmc, interp); } PARROT_API -INTVAL +Parrot_Int Parrt_api_add_dynext_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path)) { - ASSERT_ARGS(Parrot_api_add_dynext_search_path) + //ASSERT_ARGS(Parrot_api_add_dynext_search_path) EMBED_API_CALLIN(interp_pmc, interp); Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT); EMBED_API_CALLOUT(interp_pmc, interp); @@ -226,8 +220,8 @@ Parrt_api_add_dynext_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path /* -=item C +=item C Set the std file descriptors for the embedded interpreter. Any file descriptor passed as argument and set to C is ignored. @@ -237,8 +231,8 @@ passed as argument and set to C is ignored. */ PARROT_API -INTVAL -Parrot_api_set_stdhandles(ARGIN(PMC *interp_pmc), INTVAL stdin, INTVAL stdout, INTVAL stderr) +Parrot_Int +Parrot_api_set_stdhandles(ARGIN(PMC *interp_pmc), Parrot_Int stdin, Parrot_Int stdout, Parrot_Int stderr) { ASSERT_ARGS(Parrot_api_set_stdhandles) EMBED_API_CALLIN(interp_pmc, interp); diff --git a/src/embed/embed_private.h b/src/embed/embed_private.h index c7975afcc4..2fccdf7414 100644 --- a/src/embed/embed_private.h +++ b/src/embed/embed_private.h @@ -1,22 +1,23 @@ -#define GET_RAW_INTERP(p) ((Parrot_ParrotInterpreter_attributes)(p)->data)->interp; + +#ifndef PARROT_EMBED_PRIVATE_H +#define PARROT_EMBED_PRIVATE_H + +#include "pmc/pmc_parrotinterpreter.h" + +#define GET_RAW_INTERP(p) ((Parrot_ParrotInterpreter_attributes*)(p)->data)->interp; #define EMBED_API_CALLIN(p, i) \ - jmp_buf _env; \ void * _oldtop; \ Interp * (i) = PMC_IS_NULL(p) ? NULL : GET_RAW_INTERP(p); \ _oldtop = (i)->lo_var_ptr; \ - if (_oldtop) {} else (1)->lo_var_ptr = &oldtop \ - PARROT_ASSERT(i); \ - PARROT_ASSERT((i)->lo_val_ptr); \ - if (setjmp(_env)) { \ - (i)->api_jmp_buf = NULL; \ + if (_oldtop) {} else (i)->lo_var_ptr = &_oldtop; \ + if (setjmp((i)->api_jmp_buf)) { \ return 0; \ } else { \ - (i)->api_jmp_buf = _env; \ { #define EMBED_API_CALLOUT(p, i) \ } \ if (!_oldtop) {\ - PARROT_ASSERT((i)->lo_var_ptr == &oldtop);\ + PARROT_ASSERT((i)->lo_var_ptr == &_oldtop);\ (i)->lo_var_ptr = NULL;\ }\ return 1; \ @@ -25,8 +26,11 @@ #define EMBED_API_FAILURE(p, i) \ do { \ if (!_oldtop) {\ - PARROT_ASSERT((i)->lo_var_ptr == &oldtop);\ + PARROT_ASSERT((i)->lo_var_ptr == &_oldtop);\ (i)->lo_var_ptr = NULL;\ } \ return 0; \ - } + } while(0); + + +#endif /* PARROT_EMBED_PRIVATE_H */ diff --git a/src/embed/strings.c b/src/embed/strings.c index 4bd23f4ea2..d484029aeb 100644 --- a/src/embed/strings.c +++ b/src/embed/strings.c @@ -8,7 +8,7 @@ PARROT_API INTVAL Parrot_api_string_export(ARGMOD(PMC *interp_pmc), ARGIN(Parrot_String *string), ARGOUT(char ** strout)) { - ASSERT_ARGS(Parrot_api_string_export) + //ASSERT_ARGS(Parrot_api_string_export) EMBED_API_CALLIN(interp_pmc, interp); /* TODO */ EMBED_API_CALLOUT(interp_pmc, interp); @@ -18,7 +18,7 @@ PARROT_API INTVAL Parrot_api_string_import(ARGMOD(PMC *interp_pmc), ARGIN(const char * str), ARGOUT(Parrot_String ** out)) { - ASSERT_ARGS(Parrot_api_string_import) + //ASSERT_ARGS(Parrot_api_string_import) EMBED_API_CALLIN(interp_pmc, interp); *out = Parrot_str_new(interp, str, 0); EMBED_API_CALLOUT(interp_pmc, interp); diff --git a/src/exit.c b/src/exit.c index 031ac67f6a..a0fdf26a39 100644 --- a/src/exit.c +++ b/src/exit.c @@ -93,7 +93,7 @@ Parrot_exit(PARROT_INTERP, int status) } if (interp->api_jmp_buf) - longjump(api_jmp_buf); + longjump(interp->api_jmp_buf); else exit(status); } diff --git a/src/gc/api.c b/src/gc/api.c index e88371a4af..3d000bb6f8 100644 --- a/src/gc/api.c +++ b/src/gc/api.c @@ -106,17 +106,16 @@ implementation, and malloc wrappers for various purposes. These are unused. #endif PARROT_EXPORT -INTVAL -Parrot_gc_get_system_id(PARROT_INTERP, const char *name) +void +Parrot_gc_set_system_type(PARROT_INTERP, const char *name) { - ASSERT_ARGS(Parrot_gc_get_system_id) + //ASSERT_ARGS(Parrot_gc_set_system_type) if (STREQ(name, "MS")) - return MS; + interp->gc_sys->sys_type = MS; if (STREQ(name, "MS2")) - return MS2; + interp->gc_sys->sys_type = MS2; if (STREQ(name, "INF")) - return INF; - return -1; + interp->gc_sys->sys_type = INF; } /* diff --git a/src/main.c b/src/main.c index b309d3a232..507b142542 100644 --- a/src/main.c +++ b/src/main.c @@ -18,6 +18,8 @@ Start Parrot */ #include +#include +#include #include "parrot/api.h" @@ -161,7 +163,7 @@ PARROT_PURE_FUNCTION static int is_all_digits(ARGIN(const char *s)) { - ASSERT_ARGS(is_all_digits) + ASSERT_ARGS(is_all_digits); for (; *s; ++s) if (!isdigit((unsigned char)*s)) return 0; @@ -184,7 +186,7 @@ PARROT_PURE_FUNCTION static int is_all_hex_digits(ARGIN(const char *s)) { - ASSERT_ARGS(is_all_hex_digits) + ASSERT_ARGS(is_all_hex_digits); for (; *s; ++s) if (!isxdigit(*s)) return 0; @@ -434,8 +436,8 @@ parseflags_minimal(Parrot_Init_Args *initargs, int argc, ARGIN(const char *argv[ /* =item C +*argv[], int *pgm_argc, const char ***pgm_argv, Parrot_Int *core, Parrot_Int +*trace)> Parse Parrot's command line for options and set appropriate flags. @@ -448,7 +450,7 @@ static const char * parseflags(PMC *interp, int argc, ARGIN(const char *argv[]), ARGOUT(int *pgm_argc), ARGOUT(const char ***pgm_argv), - ARGMOD(Parrot_Run_core_t *core), ARGMOD(Parrot_trace_flags *trace)) + ARGMOD(Parrot_Int *core), ARGMOD(Parrot_Int *trace)) { ASSERT_ARGS(parseflags) struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT;