Skip to content
Browse files

remove the field interp->output_file. Instead, we let IMCC parse that…

… option internally for now and not burden the interp with that information
  • Loading branch information...
1 parent c68e224 commit 2471580b7316eb4289d0012a8aa927077d65aecd @Whiteknight Whiteknight committed Jan 14, 2011
Showing with 13 additions and 52 deletions.
  1. +11 −10 compilers/imcc/main.c
  2. +2 −8 frontend/parrot/main.c
  3. +0 −6 include/parrot/api.h
  4. +0 −2 include/parrot/interpreter.h
  5. +0 −26 src/embed/api.c
View
21 compilers/imcc/main.c
@@ -75,7 +75,7 @@ static void imcc_get_optimization_description(
__attribute__nonnull__(3)
FUNC_MODIFIES(*opt_desc);
-static void imcc_parseflags(PARROT_INTERP,
+static char * imcc_parseflags(PARROT_INTERP,
int argc,
ARGIN(const char **argv))
__attribute__nonnull__(1)
@@ -226,19 +226,21 @@ Parrot_cmd_options(void)
/*
-=item C<static void imcc_parseflags(PARROT_INTERP, int argc, const char **argv)>
+=item C<static char * imcc_parseflags(PARROT_INTERP, int argc, const char
+**argv)>
Parse flags ans set approptiate state(s)
=cut
*/
-static void
+static char *
imcc_parseflags(PARROT_INTERP, int argc, ARGIN(const char **argv))
{
ASSERT_ARGS(imcc_parseflags)
struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT;
+ char * output_file = NULL;
/* default state: run pbc */
SET_STATE_RUN_PBC(interp);
@@ -283,14 +285,14 @@ imcc_parseflags(PARROT_INTERP, int argc, ARGIN(const char **argv))
break;
case 'o':
UNSET_STATE_RUN_PBC(interp);
- interp->output_file = opt.opt_arg;
+ output_file = opt.opt_arg;
break;
case OPT_PBC_OUTPUT:
UNSET_STATE_RUN_PBC(interp);
SET_STATE_WRITE_PBC(interp);
- if (!interp->output_file)
- interp->output_file = "-";
+ if (!output_file)
+ output_file = "-";
break;
case 'O':
@@ -317,6 +319,7 @@ imcc_parseflags(PARROT_INTERP, int argc, ARGIN(const char **argv))
break;
}
}
+ return output_file;
}
/*
@@ -481,7 +484,7 @@ imcc_write_pbc(PARROT_INTERP, ARGIN(const char *output_file))
size_t size;
opcode_t *packed;
FILE *fp;
- PackFile_ByteCode * interp_code = Parrot_pf_get_current_code_segment(interp);
+ PackFile_ByteCode * const interp_code = Parrot_pf_get_current_code_segment(interp);
IMCC_info(interp, 1, "Writing %s\n", output_file);
@@ -682,11 +685,9 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc,
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);
+ const char * output_file = imcc_parseflags(interp, argc, argv);
/* PMCs in IMCC_INFO won't get marked */
Parrot_block_GC_mark(interp);
View
10 frontend/parrot/main.c
@@ -460,14 +460,14 @@ Parrot_cmd_options(void)
{ 'X', 'X', OPTION_required_FLAG, { "--dynext" } },
{ '\0', OPT_DESTROY_FLAG, (OPTION_flags)0,
{ "--leak-test", "--destroy-at-end" } },
+ { 'o', 'o', OPTION_required_FLAG, { "--output" } },
+ { '\0', OPT_PBC_OUTPUT, (OPTION_flags)0, { "--output-pbc" } },
{ '\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" } },
@@ -716,12 +716,6 @@ parseflags(Parrot_PMC interp,
/* result = Parrot_api_set_warnings(interp, PARROT_WARNINGS_ALL_FLAG); */
result = Parrot_api_set_warnings(interp, 0xFFFF);
break;
- case 'o':
- result = Parrot_api_set_output_file(interp, opt.opt_arg);
- break;
- case OPT_PBC_OUTPUT:
- result = Parrot_api_set_output_file(interp, NULL);
- break;
default:
/* languages handle their arguments later (after being initialized) */
break;
View
6 include/parrot/api.h
@@ -207,11 +207,6 @@ Parrot_Int Parrot_api_set_executable_name(
__attribute__nonnull__(2);
PARROT_API
-Parrot_Int Parrot_api_set_output_file(
- Parrot_PMC interp_pmc,
- ARGIN_NULLOK(const char * filename));
-
-PARROT_API
Parrot_Int Parrot_api_set_runcore(
Parrot_PMC interp_pmc,
ARGIN(const char * corename),
@@ -283,7 +278,6 @@ Parrot_Int Parrot_api_wrap_imcc_hack(
#define ASSERT_ARGS_Parrot_api_set_executable_name \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(name))
-#define ASSERT_ARGS_Parrot_api_set_output_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_set_runcore __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(corename))
#define ASSERT_ARGS_Parrot_api_set_warnings __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
View
2 include/parrot/interpreter.h
@@ -207,8 +207,6 @@ struct parrot_interp_t {
struct _imc_info_t *imc_info; /* imcc data */
Hash *op_hash; /* mapping from op names to op_info_t */
- const char *output_file; /* where to write output */
-
PDB_t *pdb; /* debug /trace system */
PMC *dynamic_env; /* Dynamic environment stack */
View
26 src/embed/api.c
@@ -519,32 +519,6 @@ Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags)
/*
-=item C<Parrot_Int Parrot_api_set_output_file(Parrot_PMC interp_pmc, const char
-* filename)>
-
-Sets the C<interp_pmc>'s output file name specified by C<filename>. This function
-returns a true value if this call is successful and false value otherwise.
-
-=cut
-
-*/
-
-PARROT_API
-Parrot_Int
-Parrot_api_set_output_file(Parrot_PMC interp_pmc,
- ARGIN_NULLOK(const char * filename))
-{
- ASSERT_ARGS(Parrot_api_set_output_file)
- EMBED_API_CALLIN(interp_pmc, interp)
- if (!filename && !interp->output_file)
- interp->output_file = "-";
- else
- interp->output_file = filename;
- EMBED_API_CALLOUT(interp_pmc, interp)
-}
-
-/*
-
=item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
const char *path)>

0 comments on commit 2471580

Please sign in to comment.
Something went wrong with that request. Please try again.