pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: interpret.c,v 1.80 1998/04/20 18:43:08 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.81 1998/05/12 23:51:23 hubbe Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "error.h"   #include "language.h"   #include "stralloc.h"   #include "constants.h"
pike.git/src/interpret.c:381:   struct callback_list evaluator_callbacks;      #ifdef DEBUG   static char trace_buffer[100];   #define GET_ARG() (backlog[backlogp].arg=(\    instr=prefix,\    prefix=0,\    instr+=EXTRACT_UCHAR(pc++),\    (t_flag>3 ? sprintf(trace_buffer,"- Arg = %ld\n",(long)instr),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\    instr)) + #define GET_ARG2() (\ +  instr=EXTRACT_UCHAR(pc++),\ +  (t_flag>3 ? sprintf(trace_buffer,"- Arg2= %ld\n",(long)instr),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\ +  instr)    -  +    #else   #define GET_ARG() (instr=prefix,prefix=0,instr+EXTRACT_UCHAR(pc++)) -  + #define GET_ARG2() EXTRACT_UCHAR(pc++)   #endif      #define CASE(X) case (X)-F_OFFSET:      #define DOJUMP() \    do { int tmp; tmp=EXTRACT_INT(pc); pc+=tmp; if(tmp < 0) fast_check_threads_etc(6); }while(0)      #define COMPARISMENT(ID,EXPR) \   CASE(ID); \   instr=EXPR; \
pike.git/src/interpret.c:734:       CASE(F_MARK_AND_LOCAL); *(mark_sp++)=sp;    CASE(F_LOCAL);    assign_svalue_no_free(sp++,fp->locals+GET_ARG());    print_return_value();    break;       CASE(F_2_LOCALS);    assign_svalue_no_free(sp++,fp->locals+GET_ARG());    print_return_value(); -  assign_svalue_no_free(sp++,fp->locals+GET_ARG()); +  assign_svalue_no_free(sp++,fp->locals+GET_ARG2());    print_return_value();    break;    -  +  CASE(F_LOCAL_2_LOCAL); +  { +  int tmp=GET_ARG(); +  assign_svalue(fp->locals+tmp, fp->locals+GET_ARG2()); +  break; +  }    -  +  CASE(F_LOCAL_2_GLOBAL); +  { +  INT32 tmp=GET_ARG() + fp->context.identifier_level; +  struct identifier *i; +  +  if(!fp->current_object->prog) +  error("Cannot access global variables in destructed object.\n"); +  +  i=ID_FROM_INT(fp->current_object->prog, tmp); +  if(!IDENTIFIER_IS_VARIABLE(i->identifier_flags)) +  error("Cannot assign functions or constants.\n"); +  if(i->run_time_type == T_MIXED) +  { +  assign_svalue((struct svalue *)GLOBAL_FROM_INT(tmp), fp->locals + GET_ARG2()); +  }else{ +  assign_to_short_svalue((union anything *)GLOBAL_FROM_INT(tmp), +  i->run_time_type, +  fp->locals + GET_ARG2()); +  } +  break; +  } +  +  CASE(F_GLOBAL_2_LOCAL); +  { +  INT32 tmp=GET_ARG() + fp->context.identifier_level; +  INT32 tmp2=GET_ARG2(); +  free_svalue(fp->locals + tmp2); +  low_object_index_no_free(fp->locals + tmp2, +  fp->current_object, +  tmp); +  break; +  } +     CASE(F_LOCAL_LVALUE);    sp[0].type=T_LVALUE;    sp[0].u.lval=fp->locals+GET_ARG();    sp[1].type=T_VOID;    sp+=2;    break;       CASE(F_ARRAY_LVALUE);    f_aggregate(GET_ARG()*2);    sp[-1].u.array->flags |= ARRAY_LVALUE;
pike.git/src/interpret.c:1142:       CASE(F_CLEAR_STRING_SUBTYPE);    if(sp[-1].type==T_STRING) sp[-1].subtype=0;    break;       /* Jumps */    CASE(F_BRANCH);    DOJUMP();    break;    +  CASE(F_BRANCH_IF_NOT_LOCAL_ARROW); +  { +  struct svalue tmp; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=1; +  sp->type=T_INT; +  sp++; +  index_no_free(sp-1,fp->locals+GET_ARG2() , &tmp); +  print_return_value(); +  } +  +  /* Fall through */ +     CASE(F_BRANCH_WHEN_ZERO);    if(!IS_ZERO(sp-1))    {    pc+=sizeof(INT32);    }else{    DOJUMP();    }    pop_stack();    break;   
pike.git/src/interpret.c:1172:    CASE(F_BRANCH_IF_LOCAL);    instr=GET_ARG();    if(IS_ZERO(fp->locals + instr))    {    pc+=sizeof(INT32);    }else{    DOJUMP();    }    break;    +  CASE(F_BRANCH_IF_NOT_LOCAL); +  instr=GET_ARG(); +  if(!IS_ZERO(fp->locals + instr)) +  { +  pc+=sizeof(INT32); +  }else{ +  DOJUMP(); +  } +  break; +     CJUMP(F_BRANCH_WHEN_EQ, is_eq);    CJUMP(F_BRANCH_WHEN_NE,!is_eq);    CJUMP(F_BRANCH_WHEN_LT, is_lt);    CJUMP(F_BRANCH_WHEN_LE,!is_gt);    CJUMP(F_BRANCH_WHEN_GT, is_gt);    CJUMP(F_BRANCH_WHEN_GE,!is_lt);       CASE(F_BRANCH_AND_POP_WHEN_ZERO);    if(!IS_ZERO(sp-1))    {
pike.git/src/interpret.c:1427:    PIKE_ERROR("@", "Bad argument.\n", sp, 1);    sp--;    push_array_items(sp->u.array);    break;       CASE(F_LOCAL_LOCAL_INDEX);    {    struct svalue *s=fp->locals+GET_ARG();    if(s->type == T_STRING) s->subtype=0;    sp++->type=T_INT; -  index_no_free(sp-1,fp->locals+GET_ARG(),s); +  index_no_free(sp-1,fp->locals+GET_ARG2(),s);    break;    }       CASE(F_LOCAL_INDEX);    {    struct svalue tmp,*s=fp->locals+GET_ARG();    if(s->type == T_STRING) s->subtype=0;    index_no_free(&tmp,sp-1,s);    free_svalue(sp-1);    sp[-1]=tmp;    break;    }    -  CASE(F_POS_INT_INDEX); -  push_int(GET_ARG()); -  print_return_value(); -  goto do_index; +  CASE(F_GLOBAL_LOCAL_INDEX); +  { +  struct svalue tmp,*s; +  low_object_index_no_free(sp, +  fp->current_object, +  GET_ARG() + fp->context.identifier_level); +  sp++; +  s=fp->locals+GET_ARG2(); +  if(s->type == T_STRING) s->subtype=0; +  index_no_free(&tmp,sp-1,s); +  free_svalue(sp-1); +  sp[-1]=tmp; +  break; +  }    -  CASE(F_NEG_INT_INDEX); -  push_int(-GET_ARG()); +  CASE(F_LOCAL_ARROW); +  { +  struct svalue tmp; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=1; +  sp->type=T_INT; +  sp++; +  index_no_free(sp-1,fp->locals+GET_ARG2() , &tmp);    print_return_value(); -  goto do_index; +  break; +  }       CASE(F_ARROW); -  copy_shared_string(sp->u.string,fp->context.prog->strings[GET_ARG()]); -  sp->type=T_STRING; -  sp->subtype=1; -  sp++; +  { +  struct svalue tmp,tmp2; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=1; +  index_no_free(&tmp2, sp-1, &tmp); +  free_svalue(sp-1); +  sp[-1]=tmp2;    print_return_value(); -  goto do_index; +  break; +  }       CASE(F_STRING_INDEX); -  copy_shared_string(sp->u.string,fp->context.prog->strings[GET_ARG()]); -  sp->type=T_STRING; -  sp->subtype=0; -  sp++; +  { +  struct svalue tmp,tmp2; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=0; +  index_no_free(&tmp2, sp-1, &tmp); +  free_svalue(sp-1); +  sp[-1]=tmp2;    print_return_value(); -  /* Fall through */ +  break; +  }    -  +  CASE(F_POS_INT_INDEX); +  push_int(GET_ARG()); +  print_return_value(); +  goto do_index; +  +  CASE(F_NEG_INT_INDEX); +  push_int(-GET_ARG()); +  print_return_value(); +     CASE(F_INDEX);    do_index:    o_index();    print_return_value();    break;       CASE(F_CAST); f_cast(); break;       CASE(F_RANGE); o_range(); break;    CASE(F_COPY_VALUE);