pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: las.c,v 1.185 2000/07/12 01:20:21 hubbe Exp $"); + RCSID("$Id: las.c,v 1.186 2000/07/12 12:38:40 grubba Exp $");      #include "language.h"   #include "interpret.h"   #include "las.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "lex.h"   #include "pike_types.h"
pike.git/src/las.c:101: Inside #if defined(PIKE_DEBUG)
   if(n->token==USHRT_MAX)    fatal("Free node in tree.\n");       check_node_hash(n);       switch(n->token)    {    case F_EXTERNAL:    if(n->type)    { -  int level = n->u.integer.a; +  int parent_id = n->u.integer.a;    int id_no = n->u.integer.b; -  struct program *p = parent_compilation(level); -  if (p) { -  struct identifier *id = ID_FROM_INT(p, id_no); +  struct program_state *state = Pike_compiler->previous; +  while (state && (state->new_program->id != parent_id)) { +  state = state->previous; +  } +  if (state) { +  struct identifier *id = ID_FROM_INT(state->new_program, id_no);    if (id) {   #ifdef PIKE_DEBUG    if(id->type != n->type)    {    printf("Type of external node is not matching it's identifier.\nid->type: ");    simple_describe_type(id->type);    printf("\nn->type : ");    simple_describe_type(n->type);    printf("\n");   
pike.git/src/las.c:376: Inside #if defined(SHARED_NODES)
  }      #else /* !SHARED_NODES */      #ifdef PIKE_DEBUG   static node *freeze_node(node *orig)   {    check_tree(orig);    return orig;   } - #endif -  + #else /* !PIKE_DEBUG */   #define freeze_node(X) (X) -  + #endif /* PIKE_DEBUG */ +    #endif /* SHARED_NODES */      void free_all_nodes(void)   {    if(!Pike_compiler->compiler_frame)    {    node *tmp;    struct node_s_block *tmp2;    int e=0;   
pike.git/src/las.c:919: Inside #if defined(SHARED_NODES)
  #ifdef SHARED_NODES    res->u.id.prog = Pike_compiler->new_program;   #endif /* SHARED_NODES */       res = freeze_node(res);       check_tree(res,0);    return res;   }    - node *debug_mkexternalnode(int level, -  int i, -  struct identifier *id) + node *debug_mkexternalnode(struct program *parent_prog, int i)   {    node *res = mkemptynode(); -  +  struct identifier *id;    res->token = F_EXTERNAL;   #ifdef PIKE_DEBUG    if(d_flag)    {    check_string(id->type);    check_string(id->name);    }   #endif    -  /* Kludge */ -  id = ID_FROM_INT(parent_compilation(level), i); +  id = ID_FROM_INT(parent_prog, i);       copy_shared_string(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;    }    res->tree_info = res->node_info;      #ifdef __CHECKER__    _CDR(res) = 0;   #endif -  res->u.integer.a = level; +  res->u.integer.a = parent_prog->id;    res->u.integer.b = i;       /* Bzot-i-zot */    Pike_compiler->new_program->flags |= PROGRAM_USES_PARENT;    -  /* Can't freeze the node, since the type-info may become wrong. */ -  /* return freeze_node(res); */ -  res->hash = hash_node(res); -  return res; +  return freeze_node(res);   }      node *debug_mkcastnode(struct pike_string *type,node *n)   {    node *res;       if(!n) return 0;      #ifdef PIKE_DEBUG    if (!type) {
pike.git/src/las.c:1070:    {    push_int(0);    }else{    switch(n->token)    {    case F_CONSTANT:    push_svalue(& n->u.sval);    return;       case F_EXTERNAL: -  p=parent_compilation(n->u.integer.a); -  if(!p) +     { -  +  struct program_state *state = Pike_compiler->previous; +  +  while (state && (state->new_program->id != n->u.integer.a)) { +  state = state->previous; +  } +  if(!state) +  {    yyerror("Failed to resolv external constant");    push_int(0);    return;    } -  +  p = state->new_program;    numid=n->u.integer.b; -  +  }    break;       case F_IDENTIFIER:    p=Pike_compiler->new_program;    numid=n->u.id.number;    break;       case F_LOCAL:    /* FIXME: Ought to have the name of the identifier in the message. */    yyerror("Expected constant, got local variable");
pike.git/src/las.c:1448:       case T_FUNCTION:    {    if(s->subtype != FUNCTION_BUILTIN)    {    if(s->u.object == Pike_compiler->fake_object)    return mkidentifiernode(s->subtype);       if(s->u.object->next == s->u.object)    { -  int x=0; -  struct object *o; -  for(o=Pike_compiler->fake_object->parent;o!=s->u.object;o=o->parent) x++; -  return mkexternalnode(x, s->subtype, -  ID_FROM_INT(o->prog, s->subtype)); -  +  return mkexternalnode(s->u.object->prog, s->subtype);    }      /* yyerror("Non-constant function pointer! (should not happen!)"); */    }    }    }       return mkconstantsvaluenode(s);   }   
pike.git/src/las.c:2412:    break;       default:    name="`() (function call)";    break;    }    break;       case F_EXTERNAL:    { -  int level = CAR(n)->u.integer.a; +  int program_id = CAR(n)->u.integer.a;    int id_no = CAR(n)->u.integer.b; -  struct program *p = parent_compilation(level); +  struct program_state *state = Pike_compiler->previous; +     name="external symbol"; -  if (p) { -  struct identifier *id = ID_FROM_INT(p, id_no); +  +  while (state && (state->new_program->id != program_id)) { +  state = state->previous; +  } +  +  if (state) { +  struct identifier *id = ID_FROM_INT(state->new_program, id_no);    if (id && id->name) {    name = id->name->str;   #ifdef PIKE_DEBUG    if(id->type != f)    {    printf("Type of external node is not matching it's identifier.\nid->type: ");    simple_describe_type(id->type);    printf("\nf : ");    simple_describe_type(f);    printf("\n");