pike.git / src / interpret_functions.h

version» Context lines:

pike.git/src/interpret_functions.h:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: interpret_functions.h,v 1.174 2004/10/01 13:26:40 grubba Exp $ + || $Id: interpret_functions.h,v 1.175 2004/10/06 18:35:02 mast Exp $   */      /*    * Opcode definitions for the interpreter.    */      #include "global.h"      #undef CJUMP   #undef AUTO_BIGNUM_LOOP_TEST
pike.git/src/interpret_functions.h:313:    if ((Pike_sp[-1].type == T_OBJECT) && ((o = Pike_sp[-1].u.object)->prog) &&    (FIND_LFUN(o->prog, LFUN_ARROW) == -1)) {    int id = FIND_LFUN(o->prog, arg1);    if ((id != -1) &&    (!(o->prog->identifier_references[id].id_flags &    (ID_STATIC|ID_PRIVATE|ID_HIDDEN)))) {    low_object_index_no_free(&tmp, o, id);    } else {    /* Not found. */    tmp.type = T_INT; -  tmp.subtype = 1; +  tmp.subtype = NUMBER_UNDEFINED;    tmp.u.integer = 0;    }    } else {    LOCAL_VAR(struct svalue tmp2);    tmp2.type = PIKE_T_STRING;    tmp2.u.string = lfun_strings[arg1];    tmp2.subtype = 1;    index_no_free(&tmp, Pike_sp-1, &tmp2);    }    free_svalue(Pike_sp-1);
pike.git/src/interpret_functions.h:506:    Pike_sp[-1].u.array->type_field |= BIT_UNFINISHED | BIT_MIXED;    /* FIXME: Shouldn't a ref be added here? */    move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type = T_ARRAY_LVALUE;    Pike_sp++;   });      OPCODE1(F_CLEAR_2_LOCAL, "clear 2 local", 0, {    free_mixed_svalues(Pike_fp->locals + arg1, 2);    Pike_fp->locals[arg1].type = PIKE_T_INT; -  Pike_fp->locals[arg1].subtype = 0; +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER;    Pike_fp->locals[arg1].u.integer = 0;    Pike_fp->locals[arg1+1].type = PIKE_T_INT; -  Pike_fp->locals[arg1+1].subtype = 0; +  Pike_fp->locals[arg1+1].subtype = NUMBER_NUMBER;    Pike_fp->locals[arg1+1].u.integer = 0;   });      OPCODE1(F_CLEAR_4_LOCAL, "clear 4 local", 0, {    int e;    free_mixed_svalues(Pike_fp->locals + arg1, 4);    for(e = 0; e < 4; e++)    {    Pike_fp->locals[arg1+e].type = PIKE_T_INT; -  Pike_fp->locals[arg1+e].subtype = 0; +  Pike_fp->locals[arg1+e].subtype = NUMBER_NUMBER;    Pike_fp->locals[arg1+e].u.integer = 0;    }   });      OPCODE1(F_CLEAR_LOCAL, "clear local", 0, {    free_svalue(Pike_fp->locals + arg1);    Pike_fp->locals[arg1].type = PIKE_T_INT; -  Pike_fp->locals[arg1].subtype = 0; +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER;    Pike_fp->locals[arg1].u.integer = 0;   });      OPCODE1(F_INC_LOCAL, "++local", I_UPDATE_SP, {    if( (Pike_fp->locals[arg1].type == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    push_int(++(Pike_fp->locals[arg1].u.integer)); -  +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } else {    push_svalue(Pike_fp->locals+arg1);    push_int(1);    f_add(2);    assign_svalue(Pike_fp->locals+arg1,Pike_sp-1);    }   });      OPCODE1(F_POST_INC_LOCAL, "local++", I_UPDATE_SP, {    push_svalue( Pike_fp->locals + arg1);       if( (Pike_fp->locals[arg1].type == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    Pike_fp->locals[arg1].u.integer++; -  +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } else {    push_svalue(Pike_fp->locals + arg1);    push_int(1);    f_add(2);    stack_pop_to(Pike_fp->locals + arg1);    }   });      OPCODE1(F_INC_LOCAL_AND_POP, "++local and pop", 0, {    if( (Pike_fp->locals[arg1].type == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    Pike_fp->locals[arg1].u.integer++; -  +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } else {    push_svalue( Pike_fp->locals + arg1);    push_int(1);    f_add(2);    stack_pop_to(Pike_fp->locals + arg1);    }   });      OPCODE1(F_DEC_LOCAL, "--local", I_UPDATE_SP, {    if( (Pike_fp->locals[arg1].type == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_SUB_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    push_int(--(Pike_fp->locals[arg1].u.integer)); -  +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } else {    push_svalue(Pike_fp->locals+arg1);    push_int(1);    o_subtract();    assign_svalue(Pike_fp->locals+arg1,Pike_sp-1);    }   });      OPCODE1(F_POST_DEC_LOCAL, "local--", I_UPDATE_SP, {    push_svalue( Pike_fp->locals + arg1);       if( (Pike_fp->locals[arg1].type == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_SUB_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    Pike_fp->locals[arg1].u.integer--; -  +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } else {    push_svalue(Pike_fp->locals + arg1);    push_int(1);    o_subtract();    stack_pop_to(Pike_fp->locals + arg1);    } -  /* Pike_fp->locals[instr].u.integer--; */ +    });      OPCODE1(F_DEC_LOCAL_AND_POP, "--local and pop", 0, {    if( (Pike_fp->locals[arg1].type == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_SUB_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    Pike_fp->locals[arg1].u.integer--; -  +  Pike_fp->locals[arg1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } else {    push_svalue(Pike_fp->locals + arg1);    push_int(1);    o_subtract();    stack_pop_to(Pike_fp->locals + arg1);    }   });      OPCODE0(F_LTOSVAL, "lvalue to svalue", I_UPDATE_SP, {    dmalloc_touch_svalue(Pike_sp-2);
pike.git/src/interpret_functions.h:649:      OPCODE0(F_LTOSVAL2, "ltosval2", I_UPDATE_SP, {    dmalloc_touch_svalue(Pike_sp-3);    dmalloc_touch_svalue(Pike_sp-2);    dmalloc_touch_svalue(Pike_sp-1);    move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type = PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2, Pike_sp-4);    -  /* this is so that foo+=bar (and similar things) will be faster, this -  * is done by freeing the old reference to foo after it has been pushed -  * on the stack. That way foo can have only 1 reference if we are lucky, -  * and then the low array/multiset/mapping manipulation routines can be -  * destructive if they like +  /* This is so that foo+=bar (and similar things) will be faster. +  * It's done by freeing the old reference to foo after it has been +  * pushed on the stack. That way foo can have only 1 reference if we +  * are lucky, and then the low array/multiset/mapping manipulation +  * routines can be destructive if they like.    */    if( (1 << Pike_sp[-2].type) &    (BIT_ARRAY | BIT_MULTISET | BIT_MAPPING | BIT_STRING) )    {    LOCAL_VAR(struct svalue tmp);    tmp.type = PIKE_T_INT; -  tmp.subtype = 0; +  tmp.subtype = NUMBER_NUMBER;    tmp.u.integer = 0;    assign_lvalue(Pike_sp-4, &tmp);    }   });      OPCODE0(F_LTOSVAL3, "ltosval3", I_UPDATE_SP, {    move_svalue (Pike_sp, Pike_sp - 1);    move_svalue (Pike_sp - 1, Pike_sp - 2);    Pike_sp[-2].type = PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-3, Pike_sp-5);    -  /* this is so that foo=foo[x..y] (and similar things) will be faster, this -  * is done by freeing the old reference to foo after it has been pushed -  * on the stack. That way foo can have only 1 reference if we are lucky, -  * and then the low array/multiset/mapping manipulation routines can be -  * destructive if they like +  /* This is so that foo=foo[x..y] (and similar things) will be faster. +  * It's done by freeing the old reference to foo after it has been +  * pushed on the stack. That way foo can have only 1 reference if we +  * are lucky, and then the low array/multiset/mapping manipulation +  * routines can be destructive if they like.    */    if( (1 << Pike_sp[-3].type) &    (BIT_ARRAY | BIT_MULTISET | BIT_MAPPING | BIT_STRING) )    {    LOCAL_VAR(struct svalue tmp);    tmp.type = PIKE_T_INT; -  tmp.subtype = 0; +  tmp.subtype = NUMBER_NUMBER;    tmp.u.integer = 0;    assign_lvalue(Pike_sp-5, &tmp);    }   });      OPCODE0(F_ADD_TO, "+=", I_UPDATE_SP, {    move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type=PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4);       if( Pike_sp[-1].type == PIKE_T_INT &&    Pike_sp[-2].type == PIKE_T_INT )    {    DO_IF_BIGNUM(    if(!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer))    )    {    /* Optimization for a rather common case. Makes it 30% faster. */    INT_TYPE val = (Pike_sp[-1].u.integer += Pike_sp[-2].u.integer); -  +  Pike_sp[-1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    assign_lvalue(Pike_sp-4,Pike_sp-1);    Pike_sp-=2;    pop_2_elems();    push_int(val);    goto add_to_done;    }    } -  /* this is so that foo+=bar (and similar things) will be faster, this -  * is done by freeing the old reference to foo after it has been pushed -  * on the stack. That way foo can have only 1 reference if we are lucky, -  * and then the low array/multiset/mapping manipulation routines can be -  * destructive if they like +  /* This is so that foo+=bar (and similar things) will be faster. +  * It's done by freeing the old reference to foo after it has been +  * pushed on the stack. That way foo can have only 1 reference if we +  * are lucky, and then the low array/multiset/mapping manipulation +  * routines can be destructive if they like.    */    if( (1 << Pike_sp[-2].type) &    (BIT_ARRAY | BIT_MULTISET | BIT_MAPPING | BIT_STRING) )    {    LOCAL_VAR(struct svalue tmp);    tmp.type=PIKE_T_INT; -  tmp.subtype=0; +  tmp.subtype=NUMBER_NUMBER;    tmp.u.integer=0;    assign_lvalue(Pike_sp-4, &tmp);    } else if (Pike_sp[-2].type == T_OBJECT) {    /* One ref in the lvalue, and one on the stack. */    int i;    if(Pike_sp[-2].u.object->refs <= 2 &&    (i = FIND_LFUN(Pike_sp[-2].u.object->prog, LFUN_ADD_EQ)) != -1)    {    apply_low(Pike_sp[-2].u.object, i, 1);    /* NB: The lvalue already contains the object, so
pike.git/src/interpret_functions.h:763:       if( Pike_sp[-1].type == PIKE_T_INT &&    Pike_sp[-2].type == PIKE_T_INT )    {    DO_IF_BIGNUM(    if(!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer))    )    {    /* Optimization for a rather common case. Makes it 30% faster. */    Pike_sp[-1].u.integer += Pike_sp[-2].u.integer; +  Pike_sp[-1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    assign_lvalue(Pike_sp-4,Pike_sp-1);    Pike_sp-=2;    pop_2_elems();    goto add_to_and_pop_done;    }    } -  /* this is so that foo+=bar (and similar things) will be faster, this -  * is done by freeing the old reference to foo after it has been pushed -  * on the stack. That way foo can have only 1 reference if we are lucky, -  * and then the low array/multiset/mapping manipulation routines can be -  * destructive if they like +  /* This is so that foo+=bar (and similar things) will be faster. +  * It's done by freeing the old reference to foo after it has been +  * pushed on the stack. That way foo can have only 1 reference if we +  * are lucky, and then the low array/multiset/mapping manipulation +  * routines can be destructive if they like.    */    if( (1 << Pike_sp[-2].type) &    (BIT_ARRAY | BIT_MULTISET | BIT_MAPPING | BIT_STRING) )    {    LOCAL_VAR(struct svalue tmp);    tmp.type=PIKE_T_INT; -  tmp.subtype=0; +  tmp.subtype=NUMBER_NUMBER;    tmp.u.integer=0;    assign_lvalue(Pike_sp-4, &tmp);    } else if (Pike_sp[-2].type == PIKE_T_OBJECT) {    /* One ref in the lvalue, and one on the stack. */    int i;    if(Pike_sp[-2].u.object->refs <= 2 &&    (i = FIND_LFUN(Pike_sp[-2].u.object->prog, LFUN_ADD_EQ)) != -1)    {    apply_low(Pike_sp[-2].u.object, i, 1);    /* NB: The lvalue already contains the object, so
pike.git/src/interpret_functions.h:1371:    if (!is_lt(Pike_sp-2, Pike_sp-1)) {    o_subtract();    DO_BRANCH();    } else {    /* write_to_stderr("foreach\n", 8); */    DONT_BRANCH();    pop_2_elems();    }   });    - OPCODE0_BRANCH(F_FOREACH, "foreach", 0, { /* array, lvalue, X, i */ + OPCODE0_BRANCH(F_FOREACH, "foreach", 0, { /* array, lvalue, i */    if(Pike_sp[-4].type != PIKE_T_ARRAY)    PIKE_ERROR("foreach", "Bad argument 1.\n", Pike_sp-3, 1);    if(Pike_sp[-1].u.integer < Pike_sp[-4].u.array->size)    {    if(Pike_sp[-1].u.integer < 0) -  +  /* Isn't this an internal compiler error? /mast */    Pike_error("Foreach loop variable is negative!\n");    assign_lvalue(Pike_sp-3, Pike_sp[-4].u.array->item + Pike_sp[-1].u.integer);    DO_BRANCH();    Pike_sp[-1].u.integer++; -  +  DO_IF_DEBUG ( +  if (Pike_sp[-1].subtype) +  Pike_fatal ("Got unexpected subtype in loop variable.\n"); +  );    }else{    /* write_to_stderr("foreach\n", 8); */    DONT_BRANCH();    }   });      OPCODE0(F_MAKE_ITERATOR, "get_iterator", 0, {    f_get_iterator(1);   });   
pike.git/src/interpret_functions.h:1473:    if(Pike_sp[-1].type == PIKE_T_INT)    {    DO_IF_BIGNUM(    if(INT_TYPE_NEG_OVERFLOW(Pike_sp[-1].u.integer))    {    convert_stack_top_to_bignum();    o_negate();    }    else    ) +  {    Pike_sp[-1].u.integer =- Pike_sp[-1].u.integer; -  +  Pike_sp[-1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    } -  +  }    else if(Pike_sp[-1].type == PIKE_T_FLOAT)    {    Pike_sp[-1].u.float_number =- Pike_sp[-1].u.float_number;    }else{    o_negate();    }   });      OPCODE0_ALIAS(F_COMPL, "~", 0, o_compl);      OPCODE0(F_NOT, "!", 0, {    switch(Pike_sp[-1].type)    {    case PIKE_T_INT:    Pike_sp[-1].u.integer =! Pike_sp[-1].u.integer; -  +  Pike_sp[-1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    break;       case PIKE_T_FUNCTION:    case PIKE_T_OBJECT:    if(UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    push_int(1);    }else{    pop_stack();    push_int(0);    }    break;       default:    free_svalue(Pike_sp-1);    Pike_sp[-1].type=PIKE_T_INT; -  +  Pike_sp[-1].subtype = NUMBER_NUMBER;    Pike_sp[-1].u.integer=0;    }   });      OPCODE0_ALIAS(F_LSH, "<<", I_UPDATE_SP, o_lsh);   OPCODE0_ALIAS(F_RSH, ">>", I_UPDATE_SP, o_rsh);      #define COMPARISON(ID,DESC,EXPR) \    OPCODE0(ID, DESC, I_UPDATE_SP, { \    INT32 val = EXPR; \
pike.git/src/interpret_functions.h:1540:   });      OPCODE0(F_ADD_INTS, "int+int", I_UPDATE_SP, {    if(Pike_sp[-1].type == T_INT && Pike_sp[-2].type == T_INT    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer))    )    )    {    Pike_sp[-2].u.integer+=Pike_sp[-1].u.integer; +  Pike_sp[-2].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    }else{    f_add(2);    }   });      OPCODE0(F_ADD_FLOATS, "float+float", I_UPDATE_SP, {    if(Pike_sp[-1].type == T_FLOAT && Pike_sp[-2].type == T_FLOAT)    {
pike.git/src/interpret_functions.h:1574:   OPCODE0_ALIAS(F_MOD, "%", I_UPDATE_SP, o_mod);      OPCODE1(F_ADD_INT, "add integer", 0, {    if(Pike_sp[-1].type == T_INT    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, arg1))    )    )    {    Pike_sp[-1].u.integer+=arg1; +  Pike_sp[-1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    }else{    push_int(arg1);    f_add(2);    }   });      OPCODE1(F_ADD_NEG_INT, "add -integer", 0, {    if(Pike_sp[-1].type == T_INT    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, -arg1))    )    )    {    Pike_sp[-1].u.integer-=arg1; -  +  Pike_sp[-1].subtype = NUMBER_NUMBER; /* Could have UNDEFINED there before. */    }else{    push_int(-arg1);    f_add(2);    }   });      OPCODE0(F_PUSH_ARRAY, "@", I_UPDATE_SP, {    switch(Pike_sp[-1].type)    {    default: