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.350 2004/10/16 07:27:29 agehall Exp $ + || $Id: las.c,v 1.351 2004/10/30 11:38:26 mast 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:281:    return -1;       case F_APPLY:    if(CAR(n)->token == F_CONSTANT &&    CAR(n)->u.sval.type == T_FUNCTION &&    CAR(n)->u.sval.subtype == FUNCTION_BUILTIN &&    n->type == void_type_string)    return 0;    return 1;    +  case F_RANGE_FROM_BEG: +  case F_RANGE_FROM_END: +  return 1; +  case F_RANGE_OPEN: +  return 0; +     default:    if(n->type == void_type_string) return 0;    return 1;    }   }      /* FIXME: Ought to use parent pointer to avoid recursion. */   struct pike_type *find_return_type(node *n)   {    struct pike_type *a, *b;
pike.git/src/las.c:1111:    case F_INC:    case F_DEC:    case F_POST_INC:    case F_POST_DEC:    res->node_info |= OPT_ASSIGNMENT;    if (a) {    res->tree_info |= a->tree_info;    }    break;    +  case ':': +  case F_RANGE_FROM_BEG: +  case F_RANGE_FROM_END: +  case F_RANGE_OPEN: +  res->node_info |= OPT_FLAG_NODE; +  break; +     default:    if(a) res->tree_info |= a->tree_info;    if(b) res->tree_info |= b->tree_info;    }       /* We try to optimize most things, but argument lists are hard... */    if((token != F_ARG_LIST) && (a || b))    res->node_info |= OPT_TRY_OPTIMIZE;       res->tree_info |= res->node_info;
pike.git/src/las.c:3354:    int ret;       /* Make a temporary node (lval = 0), so that we can use depend_p(). */    ADD_NODE_REF2(lval,    tmp = mknode(F_ASSIGN, mkintnode(0), lval));    ret = depend_p(n, tmp);    free_node(tmp);    return ret;   }    + #if 0 + /* Not used anywhere. */   /* FIXME: Ought to use parent pointer to avoid recursion. */   static int cntargs(node *n)   {    if(!n) return 0;    switch(n->token)    {    case F_CAST:    case F_SOFT_CAST:    case F_APPLY:    return n->type != void_type_string;
pike.git/src/las.c:3386:    case F_ARG_LIST:       fatal_check_c_stack(16384);       return cntargs(CAR(n))+cntargs(CDR(n));       /* this might not be true, but it doesn't matter very much */    default: return 1;    }   } + #endif      static int function_type_max=0;      /* FIXME: Ought to use parent pointer to avoid recursion. */   static void low_build_function_type(node *n)   {    if(!n) return;    if(function_type_max++ > 999)    {    reset_type_stack();
pike.git/src/las.c:3636:    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.");    n->type=index_type(type_a, type_b,n);    }    break; -  case F_RANGE: -  { -  node **nptr = my_get_arg(&_CDR(n), 0); +     -  +  case F_RANGE:    if (!CAR(n)) { -  /* Unlikely to occurr, and if it does, it has probably +  /* Unlikely to occur, and if it does, it has probably    * already been complained about.    */    copy_pike_type(n->type, mixed_type_string); -  break; +     } -  -  if (nptr) { -  node *arg1 = *nptr; -  -  if ((nptr = my_get_arg(&_CDR(n), 1))) { -  node *arg2 = *nptr; -  -  n->type = range_type(CAR(n)->type, arg1->type, arg2->type); -  break; +  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);    } -  } -  /* Fewer than 2 arguments to F_RANGE. */ -  Pike_fatal("Bad number of arguments to F_RANGE.\n"); -  } +     break; -  +     case F_AUTO_MAP_MARKER:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    my_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.");
pike.git/src/las.c:5201: Inside #if defined(SHARED_NODES)
   }    }   #endif /* SHARED_NODES */       if(!n->parent) break;       if(n->tree_info & (OPT_NOT_CONST|    OPT_SIDE_EFFECT|    OPT_EXTERNAL_DEPEND|    OPT_ASSIGNMENT| -  OPT_RETURN)) +  OPT_RETURN| +  OPT_FLAG_NODE))    {    if(car_is_node(n) &&    !(CAR(n)->tree_info & (OPT_NOT_CONST|    OPT_SIDE_EFFECT|    OPT_EXTERNAL_DEPEND|    OPT_ASSIGNMENT| -  OPT_RETURN)) && +  OPT_RETURN| +  OPT_FLAG_NODE)) &&    (CAR(n)->tree_info & OPT_TRY_OPTIMIZE) && -  CAR(n)->token != ':' && +     CAR(n)->token != F_VAL_LVAL)    {   #ifdef SHARED_NODES    sub_node(n);   #endif /* SHARED_NODES */    _CAR(n) = eval(CAR(n));   #ifdef SHARED_NODES    n->node_info |= OPT_DEFROSTED;    if (!(n->tree_info & OPT_NOT_SHARED)) {    n->hash = hash_node(n);
pike.git/src/las.c:5233:   #endif /* SHARED_NODES */    if(CAR(n)) CAR(n)->parent = n;    zapp_try_optimize(CAR(n)); /* avoid infinite loops */    continue;    }    if(cdr_is_node(n) &&    !(CDR(n)->tree_info & (OPT_NOT_CONST|    OPT_SIDE_EFFECT|    OPT_EXTERNAL_DEPEND|    OPT_ASSIGNMENT| -  OPT_RETURN)) && -  (CDR(n)->tree_info & OPT_TRY_OPTIMIZE) && -  CDR(n)->token != ':') +  OPT_RETURN| +  OPT_FLAG_NODE)) && +  (CDR(n)->tree_info & OPT_TRY_OPTIMIZE))    {   #ifdef SHARED_NODES    sub_node(n);   #endif /* SHARED_NODES */    _CDR(n) = eval(CDR(n));   #ifdef SHARED_NODES    n->node_info |= OPT_DEFROSTED;    if (!(n->tree_info & OPT_NOT_SHARED)) {    n->hash = hash_node(n);    add_node(n);
pike.git/src/las.c:5484:       prog->num_program=num_program;       return ret;   }      static node *eval(node *n)   {    node *new;    ptrdiff_t args; -  if(!is_const(n) || n->token==':') +  +  if(!is_const(n) || n->node_info & OPT_FLAG_NODE)    return n;       args=eval_low(n,0);       switch(args)    {    case -1:    return n;    break;