pike.git / src / las.c

version» Context lines:

pike.git/src/las.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: las.c,v 1.181 2000/07/07 01:48:40 hubbe Exp $"); + RCSID("$Id: las.c,v 1.182 2000/07/10 20:57:56 grubba Exp $");      #include "language.h"   #include "interpret.h"   #include "las.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "lex.h"   #include "pike_types.h"
pike.git/src/las.c:65:      int cdr_is_node(node *n)   {    switch(n->token)    {    case F_EXTERNAL:    case F_IDENTIFIER:    case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL: -  case F_CAST: -  case F_SOFT_CAST: +     return 0;       default:    return !!_CDR(n);    }   }    -  + int node_is_leaf(node *n) + { +  switch(n->token) +  { +  case F_EXTERNAL: +  case F_IDENTIFIER: +  case F_TRAMPOLINE: +  case F_CONSTANT: +  case F_LOCAL: +  return 1; +  } +  return 0; + } +    #ifdef PIKE_DEBUG   void check_tree(node *n, int depth)   {    if(!d_flag) return;    if(!n) return;    if(n->token==USHRT_MAX)    fatal("Free node in tree.\n");    - #ifdef SHARED_NODES +     check_node_hash(n); - #endif /* SHARED_NODES */ +        if(d_flag<2) return;       if(!(depth & 1023))    {    node *q;    for(q=n->parent;q;q=q->parent)    if(q->parent==n)    fatal("Cyclic node structure found.\n");    }
pike.git/src/las.c:365:    {    for(e=0;e<NODES;e++)    {    for(tmp=free_node_ss;tmp;tmp=_CAR(tmp))    if(tmp==tmp2->x+e)    break;       if(!tmp)    {    tmp=tmp2->x+e; - #if defined(PIKE_DEBUG) + #ifdef PIKE_DEBUG    if(!cumulative_parse_error)    {    fprintf(stderr,"Free node at %p, (%s:%d) (token=%d).\n",    tmp, tmp->current_file->str, tmp->line_number,    tmp->token);       debug_malloc_dump_references(tmp,0,2,0);       if(tmp->token==F_CONSTANT)    print_tree(tmp);
pike.git/src/las.c:932:    res->token = F_CAST;    copy_shared_string(res->type,type);       if(match_types(object_type_string, type) ||    match_types(object_type_string, type))    res->node_info |= OPT_SIDE_EFFECT;       res->tree_info |= n->tree_info;       _CAR(res) = n; - #ifdef SHARED_NODES -  _CDR(res) = (node *)type; - #else /* !SHARED_NODES */ - #ifdef __CHECKER__ -  _CDR(res) = 0; - #endif - #endif /* SHARED_NODES */ +  _CDR(res) = mktypenode(type);       n->parent = res;       return freeze_node(res);   }      node *debug_mksoftcastnode(struct pike_string *type,node *n)   {    node *res;   
pike.git/src/las.c:988:    }    /* FIXME: check_soft_cast() is weaker than pike_types_le()    * The resulting type should probably be the and between the old    * and the new type.    */    }    }       res = mkemptynode();    res->token = F_SOFT_CAST; -  copy_shared_string(res->type,type); +  copy_shared_string(res->type, type);       res->tree_info |= n->tree_info;       _CAR(res) = n; - #ifdef SHARED_NODES -  _CDR(res) = (node *)type; - #else /* !SHARED_NODES */ - #ifdef __CHECKER__ -  _CDR(res) = 0; - #endif - #endif /* SHARED_NODES */ +  _CDR(res) = mktypenode(type);       n->parent = res;       return freeze_node(res);   }      void resolv_constant(node *n)   {    struct identifier *i;    struct program *p;
pike.git/src/las.c:1177:   node *index_node(node *n, char *node_name, struct pike_string *id)   {    node *ret;    JMP_BUF tmp;       check_tree(n,0);       if(SETJMP(tmp))    {    ONERROR tmp; +  struct svalue s; +     SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!"); -  assign_svalue_no_free(Pike_sp++, & throw_value); +  assign_svalue_no_free(Pike_sp++, &throw_value); +  assign_svalue_no_free(&s, &throw_value);    APPLY_MASTER("handle_error", 1);    pop_stack();    UNSET_ONERROR(tmp);       if (node_name) {    my_yyerror("Couldn't index module '%s'.", node_name);    } else {    yyerror("Couldn't index module.");    } -  push_int(0); +  if ((s.type == T_ARRAY) && s.u.array->size && +  (s.u.array->item[0].type == T_STRING)) { +  /* Old-style backtrace */ +  my_yyerror("Error: '%s'.", s.u.array->item[0].u.string->str); +  } else if (s.type == T_OBJECT) { +  struct generic_error_struct *ge; +  if ((ge = (struct generic_error_struct *) +  get_storage(s.u.object, generic_error_program))) { +  my_yyerror("Error: '%s'.", ge->desc->str); +  } +  } +  free_svalue(&s);    }else{    resolv_constant(n);    switch(Pike_sp[-1].type)    {    case T_INT:    if(!Pike_compiler->num_parse_error) {    if (node_name) {    my_yyerror("Failed to index module '%s' with '%s' "    "(module doesn't exist?)",    node_name, id->str);
pike.git/src/las.c:2351:    case T_PROGRAM:    name="clone call";    break;       default:    name="`() (function call)";    break;    }    break;    +  case F_EXTERNAL: +  { +  int level = CAR(n)->u.integer.a; +  int id_no = CAR(n)->u.integer.b; +  struct program *p = parent_compilation(level); +  name="external symbol"; +  if (p) { +  struct identifier *id = ID_FROM_INT(p, id_no); +  if (id && id->name) { +  name = id->name->str; +  } +  } +  } +  break; +     default:    name="unknown function";    }       if(max_args < args)    {    my_yyerror("Too many arguments to %s.",name);    }    else if(max_correct_args == args)    {    my_yyerror("Too few arguments to %s.",name);    }else{    my_yyerror("Bad argument %d to %s.",    max_correct_args+1, name);    }       yytype_error(NULL, f, s, 0);    -  +  /* print_tree(n); */ +     free_string(s);    }    copy_shared_string(n->type, mixed_type_string);    break;       case '?':    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yyerror("Conditional expression is void.");    } else if(!match_types(CAR(n)->type,mixed_type_string))    yyerror("Bad conditional expression.");
pike.git/src/las.c:2479:    if (!match_types(CAR(n)->type, CDR(n)->type)) {    if (!match_types(CAR(n)->type, int_type_string) ||    !match_types(CDR(n)->type, int_type_string)) {    yytype_error("Type mismatch in case range.",    CAR(n)->type, CDR(n)->type, 0);    }    } else if ((lex.pragmas & ID_STRICT_TYPES) &&    (CAR(n)->type != CDR(n)->type)) {    /* The type should be the same for both CAR & CDR. */    if (!pike_types_le(CDR(n)->type, CAR(n)->type)) { +  /* Note that zero should be handled as int(0..0) here. */ +  if (!(CAR(n)->type == zero_type_string) || +  !(pike_types_le(CDR(n)->type, int_type_string))) {    yytype_error("Type mismatch in case range.",    CAR(n)->type, CDR(n)->type, YYTE_IS_WARNING); -  +  }    } else if (!pike_types_le(CAR(n)->type, CDR(n)->type)) { -  +  if (!(CDR(n)->type == zero_type_string) || +  !(pike_types_le(CAR(n)->type, int_type_string))) {    yytype_error("Type mismatch in case range.",    CDR(n)->type, CAR(n)->type, YYTE_IS_WARNING);    }    }    } -  +  }    /* FALL_THROUGH */    case F_INC_LOOP:    case F_DEC_LOOP:    case F_DEC_NEQ_LOOP:    case F_INC_NEQ_LOOP:    case F_CONTINUE:    case F_BREAK:    case F_DEFAULT:    case F_POP_VALUE:    copy_shared_string(n->type,void_type_string);