Author: bernhard
Date: Mon Oct 24 13:58:17 2005
New Revision: 9546

Modified:
   trunk/imcc/imc.h
   trunk/imcc/instructions.c
   trunk/imcc/main.c
   trunk/include/parrot/interpreter.h
   trunk/ops/core.ops
   trunk/src/dod.c
   trunk/src/embed.c
   trunk/src/exceptions.c
   trunk/src/exec.c
   trunk/src/inter_create.c
   trunk/src/jit_debug.c
   trunk/src/jit_debug_xcoff.c
   trunk/src/pbc_merge.c
Log:
interpreter->current_file wasn't really used, so get rid of it.

Store the 'output' command line option in interpreter->output_file
and use it for writing e.g hello.pbc and hello.o.

Eliminate IMCC_INFO(interp)->output 

Note that the the 'getfile' and 'setfile' ops are not implemented.

Try to make definition of 'struct parrot_interp_t' more readable. 


Modified: trunk/imcc/imc.h
==============================================================================
--- trunk/imcc/imc.h    (original)
+++ trunk/imcc/imc.h    Mon Oct 24 13:58:17 2005
@@ -1,3 +1,5 @@
+/* $Id$ */
+
 #if !defined(PARROT_IMCC_IMC_H_GUARD)
 #define PARROT_IMCC_IMC_H_GUARD
 
@@ -195,7 +197,6 @@ typedef struct _imc_info_t {
     int IMCC_DEBUG;
     int gc_off;
     int write_pbc;
-    char* output;
     SymReg* sr_return;
     AsmState asm_state;
     int optimizer_level;

Modified: trunk/imcc/instructions.c
==============================================================================
--- trunk/imcc/instructions.c   (original)
+++ trunk/imcc/instructions.c   Mon Oct 24 13:58:17 2005
@@ -1,3 +1,4 @@
+/* $Id$ */
 
 #include <stdlib.h>
 #include <string.h>

Modified: trunk/imcc/main.c
==============================================================================
--- trunk/imcc/main.c   (original)
+++ trunk/imcc/main.c   Mon Oct 24 13:58:17 2005
@@ -292,14 +292,14 @@ parseflags(Parrot_Interp interp, int *ar
                 break;
             case 'o':
                 run_pbc = 0;
-                IMCC_INFO(interp)->output = str_dup(opt.opt_arg);
+                interp->output_file = str_dup(opt.opt_arg);
                 break;
 
             case OPT_PBC_OUTPUT:
                 run_pbc = 0;
                 write_pbc = 1;
-                if (!IMCC_INFO(interp)->output)
-                    IMCC_INFO(interp)->output = str_dup("-");
+                if (!interp->output_file)
+                    interp->output_file = str_dup("-");
                 break;
 
             case 'O':
@@ -453,7 +453,7 @@ main(int argc, char * argv[])
     struct PackFile *pf;
     int obj_file, ast_file = 0;
     char *sourcefile;
-    char *output;
+    char *output_file;
 
     Interp *interp = Parrot_new(NULL);
 
@@ -466,7 +466,7 @@ main(int argc, char * argv[])
     IMCC_ast_init(interp);
 
     sourcefile = parseflags(interp, &argc, &argv);
-    output = IMCC_INFO(interp)->output;
+    output_file = interp->output_file;
 
     /* Default optimization level is zero; see optimizer.c, imc.h */
     if (!*optimizer_opt) {
@@ -512,9 +512,9 @@ main(int argc, char * argv[])
 
     /* Do we need to produce an output file? If so, what type? */
     obj_file = 0;
-    if (IMCC_INFO(interp)->output) {
+    if (interp->output_file) {
         char *ext;
-        ext = strrchr(IMCC_INFO(interp)->output, '.');
+        ext = strrchr(interp->output_file, '.');
         if (ext && strcmp (ext, ".pbc") == 0) {
             write_pbc = 1;
         }
@@ -524,13 +524,12 @@ main(int argc, char * argv[])
             write_pbc = 0;
             run_pbc = 1;
             obj_file = 1;
-            Parrot_setup_opt(interp, 0, output);
             Parrot_set_run_core(interp, PARROT_EXEC_CORE);
 #else
             IMCC_fatal(interp, 1, "main: can't produce object file");
 #endif
         }
-        if (!strcmp(sourcefile, output) && strcmp(sourcefile, "-"))
+        if (!strcmp(sourcefile, output_file) && strcmp(sourcefile, "-"))
             IMCC_fatal(interp, 1,
                 "main: outputfile is sourcefile\n");
     }
@@ -562,7 +561,7 @@ main(int argc, char * argv[])
         IMCC_push_parser_state(interp);
         IMCC_INFO(interp)->state->file = sourcefile;
 
-        emit_open(interp, per_pbc, per_pbc ? NULL : (void*)output);
+        emit_open(interp, per_pbc, per_pbc ? NULL : (void*)output_file);
 
         IMCC_info(interp, 1, "Starting parse...\n");
 
@@ -588,24 +587,24 @@ main(int argc, char * argv[])
         size_t size;
         opcode_t *packed;
         FILE *fp;
-        IMCC_info(interp, 1, "Writing %s\n", output);
+        IMCC_info(interp, 1, "Writing %s\n", output_file);
 
         size = PackFile_pack_size(interp, interp->code->base.pf) *
             sizeof(opcode_t);
         IMCC_info(interp, 1, "packed code %d bytes\n", size);
         packed = (opcode_t*) mem_sys_allocate(size);
         PackFile_pack(interp, interp->code->base.pf, packed);
-        if (strcmp (output, "-") == 0)
+        if (strcmp (output_file, "-") == 0)
             fp = stdout;
-        else if ((fp = fopen(output, "wb")) == 0)
+        else if ((fp = fopen(output_file, "wb")) == 0)
             IMCC_fatal(interp, E_IOError,
-                "Couldn't open %s\n", output);
+                "Couldn't open %s\n", output_file);
 
         if ((1 != fwrite(packed, size, 1, fp)) )
             IMCC_fatal(interp, E_IOError,
-                "Couldn't write %s\n", output);
+                "Couldn't write %s\n", output_file);
         fclose(fp);
-        IMCC_info(interp, 1, "%s written.\n", output);
+        IMCC_info(interp, 1, "%s written.\n", output_file);
         free(packed);
         /* TODO */
         if (run_pbc != 2)
@@ -613,9 +612,9 @@ main(int argc, char * argv[])
     }
 
     /* If necessary, load the file written above */
