pike.git / src / interpret_functions.h

version» Context lines:

pike.git/src/interpret_functions.h:1:   /* -  * $Id: interpret_functions.h,v 1.7 2000/04/18 20:23:59 grubba Exp $ +  * $Id: interpret_functions.h,v 1.8 2000/04/19 14:14:12 grubba Exp $    *    * Opcode definitions for the interpreter.    */      OPCODE0(F_UNDEFINED,"push UNDEFINED")    push_int(0);    Pike_sp[-1].subtype=NUMBER_UNDEFINED;   BREAK;      OPCODE0(F_CONST0, "push 0")
pike.git/src/interpret_functions.h:536:    }else{    Pike_sp[0].type=T_SHORT_LVALUE;    Pike_sp[0].u.short_lval= (union anything *)GLOBAL_FROM_INT(tmp);    Pike_sp[0].subtype=i->run_time_type;    }    Pike_sp[1].type=T_VOID;    Pike_sp+=2;    break;    }    -  CASE(F_INC); + OPCODE0(F_INC, "++x")   {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT);    if(u   #ifdef AUTO_BIGNUM    && !INT_TYPE_ADD_OVERFLOW(u->integer, 1)   #endif    )    {    instr=++ u->integer;    pop_n_elems(2);    push_int(u->integer); -  break; -  } +  } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    f_add(2);    assign_lvalue(Pike_sp-3, Pike_sp-1);    assign_svalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(2); -  break; +     } -  + } + BREAK;    -  CASE(F_DEC); + OPCODE0(F_DEC, "--x")   {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT);    if(u   #ifdef AUTO_BIGNUM    && !INT_TYPE_SUB_OVERFLOW(u->integer, 1)   #endif    )    {    instr=-- u->integer;    pop_n_elems(2);    push_int(u->integer); -  break; -  } +  } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    o_subtract();    assign_lvalue(Pike_sp-3, Pike_sp-1);    assign_svalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(2); -  break; +     } -  + } + BREAK;    -  CASE(F_DEC_AND_POP); + OPCODE0(F_DEC_AND_POP, "x-- and pop")   {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT);    if(u   #ifdef AUTO_BIGNUM    && !INT_TYPE_SUB_OVERFLOW(u->integer, 1)   #endif   )    {    instr=-- u->integer;    pop_n_elems(2);    }else{    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    o_subtract();    assign_lvalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(3);    } -  break; +    } -  + BREAK;    -  CASE(F_INC_AND_POP); + OPCODE0(F_INC_AND_POP, "x++ and pop")   {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT);    if(u   #ifdef AUTO_BIGNUM    && !INT_TYPE_ADD_OVERFLOW(u->integer, 1)   #endif    )    {    instr=++ u->integer;    pop_n_elems(2); -  break; -  } +  } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    f_add(2);    assign_lvalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(3); -  break; +     } -  + } + BREAK;    -  CASE(F_POST_INC); + OPCODE0(F_POST_INC, "x++")   {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT);    if(u   #ifdef AUTO_BIGNUM    && !INT_TYPE_ADD_OVERFLOW(u->integer, 1)   #endif    )    {    instr=u->integer ++;    pop_n_elems(2);    push_int(instr); -  break; -  } +  } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    assign_svalue_no_free(Pike_sp,Pike_sp-1); Pike_sp++;    push_int(1);    f_add(2);    assign_lvalue(Pike_sp-4, Pike_sp-1);    assign_svalue(Pike_sp-4, Pike_sp-2);    pop_n_elems(3); -  break; +     } -  + } + BREAK;    -  CASE(F_POST_DEC); + OPCODE0(F_POST_DEC, "x--")   {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT);    if(u   #ifdef AUTO_BIGNUM    && !INT_TYPE_SUB_OVERFLOW(u->integer, 1)   #endif    )    {    instr=u->integer --;    pop_n_elems(2);    push_int(instr); -  break; -  } +  } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    assign_svalue_no_free(Pike_sp,Pike_sp-1); Pike_sp++;    push_int(1);    o_subtract();    assign_lvalue(Pike_sp-4, Pike_sp-1);    assign_svalue(Pike_sp-4, Pike_sp-2);    pop_n_elems(3); -  break; +     } -  + } + BREAK;    -  CASE(F_ASSIGN); + OPCODE0(F_ASSIGN, "assign")    assign_lvalue(Pike_sp-3,Pike_sp-1);    free_svalue(Pike_sp-3);    free_svalue(Pike_sp-2);    Pike_sp[-3]=Pike_sp[-1];    Pike_sp-=2; -  break; + BREAK;    -  CASE(F_ASSIGN_AND_POP); -  assign_lvalue(Pike_sp-3,Pike_sp-1); + OPCODE0(F_ASSIGN_AND_POP, "assign and pop") +  assign_lvalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(3); -  break; + BREAK;       CASE(F_APPLY_ASSIGN_LOCAL);    strict_apply_svalue(Pike_fp->context.prog->constants + GET_ARG(), Pike_sp - *--Pike_mark_sp );    /* Fall through */       CASE(F_ASSIGN_LOCAL);    assign_svalue(Pike_fp->locals+GET_ARG(),Pike_sp-1);    break;       CASE(F_APPLY_ASSIGN_LOCAL_AND_POP);    strict_apply_svalue(Pike_fp->context.prog->constants + GET_ARG(), Pike_sp - *--Pike_mark_sp );    /* Fall through */       CASE(F_ASSIGN_LOCAL_AND_POP);    instr=GET_ARG();    free_svalue(Pike_fp->locals+instr);    Pike_fp->locals[instr]=Pike_sp[-1];    Pike_sp--;    break;    -  CASE(F_ASSIGN_GLOBAL) + OPCODE1(F_ASSIGN_GLOBAL, "assign global")   {    struct identifier *i; -  INT32 tmp=GET_ARG() + Pike_fp->context.identifier_level; +  INT32 tmp=arg1 + Pike_fp->context.identifier_level;    if(!Pike_fp->current_object->prog)    error("Cannot access global variables in destructed object.\n");       i=ID_FROM_INT(Pike_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), Pike_sp-1);    }else{    assign_to_short_svalue((union anything *)GLOBAL_FROM_INT(tmp),    i->run_time_type,    Pike_sp-1);    }   } -  break; + BREAK;    -  CASE(F_ASSIGN_GLOBAL_AND_POP) + OPCODE1(F_ASSIGN_GLOBAL_AND_POP, "assign global and pop")   {    struct identifier *i; -  INT32 tmp=GET_ARG() + Pike_fp->context.identifier_level; +  INT32 tmp=arg1 + Pike_fp->context.identifier_level;    if(!Pike_fp->current_object->prog)    error("Cannot access global variables in destructed object.\n");       i=ID_FROM_INT(Pike_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)    {    struct svalue *s=(struct svalue *)GLOBAL_FROM_INT(tmp);    free_svalue(s);    Pike_sp--;    *s=*Pike_sp;    }else{    assign_to_short_svalue((union anything *)GLOBAL_FROM_INT(tmp),    i->run_time_type,    Pike_sp-1);    pop_stack();    }   } -  break; + BREAK;      /* Stack machine stuff */ -  CASE(F_POP_VALUE); pop_stack(); break; -  CASE(F_POP_N_ELEMS); pop_n_elems(GET_ARG()); break; +  + OPCODE0(F_POP_VALUE, "pop") +  pop_stack(); + BREAK; +  + OPCODE1(F_POP_N_ELEMS, "pop_n_elems") +  pop_n_elems(arg1); + BREAK; +     CASE(F_MARK2); *(Pike_mark_sp++)=Pike_sp;    CASE(F_MARK); *(Pike_mark_sp++)=Pike_sp; break; -  CASE(F_MARK_X); *(Pike_mark_sp++)=Pike_sp-GET_ARG(); break; -  CASE(F_POP_MARK); --Pike_mark_sp; break; +     -  CASE(F_CLEAR_STRING_SUBTYPE); + OPCODE1(F_MARK_X, "mark sp-X") +  *(Pike_mark_sp++)=Pike_sp-arg1; + BREAK; +  + OPCODE0(F_POP_MARK, "pop mark") +  --Pike_mark_sp; + BREAK; +  + OPCODE0(F_CLEAR_STRING_SUBTYPE, "clear string subtype")    if(Pike_sp[-1].type==PIKE_T_STRING) Pike_sp[-1].subtype=0; -  break; + BREAK;       /* Jumps */    CASE(F_BRANCH);    DOJUMP();    break;       CASE(F_BRANCH_IF_NOT_LOCAL_ARROW);    {    struct svalue tmp;    tmp.type=PIKE_T_STRING;
pike.git/src/interpret_functions.h:901:    }    break;       CASE(F_CATCH);    if(o_catch(pc+sizeof(INT32)))    return -1; /* There was a return inside the evaluated code */    else    pc+=EXTRACT_INT(pc);    break;    -  CASE(F_THROW_ZERO); + OPCODE0(F_THROW_ZERO, "throw(0)")    push_int(0);    f_throw(1); -  break; + BREAK;    -  CASE(F_SWITCH) + OPCODE1(F_SWITCH, "switch")   {    INT32 tmp;    tmp=switch_lookup(Pike_fp->context.prog-> -  constants[GET_ARG()].sval.u.array,Pike_sp-1); +  constants[arg1].sval.u.array,Pike_sp-1);    pc=(unsigned char *)DO_ALIGN(pc,sizeof(INT32));    pc+=(tmp>=0 ? 1+tmp*2 : 2*~tmp) * sizeof(INT32);    if(*(INT32*)pc < 0) fast_check_threads_etc(7);    pc+=*(INT32*)pc;    pop_stack(); -  break; +    } -  + BREAK;       /* FIXME: Does this need bignum tests? /Fixed - Hubbe */    LOOP(F_INC_LOOP, 1, <, is_lt);    LOOP(F_DEC_LOOP, -1, >, is_gt);    LOOP(F_INC_NEQ_LOOP, 1, !=, !is_eq);    LOOP(F_DEC_NEQ_LOOP, -1, !=, !is_eq);       CASE(F_FOREACH) /* array, lvalue, X, i */    {    if(Pike_sp[-4].type != PIKE_T_ARRAY)
pike.git/src/interpret_functions.h:1023: Inside #if defined(PIKE_DEBUG) && defined(GC2)
   if(d_flag>3) do_gc();    if(d_flag>4) do_debug();    check_threads_etc();   #endif       /* fall through */       CASE(F_DUMB_RETURN);    return -1;    -  CASE(F_NEGATE); + OPCODE0(F_NEGATE, "unary minus")    if(Pike_sp[-1].type == PIKE_T_INT)    {   #ifdef AUTO_BIGNUM    if(INT_TYPE_NEG_OVERFLOW(Pike_sp[-1].u.integer))    {    convert_stack_top_to_bignum();    o_negate();    }    else   #endif /* AUTO_BIGNUM */    Pike_sp[-1].u.integer =- Pike_sp[-1].u.integer;    }    else if(Pike_sp[-1].type == PIKE_T_FLOAT)    {    Pike_sp[-1].u.float_number =- Pike_sp[-1].u.float_number;    }else{    o_negate();    } -  break; + BREAK;    -  CASE(F_COMPL); o_compl(); break; + OPCODE0(F_COMPL, "~") +  o_compl(); + BREAK;    -  CASE(F_NOT); + OPCODE0(F_NOT, "!")    switch(Pike_sp[-1].type)    {    case PIKE_T_INT:    Pike_sp[-1].u.integer =! Pike_sp[-1].u.integer;    break;       case PIKE_T_FUNCTION:    case PIKE_T_OBJECT:    if(IS_ZERO(Pike_sp-1))    {
pike.git/src/interpret_functions.h:1070:    pop_stack();    push_int(0);    }    break;       default:    free_svalue(Pike_sp-1);    Pike_sp[-1].type=PIKE_T_INT;    Pike_sp[-1].u.integer=0;    } -  break; + BREAK;    -  CASE(F_LSH); o_lsh(); break; -  CASE(F_RSH); o_rsh(); break; + OPCODE0(F_LSH, "<<") +  o_lsh(); + BREAK;    -  + OPCODE0(F_RSH, ">>") +  o_rsh(); + BREAK; +     COMPARISMENT(F_EQ, is_eq(Pike_sp-2,Pike_sp-1));    COMPARISMENT(F_NE,!is_eq(Pike_sp-2,Pike_sp-1));    COMPARISMENT(F_GT, is_gt(Pike_sp-2,Pike_sp-1));    COMPARISMENT(F_GE,!is_lt(Pike_sp-2,Pike_sp-1));    COMPARISMENT(F_LT, is_lt(Pike_sp-2,Pike_sp-1));    COMPARISMENT(F_LE,!is_gt(Pike_sp-2,Pike_sp-1));       CASE(F_ADD); f_add(2); break;    CASE(F_SUBTRACT); o_subtract(); break;    CASE(F_AND); o_and(); break;
pike.git/src/interpret_functions.h:1225:   BREAK;      OPCODE1ACC(F_MAGIC_SET_INDEX, "::`[]=")    push_magic_index(magic_set_index_program, acc, arg1);   BREAK;      OPCODE0(F_CAST, "cast")    f_cast();   BREAK;    -  CASE(F_SOFT_CAST); + OPCODE0(F_SOFT_CAST, "soft cast")    /* Stack: type_string, value */   #ifdef PIKE_DEBUG    if (Pike_sp[-2].type != T_STRING) {    /* FIXME: The type should really be T_TYPE... */    fatal("Argument 1 to soft_cast isn't a string!\n");    }   #endif /* PIKE_DEBUG */    if (runtime_options & RUNTIME_CHECK_TYPES) {    struct pike_string *sval_type = get_type_of_svalue(Pike_sp-1);    if (!pike_types_le(sval_type, Pike_sp[-2].u.string)) {
pike.git/src/interpret_functions.h:1286: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if (d_flag > 2) {    struct pike_string *t = describe_type(Pike_sp[-2].u.string);    fprintf(stderr, "Soft cast to %s\n", t->str);    free_string(t);    }   #endif /* PIKE_DEBUG */    }    stack_swap();    pop_stack(); -  break; + BREAK;      OPCODE0(F_RANGE, "range")    o_range();   BREAK;      OPCODE0(F_COPY_VALUE, "copy_value")   {    struct svalue tmp;    copy_svalues_recursively_no_free(&tmp,Pike_sp-1,1,0);    free_svalue(Pike_sp-1);