On Saturday 14 April 2007 12:44, chromatic wrote: > The attached patch moves only the main() function out of > compilers/imcc/main.c into src/main.c. There's a lot more work to do to > clean up this mess, including RT #37248.
If you want a patch that compiles, try instead this one. Note that it will fail t/codingstd/file_metadata.t, because there's no way to add that in a patch. So far, I have successes on x86 Linux, Mac OS X (x86), and x86-64 Linux. -- c
=== MANIFEST ================================================================== --- MANIFEST (revision 3177) +++ MANIFEST (local) @@ -770,6 +770,7 @@ include/parrot/hash.h [main]include include/parrot/headers.h [main]include include/parrot/hll.h [main]include +include/parrot/imcc.h [main]include include/parrot/inter_call.h [main]include include/parrot/interpreter.h [main]include include/parrot/intlist.h [main]include @@ -2541,6 +2542,7 @@ src/longopt.c [] src/malloc-trace.c [] src/malloc.c [] +src/main.c [] src/misc.c [] src/mmd.c [] src/nci_test.c [] === compilers/imcc/main.c ================================================================== --- compilers/imcc/main.c (revision 3177) +++ compilers/imcc/main.c (local) @@ -24,6 +24,11 @@ static int load_pbc, run_pbc, write_pbc, pre_process, pasm_file; +char * parseflags(Interp *interp, int *argc, char **argv[]); +int imcc_initialize(Interp *interp); +int imcc_run(Interp *interp, const char *sourcefile, int argc, + char * argv[]); + static void usage(FILE* fp) { @@ -194,7 +199,7 @@ } /* most stolen from test_main.c */ -static char * +char * parseflags(Parrot_Interp interp, int *argc, char **argv[]) { struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT; @@ -511,7 +516,7 @@ return; } -static int +int imcc_initialize(Interp *interp) { yyscan_t yyscanner = IMCC_INFO(interp)->yyscanner; @@ -592,7 +597,7 @@ free(packed); } -static int +int imcc_run(Interp *interp, const char *sourcefile, int argc, char * argv[]) { PackFile *pf; @@ -760,41 +765,6 @@ return 0; } -int -main(int argc, char * argv[]) -{ - char *sourcefile; - Interp *interp; - STRING *executable_name; - PMC *executable_name_pmc; - int status; - - Parrot_set_config_hash(); - - interp = Parrot_new(NULL); - if (!imcc_initialize(interp)) - internal_exception(1, "Could not initialize IMCC\n"); - - /* We parse the arguments, but first store away the name of the Parrot - executable, since parsing destroys that and we want to make it - available. */ - executable_name = string_from_cstring(interp, argv[0], 0); - executable_name_pmc = pmc_new(interp, enum_class_String); - VTABLE_set_string_native(interp, executable_name_pmc, executable_name); - VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE, - executable_name_pmc); - - sourcefile = parseflags(interp, &argc, &argv); - status = imcc_run(interp, sourcefile, argc, argv); - - /* Clean-up after ourselves */ - Parrot_destroy(interp); - Parrot_exit(interp, 0); - - return status; -} - - /* * Local variables: * c-file-style: "parrot" === config/gen/makefiles/root.in ================================================================== --- config/gen/makefiles/root.in (revision 3177) +++ config/gen/makefiles/root.in (local) @@ -371,6 +371,7 @@ $(IMCC_DIR)/imcparser$(O) \ $(IMCC_DIR)/imclexer$(O) \ $(IMCC_DIR)/imc$(O) \ + $(IMCC_DIR)/main$(O) \ $(IMCC_DIR)/symreg$(O) \ $(IMCC_DIR)/instructions$(O) \ $(IMCC_DIR)/cfg$(O) \ @@ -425,6 +426,7 @@ $(SRC_DIR)/inter_run$(O) \ $(SRC_DIR)/gc/register$(O) \ $(SRC_DIR)/gc/memory$(O) \ + $(SRC_DIR)/main$(O) \ $(SRC_DIR)/objects$(O) \ $(SRC_DIR)/packfile$(O) \ $(SRC_DIR)/stacks$(O) \ @@ -1082,6 +1084,8 @@ $(SRC_DIR)/gc/memory$(O) : $(GENERAL_H_FILES) +$(SRC_DIR)/main$(O) : $(SRC_DIR)/main.c $(GENERAL_H_FILES) + $(SRC_DIR)/pic$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES) === include/parrot/imcc.h ================================================================== --- include/parrot/imcc.h (revision 3177) +++ include/parrot/imcc.h (local) @@ -0,0 +1,15 @@ +#if !defined(PARROT_IMCC_H_GUARD) +#define PARROT_IMCC_H_GUARD + +int imcc_initialize(Interp *interp); +char * parseflags(Interp *interp, int *argc, char **argv[]); +int imcc_run(Interp *interp, const char *sourcefile, int argc, char * argv[]); + +#endif + +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ Property changes on: include/parrot/imcc.h ___________________________________________________________________ Name: svn:eol-style +native Name: svn:keywords +Author Date Id Revision === src/main.c ================================================================== --- src/main.c (revision 3177) +++ src/main.c (local) @@ -0,0 +1,87 @@ +/* +Copyright (C) 2007, The Perl Foundation +$Id$ + +=head1 NAME + +src/main.c - the Entry Point to Parrot Programs + +=head1 DESCRIPTION + +Start Parrot + +=head2 Functions + +=over 4 + +=cut + +*/ + +#include <stdio.h> +#include <string.h> + +#include "parrot/parrot.h" +#include "parrot/embed.h" +#include "parrot/imcc.h" + +/* + +=item C<int main(int argc, char * argv[])> + +The entry point from the command line into Parrot. + +*/ + +int +main(int argc, char * argv[]) +{ + char *sourcefile; + Interp *interp; + STRING *executable_name; + PMC *executable_name_pmc; + int status; + + Parrot_set_config_hash(); + + interp = Parrot_new(NULL); + if (!imcc_initialize(interp)) + internal_exception(1, "Could not initialize IMCC\n"); + + /* We parse the arguments, but first store away the name of the Parrot + executable, since parsing destroys that and we want to make it + available. */ + executable_name = string_from_cstring(interp, argv[0], 0); + executable_name_pmc = pmc_new(interp, enum_class_String); + VTABLE_set_string_native(interp, executable_name_pmc, executable_name); + VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE, + executable_name_pmc); + + sourcefile = parseflags(interp, &argc, &argv); + status = imcc_run(interp, sourcefile, argc, argv); + + /* Clean-up after ourselves */ + Parrot_destroy(interp); + Parrot_exit(interp, 0); + + return status; +} + +/* + +=back + +=head1 SEE ALSO + +F<compilers/imcc/main.c>, unfortunately. + +=cut + +*/ + +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ Property changes on: src/main.c ___________________________________________________________________ Name: svn:eol-style +native Name: svn:keywords +Author Date Id Revision