-    if (run_pbc == 2 && write_pbc && strcmp(output, "-")) {
-        IMCC_info(interp, 1, "Loading %s\n", output);
-        pf = Parrot_readbc(interp, output);
+    if (run_pbc == 2 && write_pbc && strcmp(output_file, "-")) {
+        IMCC_info(interp, 1, "Loading %s\n", output_file);
+        pf = Parrot_readbc(interp, output_file);
         if (!pf)
             IMCC_fatal(interp, 1,
             "Packfile loading failed\n");
@@ -635,7 +634,7 @@ main(int argc, char * argv[])
             Parrot_unblock_GC(interp);
         }
         if (obj_file)
-            IMCC_info(interp, 1, "Writing %s\n", output);
+            IMCC_info(interp, 1, "Writing %s\n", output_file);
         else
             IMCC_info(interp, 1, "Running...\n");
         if (!load_pbc)
@@ -646,8 +645,8 @@ main(int argc, char * argv[])
 
     /* Clean-up after ourselves */
     Parrot_destroy(interp);
-    if (output)
-        free(output);
+    if (output_file)
+        free(output_file);
     mem_sys_free(IMCC_INFO(interp));
     Parrot_exit(0);
 

Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h  (original)
+++ trunk/include/parrot/interpreter.h  Mon Oct 24 13:58:17 2005
@@ -30,10 +30,10 @@ typedef enum {
     PARROT_THR_COPY_INTERP  = 0x2000, /* thread start copies interp state */
     PARROT_THR_THREAD_POOL  = 0x4000, /* type3 threads */
 
-    PARROT_THR_TYPE_1 = PARROT_IS_THREAD,
-    PARROT_THR_TYPE_2 = PARROT_IS_THREAD | PARROT_THR_COPY_INTERP,
-    PARROT_THR_TYPE_3 = PARROT_IS_THREAD | PARROT_THR_COPY_INTERP |
-                        PARROT_THR_THREAD_POOL
+    PARROT_THR_TYPE_1       = PARROT_IS_THREAD,
+    PARROT_THR_TYPE_2       = PARROT_IS_THREAD | PARROT_THR_COPY_INTERP,
+    PARROT_THR_TYPE_3       = PARROT_IS_THREAD | PARROT_THR_COPY_INTERP |
+                              PARROT_THR_THREAD_POOL
 
 } Parrot_Interp_flag;
 /* &end_gen */
@@ -251,88 +251,110 @@ typedef struct _context_mem {
  */
 struct parrot_interp_t {
     struct Interp_Context ctx;
-    context_mem ctx_mem;                /* ctx memory managment */
+    context_mem ctx_mem;                      /* ctx memory managment */
 
-    struct Stash *globals;              /* Pointer to the global variable
-                                         * area */
-    struct Arenas *arena_base;          /* Pointer to this interpreter's
-                                         * arena */
-    PMC *class_hash;                    /* Hash of classes */
-    struct _ParrotIOData *piodata;              /* interpreter's IO system */
-
-    op_lib_t  *op_lib;                  /* Opcode library */
-    size_t     op_count;                /* The number of ops */
-    op_info_t *op_info_table; /* Opcode info table (name, nargs, arg types) */
-
-    op_func_t *op_func_table;   /* opcode dispatch table (functios, labels,
-                                   or nothing (e.g. switched core), which
-                                   the interpreter is currently running */
-    op_func_t *evc_func_table;  /* opcode dispatch for event checking */
-    op_func_t *save_func_table; /* for restoring op_func_table */
+    struct Stash *globals;                    /* Pointer to the global variable
+                                               * area */
+    
+    struct Arenas *arena_base;                /* Pointer to this interpreter's
+                                               * arena */
+    
+    PMC *class_hash;                          /* Hash of classes */
+    
+    struct _ParrotIOData *piodata;            /* interpreter's IO system */
+
+    op_lib_t  *op_lib;                        /* Opcode library */
+    size_t     op_count;                      /* The number of ops */
+    op_info_t *op_info_table;                 /* Opcode info table (name, 
nargs, arg types) */
+
+    op_func_t *op_func_table;                 /* opcode dispatch table 
(functios, labels,
+                                               * or nothing (e.g. switched 
core), which
+                                               * the interpreter is currently 
running */
+    op_func_t *evc_func_table;                /* opcode dispatch for event 
checking */
+    op_func_t *save_func_table;               /* for restoring op_func_table */
 
-    int         n_libs;                  /* count of libs below */
-    op_lib_t  **all_op_libs;             /* all loaded opcode libraries */
+    int         n_libs;                       /* count of libs below */
+    op_lib_t  **all_op_libs;                  /* all loaded opcode libraries */
 
 /* XXX kwoo:  Is this for future, or is it safe to remove? */
 #if 0
     str_func_t *string_funcs;
 #endif
 
-    Interp_flags flags;         /* Various interpreter flags that */
-    UINTVAL debug_flags;        /* debug settings */
-    Run_Cores run_core;         /* type of core to run the ops */
+    Interp_flags flags;                       /* Various interpreter flags 
that */
+
+    UINTVAL debug_flags;                      /* debug settings */
+
+    Run_Cores run_core;                       /* type of core to run the ops */
 
     /* TODO profile per code segment or global */
-    RunProfile *profile;        /* The structure and array where we keep the
-                                 * profile counters */
+    RunProfile *profile;                      /* The structure and array where 
we keep the
+                                               * profile counters */
+
     INTVAL resume_flag;
     size_t resume_offset;
 
-    struct PackFile_ByteCode  *code;      /* The code we are executing */
-    struct PackFile *initial_pf;   /* first created PF */
+    struct PackFile_ByteCode *code;           /* The code we are executing */
+    struct PackFile *initial_pf;              /* first created PF  */
 
-    struct _imc_info_t *imc_info;   /* imcc data */
-    size_t current_line;        /* Which line we're executing in the
-                                 * source */
-    String *current_file;       /* The file we're currently in */
+    struct _imc_info_t *imc_info;             /* imcc data */
 
+    size_t current_line;                      /* Which line we're executing in 
the
+                                               * source */
+    
+    const char* output_file;                  /* The file into which output is 
written */
+
+    PDB_t *pdb;                               /* Debug system */
+
+    void *lo_var_ptr;                         /* Pointer to memory on runops 
system stack */
 
-    PDB_t *pdb;                 /* Debug system */
-    void *lo_var_ptr;           /* Pointer to memory on runops system stack */
     Interp * parent_interpreter;
 
     /* per interpreter global vars */
-    INTVAL world_inited;        /* Parrot_init is done */
-    PMC *iglobals;              /* SArray of PMCs, containing: */
-/* 0:   PMC *Parrot_base_classname_hash; hash containing name->base_type */
-/* 1:   PMC *Parrot_compreg_hash;    hash containing assembler/compilers */
-/* 2:   PMC *Argv;                   list of argv */
-/* 3:   PMC *NCI func hash           hash of NCI funcs */
-/* 4:   PMC *ParrotInterpreter       that's me */
-/* 5:   PMC *Dyn_libs           Array of dynamically loaded ParrotLibrary  */
-    PMC* DOD_registry;          /* registered PMCs added to the root set */
-    PMC* HLL_info;              /* storage for HLL names and types */
-    MMD_table *binop_mmd_funcs; /* Table of MMD functions */
-    UINTVAL n_binop_mmd_funcs;   /* function count */
-    struct _Caches * caches;            /* s. caches.h */
-    STRING **const_cstring_table;       /* CONST_STRING(x) items */
-    struct QUEUE* task_queue;           /* per interpreter queue */
-    int sleeping;                       /* used during sleep in events */
-    struct parrot_exception_t *exceptions; /* internal exception stack */
+    INTVAL world_inited;                      /* Parrot_init is done */
+
+    PMC *iglobals;                            /* SArray of PMCs, containing: */
+    /* 0:   PMC *Parrot_base_classname_hash; hash containing name->base_type */
+    /* 1:   PMC *Parrot_compreg_hash;    hash containing assembler/compilers */
+    /* 2:   PMC *Argv;                   list of argv */
+    /* 3:   PMC *NCI func hash           hash of NCI funcs */
+    /* 4:   PMC *ParrotInterpreter       that's me */
+    /* 5:   PMC *Dyn_libs           Array of dynamically loaded ParrotLibrary  
*/
+
+    PMC* DOD_registry;                        /* registered PMCs added to the 
root set */
+
+    PMC* HLL_info;                            /* storage for HLL names and 
types */
+
+    MMD_table *binop_mmd_funcs;               /* Table of MMD functions */
+    UINTVAL n_binop_mmd_funcs;                /* function count */
+
+    struct _Caches * caches;                  /* s. caches.h */
+
+    STRING **const_cstring_table;             /* CONST_STRING(x) items */
+
+    struct QUEUE* task_queue;                 /* per interpreter queue */
+
+    int sleeping;                             /* used during sleep in events */
+
+    struct parrot_exception_t *exceptions;    /* internal exception stack */
     struct parrot_exception_t *exc_free_list; /* and free list */
-    PMC ** exception_list;              /* precreated exception objects */
-    struct _Thread_data *thread_data;   /* thread specific items */
-    UINTVAL recursion_limit;    /* Sub call resursion limit */
-    UINTVAL gc_generation;      /* GC generation number */
-    opcode_t *current_args;      /* ptr into code with set_args opcode */
-    opcode_t *current_params;   /* ptr into code with get_params opcode */
-    opcode_t *current_returns;   /* ptr into code with get_returns opcode */
+    PMC ** exception_list;                    /* precreated exception objects 
*/
+
+    struct _Thread_data *thread_data;         /* thread specific items */
+
+    UINTVAL recursion_limit;                  /* Sub call resursion limit */
+
+    UINTVAL gc_generation;                    /* GC generation number */
+
+    opcode_t *current_args;                   /* ptr into code with set_args 
opcode */
+    opcode_t *current_params;                 /* ptr into code with get_params 
opcode */
+    opcode_t *current_returns;                /* ptr into code with 
get_returns opcode */
     /* during a call sequencer the caller fills these objects
      * inside the invoke these get moved to the context structure
      */
-    PMC *current_cont;          /* the return continuation PMC */
-    PMC *current_object;        /* current object if a method call */
-    STRING *current_method;     /* name of method */
+    PMC *current_cont;                        /* the return continuation PMC */
+    PMC *current_object;                      /* current object if a method 
call */
+    STRING *current_method;                   /* name of method */
 };
 
 /* typedef struct parrot_interp_t Interp;    done in parrot.h so that

Modified: trunk/ops/core.ops
==============================================================================
--- trunk/ops/core.ops  (original)
+++ trunk/ops/core.ops  Mon Oct 24 13:58:17 2005
@@ -954,7 +954,7 @@ Set the name of the file for which we're
 =cut
 
 inline op setfile(in STR) {
-  interpreter->current_file = $1;
+  /* TODO: not implemented yet */
   goto NEXT();
 }
 
@@ -965,7 +965,7 @@ Get the name of the current file.
 =cut
 
 inline op getfile(out STR) {
-  $1 = interpreter->current_file;
+  /* TODO: not implemented yet */
   goto NEXT();
 }
 

Modified: trunk/src/dod.c
==============================================================================
--- trunk/src/dod.c     (original)
+++ trunk/src/dod.c     Mon Oct 24 13:58:17 2005
@@ -514,9 +514,11 @@ trace_active_buffers(Interp *interpreter
             pobject_lives(interpreter, reg);
     }
 
-    /* The interpreter has a few strings of its own */
-    if (interpreter->current_file)
-        pobject_lives(interpreter, (PObj *)interpreter->current_file);
+    /* The interpreter might have a few strings of its own,
+     * but currently there are none.
+     * When the interpreter gets strings again, then mark them as alive */
+    /* if (interpreter->output_file)
+        pobject_lives(interpreter, (PObj *)interpreter->output_file) */;
 }
 
 #ifdef GC_IS_MALLOC

Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c   (original)
+++ trunk/src/embed.c   Mon Oct 24 13:58:17 2005
@@ -291,7 +291,7 @@ Parrot_readbc(Interp *interpreter, const
                         filename, errno);
             return NULL;
         }
