Skip to content

Commit

Permalink
fix some conflicts in branch merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Dec 23, 2010
2 parents a6f2157 + 33cfd36 commit 4e02ead
Show file tree
Hide file tree
Showing 53 changed files with 4,266 additions and 781 deletions.
7 changes: 7 additions & 0 deletions MANIFEST
Expand Up @@ -910,6 +910,7 @@ frontend/parrot_debugger/main.c []
frontend/pbc_dump/main.c []
frontend/pbc_dump/packdump.c []
frontend/pbc_merge/main.c []
include/parrot/api.h [main]include
include/parrot/atomic.h [main]include
include/parrot/atomic/fallback.h [main]include
include/parrot/atomic/gcc_pcc.h [main]include
Expand Down Expand Up @@ -1255,6 +1256,10 @@ src/dynpmc/rational.pmc []
src/dynpmc/rotest.pmc []
src/dynpmc/subproxy.pmc []
src/embed.c []
src/embed/api.c []
src/embed/embed_private.h []
src/embed/pmc.c []
src/embed/strings.c []
src/exceptions.c []
src/exit.c []
src/extend.c []
Expand Down Expand Up @@ -1942,6 +1947,8 @@ t/src/README []doc
t/src/atomic.t [test]
t/src/basic.t [test]
t/src/embed.t [test]
t/src/embed/pmc.t [test]
t/src/embed/strings.t [test]
t/src/exit.t [test]
t/src/extend.t [test]
t/src/pointer_array.t [test]
Expand Down
2 changes: 2 additions & 0 deletions compilers/imcc/Rules.in
Expand Up @@ -157,6 +157,8 @@ compilers/imcc/main$(O) : \
$(INC_DIR)/imcc.h \
$(INC_DIR)/oplib/ops.h \
$(INC_DIR)/runcore_api.h \
$(INC_DIR)/api.h \
$(INC_DIR)/longopt.h \
$(PARROT_H_HEADERS)

## SUFFIX OVERRIDE - Warnings (This is generated code)
Expand Down
2 changes: 1 addition & 1 deletion compilers/imcc/debug.c
Expand Up @@ -96,7 +96,7 @@ IMCC_fatal_standalone(PARROT_INTERP, int code, ARGIN(const char *fmt), ...)
va_start(ap, fmt);
imcc_vfprintf(interp, Parrot_io_STDERR(interp), fmt, ap);
va_end(ap);
Parrot_x_exit(interp, code);
Parrot_x_jump_out_error(interp, code);
}

/*
Expand Down
115 changes: 100 additions & 15 deletions compilers/imcc/main.c
Expand Up @@ -44,7 +44,7 @@ extern int yydebug;
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */

static void compile_to_bytecode(PARROT_INTERP,
static PackFile * compile_to_bytecode(PARROT_INTERP,
ARGIN(const char * const sourcefile),
ARGIN_NULLOK(const char * const output_file),
ARGIN(yyscan_t yyscanner))
Expand Down Expand Up @@ -89,6 +89,7 @@ PARROT_PURE_FUNCTION
static int is_all_hex_digits(ARGIN(const char *s))
__attribute__nonnull__(1);

static const struct longopt_opt_decl * Parrot_cmd_options(void);
#define ASSERT_ARGS_compile_to_bytecode __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(sourcefile) \
Expand All @@ -113,6 +114,7 @@ static int is_all_hex_digits(ARGIN(const char *s))
, PARROT_ASSERT_ARG(output_file))
#define ASSERT_ARGS_is_all_hex_digits __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_Parrot_cmd_options __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */

Expand Down Expand Up @@ -146,6 +148,59 @@ is_all_hex_digits(ARGIN(const char *s))
return 1;
}

/*
=item C<static const struct longopt_opt_decl * Parrot_cmd_options(void)>
Set up the const struct declaration for cmd_options
=cut
*/

/* TODO: Weed out the options that IMCC doesn't use, and rename this function
to something more imcc-ish
*/

