Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move -G commandline argument parsing from IMCC into the frontend

  • Loading branch information...
commit 255a8d8f91e77a38eee79fe17a9b3e7b5ebd53e0 1 parent bd67e17
@Whiteknight Whiteknight authored
View
1  compilers/imcc/imc.h
@@ -548,7 +548,6 @@ typedef struct _imc_info_t {
int emitter;
int error_code; /* The Error code. */
int expect_pasm;
- int gc_off;
int imcc_warn;
int in_pod;
int ins_line;
View
14 compilers/imcc/main.c
@@ -250,13 +250,8 @@ imcc_parseflags(PARROT_INTERP, int argc, ARGIN_NULLOK(const char **argv))
}
break;
case 'w':
- /* FIXME It's not best way to set warnings... */
- Parrot_setwarnings(interp, PARROT_WARNINGS_ALL_FLAG);
IMCC_INFO(interp)->imcc_warn = 1;
break;
- case 'G':
- IMCC_INFO(interp)->gc_off = 1;
- break;
case 'a':
SET_STATE_PASM_FILE(interp);
break;
@@ -657,10 +652,6 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile),
PackFile * pf_raw = NULL;
*pbcpmc = PMCNULL;
- /* PMCs in IMCC_INFO won't get marked */
- Parrot_block_GC_mark(interp);
- Parrot_block_GC_sweep(interp);
-
yylex_init_extra(interp, &yyscanner);
/* Figure out what kind of source file we have -- if we have one */
@@ -734,11 +725,6 @@ imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile),
else
PARROT_WARNINGS_off(interp, PARROT_WARNINGS_ALL_FLAG);
- if (!IMCC_INFO(interp)->gc_off) {
- Parrot_unblock_GC_mark(interp);
- Parrot_unblock_GC_sweep(interp);
- }
-
yylex_destroy(yyscanner);
if (pf_raw) {
View
10 frontend/parrot/main.c
@@ -30,6 +30,7 @@ struct init_args_t {
Parrot_Int trace;
Parrot_Int execute_packfile;
Parrot_Int have_pbc_file;
+ Parrot_Int turn_gc_off;
};
extern int Parrot_set_config_hash(Parrot_PMC interp_pmc);
@@ -177,12 +178,17 @@ main(int argc, const char *argv[])
if (!Parrot_api_load_bytecode_file(interp, parsed_flags.sourcefile,
&bytecodepmc))
show_last_error_and_exit(interp);
+ if (parsed_flags.turn_gc_off)
+ Parrot_api_toggle_gc(interp, 0);
}
else {
+ Parrot_api_toggle_gc(interp, 0);
if (!Parrot_api_wrap_imcc_hack(interp, parsed_flags.sourcefile, argc, argv,
&bytecodepmc, &parsed_flags.execute_packfile,
imcc_run_api))
show_last_error_and_exit(interp);
+ if (!parsed_flags.turn_gc_off)
+ Parrot_api_toggle_gc(interp, 1);
}
if (parsed_flags.execute_packfile) {
@@ -638,6 +644,7 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
args->execute_packfile = 1;
args->have_pbc_file = 0;
args->trace = 0;
+ args->turn_gc_off = 0;
if (argc == 1) {
usage(stderr);
@@ -652,6 +659,9 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
case 'g':
/* Handled in parseflags_minimal */
break;
+ case 'G':
+ args->turn_gc_off = 1;
+ break;
case OPT_GC_THRESHOLD:
/* handled in parseflags_minimal */
break;
View
4 include/parrot/api.h
@@ -225,6 +225,9 @@ PARROT_API
Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags);
PARROT_API
+Parrot_Int Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on);
+
+PARROT_API
Parrot_Int Parrot_api_wrap_imcc_hack(
Parrot_PMC interp_pmc,
ARGIN(const char * sourcefile),
@@ -291,6 +294,7 @@ Parrot_Int Parrot_api_wrap_imcc_hack(
#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)
+#define ASSERT_ARGS_Parrot_api_toggle_gc __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_wrap_imcc_hack __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(sourcefile) \
, PARROT_ASSERT_ARG(bytecodepmc) \
View
28 src/embed/api.c
@@ -807,9 +807,35 @@ Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
ASSERT_ARGS(Parrot_api_set_compiler)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_set_compiler(interp, type, compiler);
- EMBED_API_CALLOUT(interp_pmc, interp);
+ EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)>
+
+Turn Parrot's GC on or off.
+
+=cut
+
+*/
+
+PARROT_API
+Parrot_Int
+Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)
+{
+ ASSERT_ARGS(Parrot_api_toggle_gc)
+ EMBED_API_CALLIN(interp_pmc, interp)
+ if (on) {
+ Parrot_unblock_GC_mark(interp);
+ Parrot_unblock_GC_sweep(interp);
+ }
+ else {
+ Parrot_block_GC_mark(interp);
+ Parrot_block_GC_sweep(interp);
+ }
+ EMBED_API_CALLOUT(interp_pmc, interp)
+}
/*
Please sign in to comment.
Something went wrong with that request. Please try again.