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.74 1998/04/06 04:17:25 hubbe Exp $"); + RCSID("$Id: interpret.c,v 1.75 1998/04/10 18:06:05 grubba 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:1275:    break;    }       LOOP(F_INC_LOOP, ++, <, f_add(2), is_lt);    LOOP(F_DEC_LOOP, --, >, o_subtract(), is_gt);    LOOP(F_INC_NEQ_LOOP, ++, !=, f_add(2), !is_eq);    LOOP(F_DEC_NEQ_LOOP, --, !=, o_subtract(), !is_eq);       CASE(F_FOREACH) /* array, lvalue , i */    { -  if(sp[-4].type != T_ARRAY) error("Bad argument 1 to foreach()\n"); +  if(sp[-4].type != T_ARRAY) +  ERROR("foreach", "Bad argument 1.\n", sp-3, 1);    if(sp[-1].u.integer < sp[-4].u.array->size)    {    fast_check_threads_etc(10);    index_no_free(sp,sp-4,sp-1);    sp++;    assign_lvalue(sp-4, sp-1);    free_svalue(sp-1);    sp--;    pc+=EXTRACT_INT(pc);    sp[-1].u.integer++;
pike.git/src/interpret.c:1415:    CASE(F_OR); o_or(); break;    CASE(F_XOR); o_xor(); break;    CASE(F_MULTIPLY); o_multiply(); break;    CASE(F_DIVIDE); o_divide(); break;    CASE(F_MOD); o_mod(); break;       CASE(F_ADD_INT); push_int(GET_ARG()); f_add(2); break;    CASE(F_ADD_NEG_INT); push_int(-GET_ARG()); f_add(2); break;       CASE(F_PUSH_ARRAY); -  if(sp[-1].type!=T_ARRAY) error("Bad argument to @\n"); +  if(sp[-1].type!=T_ARRAY) +  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);
pike.git/src/interpret.c:1534:    break;       CASE(F_CALL_FUNCTION);    mega_apply(APPLY_STACK,sp - *--mark_sp,0,0);    break;       CASE(F_CALL_FUNCTION_AND_RETURN);    {    INT32 args=sp - *--mark_sp;    if(!args) -  error("Too few arguments to call_function()\n"); +  ERROR("`()", "Too few arguments.\n", sp, 0);    switch(sp[-args].type)    {    case T_INT:    case T_STRING:    case T_FLOAT:    case T_MAPPING:    case T_MULTISET: -  error("Attempting to call a non-function value (%s).\n",get_name_of_type(sp[-args].type)); +  ERROR("`()", "Attempt to call a non-function value.\n", sp, args);    }    return args;    }       default:    fatal("Strange instruction %ld\n",(long)instr);    }       }   }
pike.git/src/interpret.c:1622: Inside #if defined(PROFILING) and #if defined(HAVE_GETHRTIME)
  #ifdef HAVE_GETHRTIME    long long start_time = gethrtime();   #endif   #endif       switch(type)    {    case APPLY_STACK:    apply_stack:    if(!args) -  error("Too few arguments to `()\n"); +  ERROR("`()", "Too few arguments.\n", sp, 0);    args--;    if(sp-save_sp-args > (args<<2) + 32)    {    /* The test above assures these two areas    * are not overlapping    */    assign_svalues(save_sp, sp-args-1, args+1, BIT_MIXED);    pop_n_elems(sp-save_sp-args-1);    }    arg1=(void *)(sp-args-1);       case APPLY_SVALUE:    apply_svalue:    {    struct svalue *s=(struct svalue *)arg1;    switch(s->type)    {    case T_INT:    if (!s->u.integer) { -  error("Attempt to call the NULL-value\n"); +  ERROR("0", "Attempt to call the NULL-value\n", sp, args);    } else {    error("Attempt to call the value %d\n", s->u.integer);    }       case T_STRING:    if (s->u.string->len > 20) {    error("Attempt to call the string \"%20s\"...\n", s->u.string->str);    } else {    error("Attempt to call the string \"%s\"\n", s->u.string->str);    }    case T_MAPPING:    error("Attempt to call a mapping\n");    default: -  error("Call to non-function value type:%d.\n", s->type); +  error("Call to non-function value type:%s.\n", +  get_name_of_type(s->type));       case T_FUNCTION:    if(s->subtype == FUNCTION_BUILTIN)    {   #ifdef DEBUG    if(t_flag>1)    {    init_buf();    describe_svalue(s,0,0);    do_trace_call(args);
pike.git/src/interpret.c:1716:    }    break;    }       call_lfun:   #ifdef DEBUG    if(fun < 0 || fun >= NUM_LFUNS)    fatal("Apply lfun on illegal value!\n");   #endif    if(!o->prog) -  error("Apply on destructed object.\n"); +  ERROR("destructed object", "Apply on destructed object.\n", sp, args);    fun=FIND_LFUN(o->prog,fun);    goto apply_low;          case APPLY_LOW:    o=(struct object *)arg1;    fun=(long)arg2;       apply_low:    {
pike.git/src/interpret.c:1749:    check_threads_etc();    check_stack(256);    check_mark_stack(256);      #ifdef DEBUG    if(d_flag>2) do_debug();   #endif       p=o->prog;    if(!p) -  error("Cannot call functions in destructed objects.\n"); +  ERROR("destructed object->function", +  "Cannot call functions in destructed objects.\n", sp, args);   #ifdef DEBUG    if(fun>=(int)p->num_identifier_references)    fatal("Function index out of range.\n");   #endif       ref = p->identifier_references + fun;   #ifdef DEBUG    if(ref->inherit_offset>=p->num_inherits)    fatal("Inherit offset out of range in program.\n");   #endif
pike.git/src/interpret.c:1795:    init_buf();    sprintf(buf,"%lx->",(long)o);    my_strcat(buf);    my_strcat(function->name->str);    do_trace_call(args);    }       fp = &new_frame;       if(function->func.offset == -1) -  error("Calling undefined function '%s'.\n",function->name->str); +  ERROR(function->name->str, "Calling undefined function.\n", sp, args);       tailrecurse=-1;    switch(function->identifier_flags & (IDENTIFIER_FUNCTION | IDENTIFIER_CONSTANT))    {    case IDENTIFIER_C_FUNCTION:    fp->num_args=args;    new_frame.num_locals=args;    (*function->func.c_fun)(args);    break;   
pike.git/src/interpret.c:2062:    safe_apply_low(o, find_identifier(fun, o->prog), args);   }      void apply_lfun(struct object *o, int fun, int args)   {   #ifdef DEBUG    if(fun < 0 || fun >= NUM_LFUNS)    fatal("Apply lfun on illegal value!\n");   #endif    if(!o->prog) -  error("Apply on destructed object.\n"); +  ERROR("destructed object", "Apply on destructed object.\n", sp, args);       apply_low(o, (int)FIND_LFUN(o->prog,fun), args);   }      void apply_shared(struct object *o,    struct pike_string *fun,    int args)   {    apply_low(o, find_shared_string_identifier(fun, o->prog), args);   }