static const struct longopt_opt_decl *
Parrot_cmd_options(void)
{
static const struct longopt_opt_decl cmd_options[] = {
{ '.', '.', (OPTION_flags)0, { "--wait" } },
{ 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
{ 'E', 'E', (OPTION_flags)0, { "--pre-process-only" } },
{ 'G', 'G', (OPTION_flags)0, { "--no-gc" } },
{ '\0', OPT_HASH_SEED, OPTION_required_FLAG, { "--hash-seed" } },
{ 'I', 'I', OPTION_required_FLAG, { "--include" } },
{ 'L', 'L', OPTION_required_FLAG, { "--library" } },
{ 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
{ 'R', 'R', OPTION_required_FLAG, { "--runcore" } },
{ 'g', 'g', OPTION_required_FLAG, { "--gc" } },
{ '\0', OPT_GC_THRESHOLD, OPTION_required_FLAG, { "--gc-threshold" } },
{ 'V', 'V', (OPTION_flags)0, { "--version" } },
{ 'X', 'X', OPTION_required_FLAG, { "--dynext" } },
{ '\0', OPT_DESTROY_FLAG, (OPTION_flags)0,
{ "--leak-test", "--destroy-at-end" } },
{ '\0', OPT_GC_DEBUG, (OPTION_flags)0, { "--gc-debug" } },
{ 'a', 'a', (OPTION_flags)0, { "--pasm" } },
{ 'c', 'c', (OPTION_flags)0, { "--pbc" } },
{ 'd', 'd', OPTION_optional_FLAG, { "--imcc-debug" } },
{ '\0', OPT_HELP_DEBUG, (OPTION_flags)0, { "--help-debug" } },
{ 'h', 'h', (OPTION_flags)0, { "--help" } },
{ 'o', 'o', OPTION_required_FLAG, { "--output" } },
{ '\0', OPT_PBC_OUTPUT, (OPTION_flags)0, { "--output-pbc" } },
{ 'r', 'r', (OPTION_flags)0, { "--run-pbc" } },
{ '\0', OPT_RUNTIME_PREFIX, (OPTION_flags)0, { "--runtime-prefix" } },
{ 't', 't', OPTION_optional_FLAG, { "--trace" } },
{ 'v', 'v', (OPTION_flags)0, { "--verbose" } },
{ 'w', 'w', (OPTION_flags)0, { "--warnings" } },
{ 'y', 'y', (OPTION_flags)0, { "--yydebug" } },
{ 0, 0, (OPTION_flags)0, { NULL } }
};
return cmd_options;
}


/*
=item C<static void imcc_parseflags(PARROT_INTERP, int argc, const char **argv)>
Expand All @@ -165,7 +220,7 @@ imcc_parseflags(PARROT_INTERP, int argc, ARGIN(const char **argv))
/* default state: run pbc */
SET_STATE_RUN_PBC(interp);

while (longopt_get(interp, argc, argv, Parrot_cmd_options(), &opt) > 0) {
while (longopt_get(argc, argv, Parrot_cmd_options(), &opt) > 0) {
switch (opt.opt_id) {
case 'd':
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
Expand Down Expand Up @@ -522,7 +577,7 @@ determine_output_file_type(PARROT_INTERP, ARGIN(const char *output_file))

/*
=item C<static void compile_to_bytecode(PARROT_INTERP, const char * const
=item C<static PackFile * compile_to_bytecode(PARROT_INTERP, const char * const
sourcefile, const char * const output_file, yyscan_t yyscanner)>
Compile source code into bytecode (or die trying).
Expand All @@ -531,7 +586,7 @@ Compile source code into bytecode (or die trying).
*/

static void
static PackFile *
compile_to_bytecode(PARROT_INTERP,
ARGIN(const char * const sourcefile),
ARGIN_NULLOK(const char * const output_file),
Expand Down Expand Up @@ -571,8 +626,9 @@ compile_to_bytecode(PARROT_INTERP,
fprintf(stderr, "error:imcc:%s", error_str);
IMCC_print_inc(interp);
Parrot_str_free_cstring(error_str);

imc_cleanup(interp, yyscanner);
Parrot_x_exit(interp, IMCC_FATAL_EXCEPTION);
Parrot_x_jump_out_error(interp, IMCC_FATAL_EXCEPTION);
}

imc_cleanup(interp, yyscanner);
Expand All @@ -582,12 +638,34 @@ compile_to_bytecode(PARROT_INTERP,
IMCC_info(interp, 1, "%ld lines compiled.\n", IMCC_INFO(interp)->line);
if (per_pbc && !IMCC_INFO(interp)->write_pbc)
PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
return pf;
}

/*
=item C<int imcc_run_api(PMC * interp_pmc, const char *sourcefile, int argc,
const char **argv, PMC **pbcpmc)>
This is a wrapper around C<imcc_run> function in which the input parameter is a
PMC interpreter.
=cut
*/

PARROT_API
int
imcc_run_api(ARGMOD(PMC * interp_pmc), ARGIN(const char *sourcefile), int argc,
ARGIN(const char **argv), ARGOUT(PMC **pbcpmc))
{
Interp * interp = (Interp *)VTABLE_get_pointer(NULL, interp_pmc);
return imcc_run(interp, sourcefile, argc, argv, pbcpmc);
}

/*
=item C<int imcc_run(PARROT_INTERP, const char *sourcefile, int argc, const char
**argv)>
**argv, PMC **pbcpmc)>
Entry point of IMCC, as invoked by Parrot's main function.
Compile source code (if required), write bytecode file (if required)
Expand All @@ -599,10 +677,12 @@ and run. This function always returns 0.

int
imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc,
ARGIN(const char **argv))
ARGIN(const char **argv), ARGOUT(PMC **pbcpmc))
{
yyscan_t yyscanner;
const char * const output_file = interp->output_file;
PackFile * pf_raw = NULL;
*pbcpmc = PMCNULL;

imcc_parseflags(interp, argc, argv);

Expand Down Expand Up @@ -645,12 +725,13 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc,
/* If the input file is Parrot bytecode, then we simply read it
into a packfile, which Parrot then loads */
if (STATE_LOAD_PBC(interp)) {
const int loaded = Parrot_load_bytecode_file(interp, sourcefile);
if (!loaded)
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_raw);
}
else
compile_to_bytecode(interp, sourcefile, output_file, yyscanner);
pf_raw = compile_to_bytecode(interp, sourcefile, output_file, yyscanner);

/* Produce a PBC output file, if one was requested */
if (STATE_WRITE_PBC(interp)) {
Expand All @@ -662,13 +743,11 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc,

/* If necessary, load the file written above */
if (STATE_RUN_FROM_FILE(interp) && !STREQ(output_file, "-")) {
PackFile *pf;

IMCC_info(interp, 1, "Loading %s\n", output_file);
pf = Parrot_pbc_read(interp, output_file, 0);
if (!pf)
pf_raw = Parrot_pbc_read(interp, output_file, 0);
if (!pf_raw)
IMCC_fatal_standalone(interp, 1, "Packfile loading failed\n");
Parrot_pbc_load(interp, pf);
Parrot_pbc_load(interp, pf_raw);
SET_STATE_LOAD_PBC(interp);
}
}
Expand All @@ -686,6 +765,12 @@ 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_UnManagedStruct);
VTABLE_set_pointer(interp, _pbcpmc, pf_raw);
*pbcpmc = _pbcpmc;
}

/* should the bytecode be run */
if (STATE_RUN_PBC(interp))
return 1;
Expand Down
1 change: 1 addition & 0 deletions config/auto/ipv6/test.in
@@ -1,4 +1,5 @@
/*

Copyright (C) 2010, Parrot Foundation.

*/
Expand Down

0 comments on commit 4e02ead

Please sign in to comment.