pike.git / src / las.c

version» Context lines:

pike.git/src/las.c: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: las.c,v 1.351 2004/10/30 11:38:26 mast Exp $ + || $Id: las.c,v 1.352 2004/11/05 16:21:23 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "las.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "lex.h"
pike.git/src/las.c:3499:   }      void yytype_error(char *msg, struct pike_type *expected_t,    struct pike_type *got_t, unsigned int flags)   {    if (msg)    {    if (flags & YYTE_IS_WARNING)    yywarning("%s", msg);    else -  my_yyerror("%s", msg); +  yyerror(msg);    }       yyexplain_nonmatching_types(expected_t, got_t, flags);   }      void fix_type_field(node *n)   {    struct pike_type *type_a, *type_b;    struct pike_type *old_type;   
pike.git/src/las.c:3562:    else if(n->token == F_LAND || CAR(n)->type == CDR(n)->type)    {    copy_pike_type(n->type, CDR(n)->type);    }else{    n->type = or_pike_types(CAR(n)->type, CDR(n)->type, 0);    }    break;       case F_ASSIGN:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Assigning a void expression."); +  yyerror("Assigning a void expression.");    copy_pike_type(n->type, void_type_string);    break;    } else if(CAR(n) && CDR(n)) {    /* Ensure that the type-fields are up to date. */    fix_type_field(CAR(n));    fix_type_field(CDR(n));    if (!pike_types_le(CAR(n)->type, CDR(n)->type)) {    /* a["b"]=c and a->b=c can be valid when a is an array */    if (((CDR(n)->token != F_INDEX &&    CDR(n)->token != F_ARROW) ||
pike.git/src/las.c:3640:    push_type(T_ARRAY);    free_type(t);    n->type = pop_unfinished_type();    }    }    break;       case F_INDEX:    case F_ARROW:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Indexing a void expression."); +  yyerror("Indexing a void expression.");    /* The optimizer converts this to an expression returning 0. */    copy_pike_type(n->type, zero_type_string);    } else {    type_a=CAR(n)->type;    type_b=CDR(n)->type;    if(!check_indexing(type_a, type_b, n))    if(!Pike_compiler->catch_level) -  my_yyerror("Indexing on illegal type."); +  yyerror("Indexing on illegal type.");    n->type=index_type(type_a, type_b,n);    }    break;       case F_RANGE:    if (!CAR(n)) {    /* Unlikely to occur, and if it does, it has probably    * already been complained about.    */    copy_pike_type(n->type, mixed_type_string);
pike.git/src/las.c:3670:    else {    node *low = CADR (n), *high = CDDR (n);    n->type = range_type(CAR(n)->type,    low->token == F_RANGE_OPEN ? NULL : CAR (low)->type,    high->token == F_RANGE_OPEN ? NULL : CAR (high)->type);    }    break;       case F_AUTO_MAP_MARKER:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Indexing a void expression."); +  yyerror("Indexing a void expression.");    /* The optimizer converts this to an expression returning 0. */    copy_pike_type(n->type, zero_type_string);    } else {    type_a=CAR(n)->type;    if(!match_types(type_a, array_type_string))    if(!Pike_compiler->catch_level) -  my_yyerror("[*] on non-array."); +  yyerror("[*] on non-array.");    n->type=index_type(type_a, int_type_string, n);    }    break;       case F_AUTO_MAP:    case F_APPLY:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Calling a void expression."); +  yyerror("Calling a void expression.");    } else {    struct pike_type *f; /* Expected type. */    struct pike_type *s; /* Actual type */ -  char *name; +  struct pike_string *name = NULL; +  char *alternate_name;    INT32 max_args,args;      #ifdef NEW_ARG_CHECK       args = 0;       copy_pike_type(f, CAR(n)->type);       f = new_check_call(CAR(n), &args, f, CDR(n));   
pike.git/src/las.c:3764:    free_type(s);    break;    }       switch(CAR(n)->token)    {   #if 0 /* FIXME */    case F_TRAMPOLINE:   #endif    case F_IDENTIFIER: -  name=ID_FROM_INT(Pike_compiler->new_program, CAR(n)->u.id.number)->name->str; +  name=ID_FROM_INT(Pike_compiler->new_program, CAR(n)->u.id.number)->name;    break;       case F_ARROW:    case F_INDEX:    if(CDAR(n)->token == F_CONSTANT &&    CDAR(n)->u.sval.type == T_STRING)    { -  name=CDAR(n)->u.sval.u.string->str; +  name=CDAR(n)->u.sval.u.string;    }else{ -  name="dynamically resolved function"; +  alternate_name="dynamically resolved function";    }    break;       case F_CONSTANT:    switch(CAR(n)->u.sval.type)    {    case T_FUNCTION:    if(CAR(n)->u.sval.subtype == FUNCTION_BUILTIN)    { -  name=CAR(n)->u.sval.u.efun->name->str; +  name=CAR(n)->u.sval.u.efun->name;    }else{    name=ID_FROM_INT(CAR(n)->u.sval.u.object->prog, -  CAR(n)->u.sval.subtype)->name->str; +  CAR(n)->u.sval.subtype)->name;    }    break;       case T_ARRAY: -  name="array call"; +  alternate_name="array call";    break;       case T_PROGRAM: -  name="clone call"; +  alternate_name="clone call";    break;       default: -  name="`() (function call)"; +  alternate_name="`() (function call)";    break;    }    break;       case F_EXTERNAL:    {    int id_no = CAR(n)->u.integer.b;       if (id_no == IDREF_MAGIC_THIS) -  name = "this"; /* Should perhaps qualify it. */ +  alternate_name = "this"; /* Should perhaps qualify it. */       else {    int program_id = CAR(n)->u.integer.a;    struct program_state *state = Pike_compiler;    -  name="external symbol"; +  alternate_name="external symbol";       while (state && (state->new_program->id != program_id)) {    state = state->previous;    }       if (state) {    struct identifier *id = ID_FROM_INT(state->new_program, id_no);    if (id && id->name) {    name = id->name->str;   #if 0
pike.git/src/las.c:3850: Inside #if 0
   }   #endif   #endif    }    }    }    }    break;       default: -  name="unknown function"; +  alternate_name="unknown function";    }       if(max_args < args)    {    if(TEST_COMPAT(0,6))    {    free_type(s);    copy_pike_type(n->type, mixed_type_string);    break;    } -  my_yyerror("Too many arguments to %s.",name); +  if (name) { +  my_yyerror("Too many arguments to %S.", name); +  } else { +  my_yyerror("Too many arguments to %s.", alternate_name);    } -  +  }    else if(max_correct_args == args)    { -  my_yyerror("Too few arguments to %s.",name); -  }else{ -  my_yyerror("Bad argument %d to %s.", +  if (name) { +  my_yyerror("Too few arguments to %S.", name); +  } else { +  my_yyerror("Too few arguments to %s.", alternate_name); +  } +  } else if (name) { +  my_yyerror("Bad argument %d to %S.",    max_correct_args+1, name); -  +  } else { +  my_yyerror("Bad argument %d to %s.", +  max_correct_args+1, alternate_name);    }       yytype_error(NULL, f, s, 0);       /* print_tree(n); */       free_type(s);   #endif /* NEW_ARG_CHECK */    }    copy_pike_type(n->type, mixed_type_string);