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.378 2006/08/21 18:48:25 grubba Exp $ + || $Id: las.c,v 1.379 2006/10/28 18:17:56 grubba 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:45:      #define MAX_GLOBAL 2048      /* #define yywarning my_yyerror */      int car_is_node(node *n)   {    switch(n->token)    {    case F_EXTERNAL: +  case F_GET_SET:    case F_IDENTIFIER:    case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL:    case F_THIS:    case F_VERSION:    return 0;       default:    return !!_CAR(n);    }   }      int cdr_is_node(node *n)   {    switch(n->token)    {    case F_EXTERNAL: -  +  case F_GET_SET:    case F_IDENTIFIER:    case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL:    case F_THIS:    case F_VERSION:    return 0;       default:    return !!_CDR(n);    }   }      int node_is_leaf(node *n)   {    switch(n->token)    {    case F_EXTERNAL: -  +  case F_GET_SET:    case F_IDENTIFIER:    case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL:    case F_VERSION:    return 1;    }    return 0;   }   
pike.git/src/las.c:113: Inside #if defined(PIKE_DEBUG)
      while(n) {    if(n->token==USHRT_MAX)    Pike_fatal("Free node in tree.\n");       check_node_hash(n);       switch(n->token)    {    case F_EXTERNAL: +  case F_GET_SET:    if(n->type)    {    int parent_id = n->u.integer.a;    int id_no = n->u.integer.b;    struct program_state *state = Pike_compiler;    while (state && (state->new_program->id != parent_id)) {    state = state->previous;    }    if (state && id_no != IDREF_MAGIC_THIS) {    struct identifier *id = ID_FROM_INT(state->new_program, id_no);
pike.git/src/las.c:554: Inside #if defined(SHARED_NODES)
   * We might get better performance by using the one we already have.    */    sub_node(orig);    }    /* Propagate the line-number information. */    n->line_number = orig->line_number;    if (orig->current_file) {    if (n->current_file) {    free_string(n->current_file);    } -  n->current_file = orig->current_file; +  n->current_file = dmalloc_touch(struct pike_string *, +  orig->current_file);    orig->current_file = NULL;    }    free_node(dmalloc_touch(node *, orig));    add_ref(n);    return check_node_hash(dmalloc_touch(node *, n));    }    n = n->next;    }    orig->node_info &= ~OPT_DEFROSTED;    if (!found) {
pike.git/src/las.c:953: Inside #if defined(PIKE_DEBUG)
   case F_CONSTANT:    Pike_fatal("Attempt to create an F_CONSTANT-node with mknode()!\n");    case F_LOCAL:    Pike_fatal("Attempt to create an F_LOCAL-node with mknode()!\n");    case F_IDENTIFIER:    Pike_fatal("Attempt to create an F_IDENTIFIER-node with mknode()!\n");    case F_TRAMPOLINE:    Pike_fatal("Attempt to create an F_TRAMPOLINE-node with mknode()!\n");    case F_EXTERNAL:    Pike_fatal("Attempt to create an F_EXTERNAL-node with mknode()!\n"); +  case F_GET_SET: +  Pike_fatal("Attempt to create an F_GET_SET-node with mknode()!\n");   #endif /* PIKE_DEBUG */    }      #if defined(PIKE_DEBUG) && !defined(SHARED_NODES)    if(b && a==b)    Pike_fatal("mknode: a and be are the same!\n");   #endif       check_tree(a,0);    check_tree(b,0);
pike.git/src/las.c:1021:    if(a->u.sval.u.program->flags & PROGRAM_CONSTANT) {    opt_flags=0;    }    if (a->u.sval.u.program->flags & PROGRAM_USES_PARENT) {    yyerror("Can not clone program without parent context.");    }    break;    }    break;    case F_EXTERNAL: +  case F_GET_SET:    if (a->u.integer.b != IDREF_MAGIC_THIS) {    struct program_state *state = Pike_compiler;    int program_id = a->u.integer.a;    while (state && (state->new_program->id != program_id)) {    state = state->previous;    }    if (state) {    i = ID_FROM_INT(state->new_program, a->u.integer.b);    } else {    yyerror("Parent has left.");
pike.git/src/las.c:1479:   #endif       copy_pike_type(res->type, id->type);       /* FIXME */    if(IDENTIFIER_IS_CONSTANT(id->identifier_flags))    {    res->node_info = OPT_EXTERNAL_DEPEND;    }else{    res->node_info = OPT_NOT_CONST; +  if (IDENTIFIER_IS_VARIABLE(id->identifier_flags) && +  (id->run_time_type == PIKE_T_GET_SET)) { +  /* Special case of F_EXTERNAL for ease of detection. */ +  res->token = F_GET_SET;    }    } -  +  }    res->tree_info = res->node_info;      #ifdef __CHECKER__    _CDR(res) = 0;   #endif    res->u.integer.a = parent_prog->id;    res->u.integer.b = i;       /* Bzot-i-zot */    state = Pike_compiler;
pike.git/src/las.c:1670:    {    push_int(0);    }else{    switch(n->token)    {    case F_CONSTANT:    push_svalue(& n->u.sval);    return;       case F_EXTERNAL: +  case F_GET_SET:    if (n->u.integer.b == IDREF_MAGIC_THIS) {    yyerror ("Expected constant, got reference to this");    push_int (0);    return;    }       else {    struct program_state *state = Pike_compiler;    while (state && (state->new_program->id != n->u.integer.a)) {    state = state->previous;
pike.git/src/las.c:2009:    {    case F_TRAMPOLINE: /* FIXME, the context has to be the same! */   #ifdef SHARED_NODES    if(a->u.trampoline.prog != b->u.trampoline.prog)    return 0;   #endif    return a->u.trampoline.ident == b->u.trampoline.ident &&    a->u.trampoline.frame == b->u.trampoline.frame;       case F_EXTERNAL: +  case F_GET_SET:    case F_LOCAL:    return a->u.integer.a == b->u.integer.a &&    a->u.integer.b == b->u.integer.b;       case F_IDENTIFIER:    return a->u.id.number == b->u.id.number;       case F_CAST:    case F_SOFT_CAST:    return a->type == b->type && node_is_eq(CAR(a), CAR(b));
pike.git/src/las.c:2517:    case F_IDENTIFIER:    if(needlval) fputc('&', stderr);    if (Pike_compiler->new_program) {    fprintf(stderr, "id(%s)",ID_FROM_INT(Pike_compiler->new_program, foo->u.id.number)->name->str);    } else {    fputs("unknown identifier", stderr);    }    break;       case F_EXTERNAL: +  case F_GET_SET:    if(needlval) fputc('&', stderr);    {    struct program_state *state = Pike_compiler;    char *name = "?";    int program_id = foo->u.integer.a;    int level = 0;    int id_no = foo->u.integer.b;    while(state && (state->new_program->id != program_id)) {    state = state->previous;    level++;
pike.git/src/las.c:2917: Inside #if defined(PIKE_DEBUG)
   q = find_q(&(p->locals), n->u.integer.a, n->u.integer.b);   #ifdef PIKE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "local %d:%d is ",    n->u.integer.b, n->u.integer.a);    }   #endif /* PIKE_DEBUG */    goto set_pointer;       case F_EXTERNAL: +  case F_GET_SET:    q = find_q(&(p->externals), n->u.integer.b, n->u.integer.a);   #ifdef PIKE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "external %d:%d is ",    n->u.integer.a, n->u.integer.b);    }   #endif /* PIKE_DEBUG */    goto set_pointer;       case F_IDENTIFIER:
pike.git/src/las.c:3056: Inside #if defined(PIKE_DEBUG)
   if (l_flag > 2) {    fprintf(stderr, "local %d:%d is written\n",    n->u.integer.b, n->u.integer.a);    }   #endif /* PIKE_DEBUG */    *find_q(&(p->locals), n->u.integer.a, n->u.integer.b) = VAR_USED;    }    break;       case F_EXTERNAL: +  case F_GET_SET:    if(lvalue) {   #ifdef PIKE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "external %d:%d is written\n",    n->u.integer.a, n->u.integer.b);    }   #endif /* PIKE_DEBUG */    *find_q(&(p->externals), n->u.integer.b, n->u.integer.a) = VAR_USED;    }    break;
pike.git/src/las.c:3807:    alternate_name="clone call";    break;       default:    alternate_name="`() (function call)";    break;    }    break;       case F_EXTERNAL: +  case F_GET_SET:    {    int id_no = CAR(n)->u.integer.b;       if (id_no == IDREF_MAGIC_THIS)    alternate_name = "this"; /* Should perhaps qualify it. */       else {    int program_id = CAR(n)->u.integer.a;    struct program_state *state = Pike_compiler;   
pike.git/src/las.c:5107: Inside #if defined(SHARED_NODES)
  #endif /* PIKE_DEBUG */       free_node(n);    return n2;   }   #endif /* SHARED_NODES */      static void optimize(node *n)   {    node *tmp1, *tmp2, *tmp3; -  struct pike_string *save_file = lex.current_file; +  struct pike_string *save_file = +  dmalloc_touch(struct pike_string *, lex.current_file);    INT32 save_line = lex.current_line;       do    {    if(car_is_node(n) &&    ((CAR(n)->node_info & (OPT_OPTIMIZED|OPT_DEFROSTED)) != OPT_OPTIMIZED))    {    CAR(n)->parent = n;    n = CAR(n);    continue;
pike.git/src/las.c:5151: Inside #if defined(SHARED_NODES)
   n->node_info &= ~OPT_DEFROSTED;    if (n->node_info & OPT_OPTIMIZED) {    /* No need to check this node any more. */    n = n->parent;    continue;    }    }   #endif /* SHARED_NODES */       lex.current_line = n->line_number; -  lex.current_file = n->current_file; +  lex.current_file = dmalloc_touch(struct pike_string *, n->current_file);      #ifdef SHARED_NODES    if (n->tree_info & OPT_NOT_SHARED) {    n->tree_info = n->node_info;    if(car_is_node(n)) n->tree_info |= CAR(n)->tree_info;    if(cdr_is_node(n)) n->tree_info |= CDR(n)->tree_info;    if(!(n->tree_info & OPT_NOT_SHARED)) {    /* We need to fix the hash for this node. */    n->hash = hash_node(n);    /* FIXME: Should probably add the node to the hashtable here. */
pike.git/src/las.c:5317:    }   #endif    continue;       }    n->node_info |= OPT_OPTIMIZED;    n=n->parent;    }while(n);       lex.current_line = save_line; -  lex.current_file = save_file; +  lex.current_file = dmalloc_touch(struct pike_string *, save_file);   }      void optimize_node(node *n)   {    if(n &&    !Pike_compiler->num_parse_error &&    Pike_compiler->compiler_pass==2 &&    (n->node_info & OPT_TRY_OPTIMIZE))    {    optimize(n);