Branch: Tag:

1997-01-30

1997-01-30 03:51:37 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

many optimizations added (see Changelog)

Rev: src/builtin_functions.c:1.25
Rev: src/docode.c:1.10
Rev: src/interpret.c:1.23
Rev: src/language.yacc:1.21
Rev: src/las.c:1.16
Rev: src/lex.c:1.14
Rev: src/lex.h:1.3
Rev: src/peep.c:1.5
Rev: src/peep.in:1.3
Rev: src/pike_types.c:1.15
Rev: src/port.h:1.11

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: las.c,v 1.15 1997/01/28 03:04:31 hubbe Exp $"); + RCSID("$Id: las.c,v 1.16 1997/01/30 03:51:34 hubbe Exp $");      #include "language.h"   #include "interpret.h"
39:   int cumulative_parse_error=0;   extern char *get_type_name(int);    - #define MAX_GLOBAL 256 + #define MAX_GLOBAL 2048      int car_is_node(node *n)   {
537:    node *res = mkemptynode();    res->token = F_CONSTANT;    assign_svalue_no_free(& res->u.sval, s); -  if(s->type == T_OBJECT || s->type==T_FUNCTION) +  if(s->type == T_OBJECT || (s->type==T_FUNCTION && s->subtype!=FUNCTION_BUILTIN)) +  {    res->node_info|=OPT_EXTERNAL_DEPEND; -  +  }    res->type = get_type_of_svalue(s);    return res;   }
860:   /* The following routines needs much better commenting */   struct used_vars   { +  int err;    char locals[MAX_LOCAL];    char globals[MAX_GLOBAL];   };
873:    int e;    for(e=0;e<MAX_LOCAL;e++) a->locals[e]|=b->locals[e];    for(e=0;e<MAX_GLOBAL;e++) a->globals[e]|=b->globals[e]; +  a->err|=b->err;    free((char *)b);   }   
901:       case F_IDENTIFIER:    q=p->globals+n->u.number; +  if(n->u.number > MAX_GLOBAL) +  { +  p->err=1; +  return 0; +  }       set_pointer:    if(overwrite)
909:    }    else    { -  if(*q != VAR_UNUSED) *q = VAR_USED; +  if(*q == VAR_UNUSED) *q = VAR_USED;    }    break;   
973:    break;       case F_GLOBAL: -  if(lvalue) p->globals[n->u.number]=VAR_USED; +  if(lvalue) +  { +  if(n->u.number>=MAX_GLOBAL) +  { +  p->err=1; +  return; +  } +  p->globals[n->u.number]=VAR_USED; +  }    break;    -  +  case F_APPLY: +  if(n->tree_info & OPT_SIDE_EFFECT) +  MEMSET(p->globals, MAX_GLOBAL, VAR_USED); +  break; +     case F_INDEX:    case F_ARROW:    find_written_vars(CAR(n), p, lvalue);
1028:    find_used_variables(a,&aa,0,0);    find_written_vars(b,&bb,0);    +  if(aa.err || bb.err) return 1; +     for(e=0;e<MAX_LOCAL;e++)    if(aa.locals[e]==VAR_USED && bb.locals[e]!=VAR_UNUSED)    return 1;
1041:   static int depend_p(node *a,node *b)   {    if(!b) return 0; + #if 0    if(!(b->tree_info & OPT_SIDE_EFFECT) &&    (b->tree_info & OPT_EXTERNAL_DEPEND))    return 1; -  + #endif    -  +  if((a->tree_info & OPT_EXTERNAL_DEPEND)) return 1; +     return depend_p2(a,b);   }