cvsuser     01/10/17 14:32:14

  Modified:    .        interpreter.c
  Log:
  Moved op dump code into trace_op_dump, per Dan's request.
  
  Revision  Changes    Path
  1.31      +22 -56    parrot/interpreter.c
  
  Index: interpreter.c
  ===================================================================
  RCS file: /home/perlcvs/parrot/interpreter.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -w -r1.30 -r1.31
  --- interpreter.c     2001/10/17 21:04:52     1.30
  +++ interpreter.c     2001/10/17 21:32:14     1.31
  @@ -1,7 +1,7 @@
   /* interpreter.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: interpreter.c,v 1.30 2001/10/17 21:04:52 bdwheele Exp $
  + *     $Id: interpreter.c,v 1.31 2001/10/17 21:32:14 bdwheele Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -58,22 +58,14 @@
   }
   
   /*
  - *=for api interpreter trace_op_b0
  + *=for api interpreter trace_op_dump
    * TODO: This isn't really part of the API, but here's its documentation. Prints 
the PC, OP
  - * and ARGS. Used by runops_trace.
  - *
  - * No bounds checking.
  + * and ARGS. Used by trace_op_b0 and trace_op_b1.
    */
   void
  -trace_op_b0(struct Parrot_Interp *interpreter, opcode_t * code_start, opcode_t *pc) 
{
  +trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t 
*pc) {
       INTVAL i;
   
  -    if (!pc) {
  -        return;
  -    }
  -
  -    (void)fflush(NULL); /* Flush *ALL* output before printing trace info */
  -
       fprintf(stderr, "PC=%ld; OP=%ld (%s)", (long)(pc - code_start), *pc,
           interpreter->opcode_info[*pc].full_name);
   
  @@ -117,7 +109,24 @@
           fprintf(stderr, ")");
       }
       fprintf(stderr, "\n");
  +}
  +
  +
   
  +/*
  + *=for api interpreter trace_op_b0
  + * TODO: This isn't really part of the API, but here's its documentation. Prints 
the PC, OP
  + * and ARGS. Used by runops_trace.
  + *
  + * No bounds checking.
  + */
  +void
  +trace_op_b0(struct Parrot_Interp *interpreter, opcode_t * code_start, opcode_t *pc) 
{
  +    if (!pc) {
  +        return;
  +    }
  +    (void)fflush(NULL); /* Flush *ALL* output before printing trace info */
  +    trace_op_dump(interpreter, code_start, pc);
       (void)fflush(stderr); /* Flush *stderr* now that we've output the trace info */
   }
   
  @@ -137,51 +146,8 @@
       }
   
       (void)fflush(NULL); /* Flush *ALL* output before printing trace info */
  -
       if (pc >= code_start && pc < code_end) {
  -        fprintf(stderr, "PC=%ld; OP=%ld (%s)", (long)(pc - code_start), *pc,
  -            interpreter->opcode_info[*pc].full_name);
  -
  -        if (interpreter->opcode_info[*pc].arg_count > 1) {
  -            fprintf(stderr, "; ARGS=(");
  -            for(i = 1; i < interpreter->opcode_info[*pc].arg_count; i++) {
  -                if (i > 1) { fprintf(stderr, ", "); }
  -                switch(interpreter->opcode_info[*pc].types[i]) {
  -                case PARROT_ARG_IC:
  -                    fprintf(stderr, "%ld", (long) *(pc + i));
  -                    break;
  -                case PARROT_ARG_NC:
  -                    fprintf(stderr, "%f", 
interpreter->code->const_table->constants[*(pc + i)]->number);
  -                    break;
  -                case PARROT_ARG_PC:
  -                    /* what is a PMC constant look like? */
  -                    fprintf(stderr, "%ld", (long) *(pc + i));
  -                    break;
  -                case PARROT_ARG_SC:
  -                    fprintf(stderr, "\"%s\"", 
interpreter->code->const_table->constants[*(pc + i)]->string->bufstart);
  -                    break;
  -                case PARROT_ARG_I:
  -                    fprintf(stderr, "I%ld=%ld", (long) *(pc + i), (long) 
interpreter->int_reg->registers[*(pc + i)]);
  -                    break;
  -                case PARROT_ARG_N:
  -                    fprintf(stderr, "N%ld=%f", (long) *(pc + i), 
interpreter->num_reg->registers[*(pc + i)]);
  -                    break;
  -                case PARROT_ARG_P:
  -                    /* what does a PMC constant look like? */
  -                    fprintf(stderr, "P%ld=???", (long) *(pc + i));
  -                    break;
  -                case PARROT_ARG_S:
  -                    if(interpreter->string_reg->registers[*(pc + i)]) {
  -                        fprintf(stderr, "S%ld=\"%s\"", (long) *(pc + i), 
interpreter->string_reg->registers[*(pc + i)]->bufstart);
  -                    } else {
  -                        fprintf(stderr, "S%ld=(null)", (long) *(pc + i));
  -                    }
  -                    break;
  -                }
  -            }
  -            fprintf(stderr, ")");
  -        }
  -        fprintf(stderr, "\n");
  +        trace_op_dump(interpreter, code_start, pc);
       }
       else if (pc) {
           fprintf(stderr, "PC=%ld; OP=<err>\n", (long)(pc - code_start));
  
  
  


Reply via email to