-        fs = interpreter->current_file = string_make(interpreter, fullname,
+        fs = string_make(interpreter, fullname,
                 strlen(fullname), NULL, 0);
         if (!Parrot_stat_info_intval(interpreter, fs, STAT_EXISTS)) {
             PIO_eprintf(interpreter, "Parrot VM: Can't stat %s, code %i.\n",
@@ -497,26 +497,6 @@ setup_argv(Interp *interpreter, int argc
 }
 
 /*
-
-=item C<void
-Parrot_setup_opt(Interp *interpreter, int n, char *argv)>
-
-XXX This allows a command line option to be visible from inside the
-Parrot core. This is done using the pointers in the interpreter
-structure, and the subsystems using this arguments must clear them
-before running.
-
-=cut
-
-*/
-
-void
-Parrot_setup_opt(Interp *interpreter, int n, char *argv)
-{
-    REG_STR(n) = (STRING *)argv;
-}
-
-/*
 
 =item C<static int
 prof_sort_f(const void *a, const void *b)>

Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c      (original)
+++ trunk/src/exceptions.c      Mon Oct 24 13:58:17 2005
@@ -97,9 +97,7 @@ do_panic(Interp *interpreter, const char
 
     if (interpreter) {
         fprintf(stderr, "Parrot file %s, line %d\n",
-                   interpreter->current_file &&
-                   interpreter->current_file->strstart ?
-                   (char *)interpreter->current_file->strstart : "(null)",
+                   "(unknown)",
                    (int)interpreter->current_line);
     }
     else {

Modified: trunk/src/exec.c
==============================================================================
--- trunk/src/exec.c    (original)
+++ trunk/src/exec.c    Mon Oct 24 13:58:17 2005
@@ -113,8 +113,8 @@ Parrot_exec(Interp *interpreter, opcode_
     obj->text.size += (4 - obj->text.size % 4);
     obj->data.size += (4 - obj->data.size % 4);
     offset_fixup(obj);
-    output = REG_STR(0) ?
-        (const char *)REG_STR(0) : "exec_output.o";
+    output = interpreter->output_file ?
+        interpreter->output_file : "exec_output.o";
     Parrot_exec_save(obj, output);
 }
 

Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c    (original)
+++ trunk/src/inter_create.c    Mon Oct 24 13:58:17 2005
@@ -589,8 +589,6 @@ make_interpreter(Parrot_Interp parent, I
     SET_NULL_P(interpreter->save_func_table, op_func_t *);
 
     /* Set up defaults for line/package/file */
-    interpreter->current_file =
-        string_make(interpreter, "(unknown file)", 14, NULL, 0);
     CONTEXT(interpreter->ctx)->current_package =
         string_make(interpreter, "(unknown package)", 18, NULL, 0);
 

Modified: trunk/src/jit_debug.c
==============================================================================
--- trunk/src/jit_debug.c       (original)
+++ trunk/src/jit_debug.c       Mon Oct 24 13:58:17 2005
@@ -279,7 +279,7 @@ static void
 Parrot_jit_debug_stabs(Interp *interpreter)
 {
     Parrot_jit_info_t *jit_info = interpreter->code->jit_info;
-    STRING *file = interpreter->current_file;
+    STRING *file = NULL;
     STRING *pasmfile, *stabsfile, *ofile, *cmd;
     FILE *stabs;
     size_t i;

Modified: trunk/src/jit_debug_xcoff.c
==============================================================================
--- trunk/src/jit_debug_xcoff.c (original)
+++ trunk/src/jit_debug_xcoff.c Mon Oct 24 13:58:17 2005
@@ -248,7 +248,7 @@ static void
 Parrot_jit_debug_stabs(Interp *interpreter)
 {
     Parrot_jit_info_t *jit_info = interpreter->jit_info;
-    STRING *file = interpreter->current_file;
+    STRING *file = NULL;
     STRING *pasmfile, *stabsfile, *ofile, *cmd;
     FILE *stabs;
     size_t i;

Modified: trunk/src/pbc_merge.c
==============================================================================
--- trunk/src/pbc_merge.c       (original)
+++ trunk/src/pbc_merge.c       Mon Oct 24 13:58:17 2005
@@ -101,7 +101,7 @@ pbc_merge_loadpbc(Interp *interpreter, c
 

     /* Check the file exists. */

     STRING *fs;

-    fs = interpreter->current_file = string_make(interpreter, fullname,

+    fs = string_make(interpreter, fullname,

             strlen(fullname), NULL, 0);

     if (!Parrot_stat_info_intval(interpreter, fs, STAT_EXISTS)) {

         PIO_eprintf(interpreter, "PBC Merge: Can't stat %s, code %i.\n",

Reply via email to