Skip to content

Commit

Permalink
lots of fixes. We still don't build completely, but we are much close…
Browse files Browse the repository at this point in the history
…r than we were
  • Loading branch information
Whiteknight committed Nov 14, 2010
1 parent 3ea891c commit e98ef02
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 110 deletions.
4 changes: 2 additions & 2 deletions compilers/imcc/main.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions config/gen/makefiles/root.in
Expand Up @@ -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) \
Expand Down Expand Up @@ -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
Expand Down
96 changes: 68 additions & 28 deletions include/parrot/api.h
Expand Up @@ -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)
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -78,58 +115,59 @@ 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)
__attribute__nonnull__(2)
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)
__attribute__nonnull__(2)
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)
__attribute__nonnull__(2)
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)
Expand All @@ -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) \
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion include/parrot/imcc.h
Expand Up @@ -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 */
Expand Down

0 comments on commit e98ef02

Please sign in to comment.