Permalink
Browse files

[imcc] merge yydebug with imccflags, init pasm and pir compilers

we need to init both compilers to fix t/pmc/sub.t
simplify imcc_set_debug_api: only take imccflags, and also call imcc_set_verbosity on -v
shift public PARROT_IMCC_* flags by 16 to private imcc->debug
enable -v (imcc->verbose)
use PARROT_IMCC_PARSER for imcc yydebug flag

TODO: imccflags do not yet arrive in imcc
  • Loading branch information...
1 parent 93a3905 commit 4d02cc759d2fecaf110acb7cc39c6b36f9c10cac Reini Urban committed Feb 26, 2014
Showing with 49 additions and 37 deletions.
  1. +7 −4 compilers/imcc/api.c
  2. +23 −19 frontend/parrot/main.c
  3. +14 −9 frontend/parrot2/main.c
  4. +2 −1 frontend/parrot2/prt0.winxed
  5. +1 −2 include/imcc/api.h
  6. +2 −2 include/parrot/interpreter.h
View
@@ -2,7 +2,7 @@
*
* IMCC call-in routines for use with the Parrot embedding API
*
- * Copyright (C) 2011, Parrot Foundation.
+ * Copyright (C) 2011-2014, Parrot Foundation.
*/
/*
@@ -206,7 +206,7 @@ imcc_preprocess_file_api(Parrot_PMC interp_pmc, Parrot_PMC compiler,
/*
=item C<Parrot_Int imcc_set_debug_api(Parrot_PMC interp_pmc, Parrot_PMC
-compiler, Parrot_Int imcc_debug, Parrot_Int yydebug)>
+compiler, Parrot_Int imccflags)>
=cut
@@ -216,13 +216,16 @@ PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
Parrot_Int
imcc_set_debug_api(Parrot_PMC interp_pmc, Parrot_PMC compiler,
- Parrot_Int imcc_debug, Parrot_Int yydebug)
+ Parrot_Int imccflags)
{
ASSERT_ARGS(imcc_set_debug_api)
IMCC_API_CALLIN(interp_pmc, interp)
imc_info_t * imcc = (imc_info_t *)VTABLE_get_pointer(interp, compiler);
- imcc_set_debug_mode(imcc, imcc_debug, yydebug);
+ if (imccflags & PARROT_IMCC_VERBOSE)
+ imcc_set_verbosity(imcc, 1);
+ /* >> 16 translates public PARROT_IMCC_* flags to internal imcc->debug flags. */
+ imcc_set_debug_mode(imcc, imccflags >> 16, imccflags & PARROT_IMCC_PARSER);
IMCC_API_CALLOUT(interp_pmc, interp)
}
View
@@ -39,8 +39,7 @@ struct init_args_t {
Parrot_Int have_pasm_file;
Parrot_Int turn_gc_off;
Parrot_Int preprocess_only;
- Parrot_Int yydebug;
- Parrot_Int imcc_debug;
+ Parrot_Int imccflags;
};
extern int Parrot_set_config_hash(Parrot_PMC interp_pmc);
@@ -255,14 +254,14 @@ run_imcc(Parrot_PMC interp, Parrot_String sourcefile, ARGIN(struct init_args_t *
ASSERT_ARGS(run_imcc)
Parrot_Int r;
Parrot_PMC pir_compiler = NULL;
- Parrot_PMC pasm_compiler = NULL;;
+ Parrot_PMC pasm_compiler = NULL;
if (!(imcc_get_pir_compreg_api(interp, 1, &pir_compiler) &&
imcc_get_pasm_compreg_api(interp, 1, &pasm_compiler)))
show_last_error_and_exit(interp);
if (flags->preprocess_only) {
- if (flags->yydebug || flags->imcc_debug) {
- r = imcc_set_debug_api(interp, pir_compiler, flags->imcc_debug, flags->yydebug);
+ if (flags->imccflags) {
+ r = imcc_set_debug_api(interp, pir_compiler, flags->imccflags);
if (!r) exit(EXIT_FAILURE);
}
r = imcc_preprocess_file_api(interp, pir_compiler, sourcefile);
@@ -273,8 +272,8 @@ run_imcc(Parrot_PMC interp, Parrot_String sourcefile, ARGIN(struct init_args_t *
const Parrot_PMC compiler = pasm_mode ? pasm_compiler : pir_compiler;
Parrot_PMC pbc;
- if (flags->yydebug || flags->imcc_debug) {
- r = imcc_set_debug_api(interp, compiler, flags->imcc_debug, flags->yydebug);
+ if (flags->imccflags) {
+ r = imcc_set_debug_api(interp, compiler, flags->imccflags);
if (!r) exit(EXIT_FAILURE);
}
if (!imcc_compile_file_api(interp, compiler, sourcefile, &pbc))
@@ -491,6 +490,7 @@ help_debug(void)
printf(
"\n"
"--imcc-debug -d [Flags] ...\n"
+ " 0001 verbose\n"
" 0002 lexer\n"
" 0004 parser\n"
" 0008 imc\n"
@@ -758,8 +758,7 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
args->outfile = NULL;
args->sourcefile = NULL;
args->preprocess_only = 0;
- args->imcc_debug = 0;
- args->yydebug = 0;
+ args->imccflags = 0;
if (argc == 1) {
usage(stderr);
@@ -795,24 +794,24 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
break;
case 'd':
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
- args->imcc_debug = strtoul(opt.opt_arg, NULL, 16);
+ args->imccflags = (Parrot_Int)(strtoul(opt.opt_arg, NULL, 16) << 16);
else
- args->imcc_debug = 1;
+ args->imccflags = PARROT_IMCC_VERBOSE;
break;
case 'O':
if (!opt.opt_arg || !*opt.opt_arg || opt.opt_arg[0] == '0') {
- args->imcc_debug |= PARROT_IMCC_OPT1;
+ args->imccflags |= PARROT_IMCC_OPT1;
break;
}
if (strchr(opt.opt_arg, 'p'))
- args->imcc_debug |= PARROT_IMCC_OPT1;
+ args->imccflags |= PARROT_IMCC_OPT1;
if (strchr(opt.opt_arg, 'c'))
- args->imcc_debug |= PARROT_IMCC_OPT2;
- /* currently not ok due to different register allocation */
+ args->imccflags |= PARROT_IMCC_OPT2;
if (strchr(opt.opt_arg, '1'))
- args->imcc_debug |= PARROT_IMCC_OPT1;
+ args->imccflags |= PARROT_IMCC_OPT1;
if (strchr(opt.opt_arg, '2'))
- args->imcc_debug |= (PARROT_IMCC_OPT1|PARROT_IMCC_OPT2);
+ args->imccflags |= (PARROT_IMCC_OPT1|PARROT_IMCC_OPT2);
+ break;
case '.': /* Give Windows Parrot hackers an opportunity to
* attach a debuggger. */
fgetc(stdin);
@@ -884,8 +883,13 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
break;
case 'E':
args->preprocess_only = 1;
- case 'y':
- args->yydebug = 1;
+ break;
+ case 'v': /* same as -d */
+ args->imccflags |= PARROT_IMCC_VERBOSE;
+ break;
+ case 'y': /* same as -d400 */
+ args->imccflags |= PARROT_IMCC_PARSER;
+ break;
default:
/* languages handle their arguments later (after being initialized) */
break;
View
@@ -35,8 +35,7 @@ struct init_args_t {
Parrot_Int have_pasm_file;
Parrot_Int turn_gc_off;
Parrot_Int preprocess_only;
- Parrot_Int imcc_debug;
- Parrot_Int yydebug; /* possibly merge with imcc_debug */
+ Parrot_Int imccflags;
const char ** argv;
int argc;
};
@@ -170,15 +169,19 @@ main(int argc, const char *argv[])
Parrot_api_toggle_gc(interp, 0);
+#if 1
+ setup_imcc(interp);
+#else
if (!(parsed_flags.have_pasm_file
? imcc_get_pasm_compreg_api(interp, 1, &compiler)
: imcc_get_pir_compreg_api(interp, 1, &compiler))) {
show_last_error_and_exit(interp);
}
+#endif
if (!parsed_flags.turn_gc_off)
Parrot_api_toggle_gc(interp, 1);
- if (parsed_flags.yydebug) {
- if (!imcc_set_debug_api(interp, compiler, parsed_flags.trace, 1))
+ if (parsed_flags.imccflags) {
+ if (!imcc_set_debug_api(interp, compiler, parsed_flags.imccflags))
exit(EXIT_FAILURE);
}
@@ -602,8 +605,7 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
args->turn_gc_off = 0;
args->have_pasm_file = 0;
args->preprocess_only = 0;
- args->imcc_debug = 0;
- args->yydebug = 0;
+ args->imccflags = 0;
pargs[nargs++] = argv[0];
while ((status = longopt_get(argc, argv, Parrot_cmd_options(), &opt)) > 0) {
@@ -638,9 +640,9 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
break;
case 'd':
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
- args->imcc_debug = (Parrot_Int)strtoul(opt.opt_arg, NULL, 16);
+ args->imccflags = (Parrot_Int)(strtoul(opt.opt_arg, NULL, 16) << 16);
else
- args->imcc_debug = 1;
+ args->imccflags = PARROT_IMCC_VERBOSE;
break;
case '.': /* Give Windows Parrot hackers an opportunity to
@@ -685,8 +687,11 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
case OPT_DESTROY_FLAG:
result = Parrot_api_flag(interp, PARROT_DESTROY_FLAG, 1);
break;
+ case 'v':
+ args->imccflags |= PARROT_IMCC_VERBOSE;
+ break;
case 'y':
- args->yydebug = 1;
+ args->imccflags |= PARROT_IMCC_PARSER;
break;
case 'a':
args->have_pasm_file = 1;
@@ -217,6 +217,7 @@ parrot [Options] <file> [<program options...>]
-a --pasm
-c --pbc
-r --run-pbc
+ -v --verbose
-y --yydebug
-d --imcc-debug[=HEXFLAGS] (see --help-debug)
<Language options>
@@ -238,7 +239,7 @@ function __usage_and_exit[anon](string msg [optional], int has_msg [opt_flag])
var stderr = getstderr();
if (has_msg)
stderr.print(msg + "\n");
- stderr.print("parrot -[acEGhrtVwy.] [-D [FLAGS]] ");
+ stderr.print("parrot -[acEGhrtVvwy.] [-D [FLAGS]] ");
stderr.print("[-[LIX] path] [-R runcore] [-o FILE] <file> <args>\n");
exit(1);
}
View
@@ -49,8 +49,7 @@ PARROT_WARN_UNUSED_RESULT
Parrot_Int imcc_set_debug_api(
Parrot_PMC interp_pmc,
Parrot_PMC compiler,
- Parrot_Int imcc_debug,
- Parrot_Int yydebug);
+ Parrot_Int imccflags);
#define ASSERT_ARGS_imcc_compile_file_api __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pbc))
@@ -38,9 +38,9 @@ typedef enum {
PARROT_EVAL_DEBUG_FLAG = 0x20, /* create EVAL_n file */
PARROT_REG_DEBUG_FLAG = 0x40, /* fill I,N with garbage */
PARROT_CTX_DESTROY_DEBUG_FLAG = 0x80, /* ctx of a sub is gone */
- PARROT_IMCC_YYDEBUG = 0x100, /* imcc parsing */
+ PARROT_IMCC_VERBOSE = 0x100, /* these appear at imcc >> 16 */
PARROT_IMCC_LEXER = 0x200,
- PARROT_IMCC_PARSER = 0x400,
+ PARROT_IMCC_PARSER = 0x400, /* sets yydebug */
PARROT_IMCC_IMC = 0x800,
PARROT_IMCC_CFG = 0x1000,
PARROT_IMCC_OPT1 = 0x2000,

0 comments on commit 4d02cc7

Please sign in to comment.