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.430 2008/07/16 01:17:50 mast Exp $ + || $Id: las.c,v 1.431 2008/07/18 13:02:29 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:940:   node *debug_mkstrnode(struct pike_string *str)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    res->u.sval.type = T_STRING;   #ifdef __CHECKER__    res->u.sval.subtype = 0;   #endif    copy_shared_string(res->u.sval.u.string, str);    res->type = get_type_of_svalue(&res->u.sval); +  res->tree_info = OPT_SAFE;    return res;   }      node *debug_mkintnode(INT_TYPE nr)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    res->u.sval.type = T_INT;    res->u.sval.subtype = NUMBER_NUMBER;    res->u.sval.u.integer = nr;    res->type=get_type_of_svalue( & res->u.sval); -  +  res->tree_info = OPT_SAFE;       return res;   }      node *debug_mknewintnode(INT_TYPE nr)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    res->u.sval.type = T_INT;    res->u.sval.subtype = NUMBER_NUMBER;    res->u.sval.u.integer = nr;    res->type=get_type_of_svalue( & res->u.sval); -  +  res->tree_info = OPT_SAFE;    return res;   }      node *debug_mkfloatnode(FLOAT_TYPE foo)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    copy_pike_type(res->type, float_type_string);    res->u.sval.type = T_FLOAT;   #ifdef __CHECKER__    res->u.sval.subtype = 0;   #endif    res->u.sval.u.float_number = foo; -  +  res->tree_info = OPT_SAFE;       return res;   }         node *debug_mkprgnode(struct program *p)   {    struct svalue s;    s.u.program=p;    s.type = T_PROGRAM;
pike.git/src/las.c:1789:    node *res = mkemptynode();    res->token = F_CONSTANT;    assign_svalue_no_free(& res->u.sval, s);    if(s->type == T_OBJECT ||    (s->type==T_FUNCTION && s->subtype!=FUNCTION_BUILTIN))    {    if(!(s->u.object->prog && (s->u.object->prog->flags & PROGRAM_CONSTANT)))    res->node_info|=OPT_EXTERNAL_DEPEND;    }    res->type = get_type_of_svalue(s); +  res->tree_info |= OPT_SAFE;    return res;   }      node *debug_mkconstantsvaluenode(const struct svalue *s)   {    return low_mkconstantsvaluenode(s);   }      node *debug_mkliteralsvaluenode(const struct svalue *s)   {
pike.git/src/las.c:1939:    OPT_ASSIGNMENT |    OPT_CASE |    OPT_CONTINUE |    OPT_BREAK |    OPT_RETURN    ));   }      int node_is_tossable(node *n)   { -  return !(n->tree_info & (OPT_SIDE_EFFECT | +  if (!(n->tree_info & (OPT_SIDE_EFFECT |    OPT_ASSIGNMENT |    OPT_CASE |    OPT_CONTINUE |    OPT_BREAK |    OPT_RETURN -  )); +  ))) { +  ptrdiff_t args; +  if (n->tree_info & (OPT_NOT_CONST|OPT_SAFE)) +  return 1; +  args = eval_low (n, 0); +  if (args == -1) { +  n->tree_info |= OPT_SIDE_EFFECT; /* A constant that throws. */ +  return 0;    } -  +  else { +  pop_n_elems (args); +  n->tree_info |= OPT_SAFE; +  return 1; +  } +  } +  return 0; + }      /* this one supposes that the value is optimized */   int node_is_true(node *n)   {    if(!n) return 0;    switch(n->token)    {    case F_CONSTANT: return !SAFE_IS_ZERO(& n->u.sval);    default: return 0;    }
pike.git/src/las.c:5211: Inside #if defined(PIKE_USE_MACHINE_CODE)
   (prog->num_program - num_program) *    sizeof (prog->program[0]));   #endif       tmp_callback=add_to_callback(&evaluator_callbacks,    check_evaluation_time,    (void *)&foo,0);       if(apply_low_safe_and_stupid(Pike_compiler->fake_object, jump))    { +  /* Assume the node will throw errors at runtime too. */ +  n->tree_info |= OPT_SIDE_EFFECT; +  n->node_info |= OPT_SIDE_EFFECT;    if(print_error)    /* Generate error message */    if(!Pike_compiler->catch_level)    handle_compile_exception("Error evaluating constant.");    else {    free_svalue(&throw_value);    mark_free_svalue (&throw_value);    }    else {    free_svalue(&throw_value);    mark_free_svalue (&throw_value); -  /* Assume the node will throw errors at runtime too. */ -  n->tree_info |= OPT_SIDE_EFFECT; -  n->node_info |= OPT_SIDE_EFFECT; +     }    }else{    if(foo.yes)    pop_n_elems(Pike_sp-save_sp);    else    ret=Pike_sp-save_sp; -  +  n->tree_info |= OPT_SAFE;    }       remove_callback(tmp_callback);    }       while(prog->num_strings > num_strings)    {    prog->num_strings--;    free_string(prog->strings[prog->num_strings]);    }