Branch: Tag:

2000-07-10

2000-07-10 20:57:56 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Cast nodes now have the type in the CDR branch also.
Added node_is_leaf().
Improved diagnostics of resolver errors.
Improved diagnostics of calling externals.
Fixed bug in strict_types.

Rev: src/las.c:1.182

5:   \*/   /**/   #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"
72:    case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL: -  case F_CAST: -  case F_SOFT_CAST: +     return 0;       default:
81:    }   }    + 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)   {
89: Inside #if defined(PIKE_DEBUG)
   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;   
372:    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",
939:    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;   
995:       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;   
1184:    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);
1195:    } 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)
2358:    }    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";    }
2376:       yytype_error(NULL, f, s, 0);    +  /* print_tree(n); */ +     free_string(s);    }    copy_shared_string(n->type, mixed_type_string);
2486:    (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: