Branch: Tag:

2000-07-10

2000-07-10 18:21:33 by Henrik Grubbström (Grubba) <grubba@grubba.org>

last_identifier is now part of the program_state.
Changed a few INT32 to size_t.

Rev: src/compilation.h:1.18
Rev: src/language.yacc:1.200
Rev: src/program.c:1.248
Rev: src/program.h:1.94

109:   /* This is the grammar definition of Pike. */      #include "global.h" - RCSID("$Id: language.yacc,v 1.199 2000/07/10 15:36:35 grubba Exp $"); + RCSID("$Id: language.yacc,v 1.200 2000/07/10 18:21:33 grubba Exp $");   #ifdef HAVE_MEMORY_H   #include <memory.h>   #endif
145:    struct pike_string *,struct pike_string *,node *);   static node *lexical_islocal(struct pike_string *);    - static struct pike_string *last_identifier=0; +    static int inherit_depth;   static struct program_state *inherit_state = NULL;   
385:    }    | idents    { -  if(last_identifier) +  if(Pike_compiler->last_identifier)    { -  ref_push_string(last_identifier); +  ref_push_string(Pike_compiler->last_identifier);    }else{    push_constant_text("");    }
2439:    {    int i;    -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $3->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string);    -  if (((i = find_shared_string_identifier(last_identifier, +  if (((i = find_shared_string_identifier(Pike_compiler->last_identifier,    Pike_compiler->new_program)) >= 0) || -  ((i = really_low_find_shared_string_identifier(last_identifier, +  ((i = really_low_find_shared_string_identifier(Pike_compiler->last_identifier,    Pike_compiler->new_program,    SEE_STATIC|    SEE_PRIVATE)) >= 0)) {
2472:    } else {    if (!Pike_compiler->num_parse_error) {    if (Pike_compiler->compiler_pass == 2) { -  my_yyerror("'%s' not defined in local scope.", last_identifier->str); +  my_yyerror("'%s' not defined in local scope.", Pike_compiler->last_identifier->str);    $$ = 0;    } else {    $$ = mknode(F_UNDEFINED, 0, 0);
2493:   idents: low_idents    | idents '.' TOK_IDENTIFIER    { -  $$=index_node($1, last_identifier?last_identifier->str:NULL, +  $$=index_node($1, Pike_compiler->last_identifier?Pike_compiler->last_identifier->str:NULL,    $3->u.sval.u.string);    free_node($1); -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $3->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string);    free_node($3);    }    | '.' TOK_IDENTIFIER
2515:    pop_stack();    $$=index_node(tmp, ".", $2->u.sval.u.string);    free_node(tmp); -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $2->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string);    free_node($2);    }    | idents '.' bad_identifier {}
2576:    {    int i;    struct efun *f; -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $1->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $1->u.sval.u.string);    -  if(($$=lexical_islocal(last_identifier))) +  if(($$=lexical_islocal(Pike_compiler->last_identifier)))    {    /* done, nothing to do here */ -  }else if((i=isidentifier(last_identifier))>=0){ +  }else if((i=isidentifier(Pike_compiler->last_identifier))>=0){    $$=mkidentifiernode(i); -  }else if(!($$=find_module_identifier(last_identifier,1))){ +  }else if(!($$=find_module_identifier(Pike_compiler->last_identifier,1))){    if(!Pike_compiler->num_parse_error)    {    if(Pike_compiler->compiler_pass==2)    { -  my_yyerror("'%s' undefined.", last_identifier->str); +  my_yyerror("'%s' undefined.", Pike_compiler->last_identifier->str);    $$=0;    }else{    $$=mknode(F_UNDEFINED,0,0);
2608:   #ifdef __CHECKER__    tmp.subtype=0;   #endif /* __CHECKER__ */ -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $3->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string);    tmp.u.mapping=get_builtin_constants();    tmp2=mkconstantsvaluenode(&tmp);    $$=index_node(tmp2, "predef", $3->u.sval.u.string);
2627:    if ($1) {    int id;    -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $2->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string);       id = low_reference_inherited_identifier(inherit_state,    $1, -  last_identifier, +  Pike_compiler->last_identifier,    SEE_STATIC);       if (id != -1) {
2642:    } else {    $$ = mkidentifiernode(id);    } -  } else if(ISCONSTSTR(last_identifier, "`->") || -  ISCONSTSTR(last_identifier, "`[]")) { +  } else if(ISCONSTSTR(Pike_compiler->last_identifier, "`->") || +  ISCONSTSTR(Pike_compiler->last_identifier, "`[]")) {    $$ = mknode(F_MAGIC_INDEX, mknewintnode($1),    mknewintnode(inherit_depth+1)); -  } else if(ISCONSTSTR(last_identifier, "`->=") || -  ISCONSTSTR(last_identifier, "`[]=")) { +  } else if(ISCONSTSTR(Pike_compiler->last_identifier, "`->=") || +  ISCONSTSTR(Pike_compiler->last_identifier, "`[]=")) {    $$ = mknode(F_MAGIC_SET_INDEX, mknewintnode($1),    mknewintnode(inherit_depth+1));    } else {    if (inherit_state->new_program->inherits[$1].name) {    my_yyerror("Undefined identifier %s::%s.",    inherit_state->new_program->inherits[$1].name->str, -  last_identifier->str); +  Pike_compiler->last_identifier->str);    } else { -  my_yyerror("Undefined identifier %s.", last_identifier->str); +  my_yyerror("Undefined identifier %s.", Pike_compiler->last_identifier->str);    }    $$=0;    }
2672:    {    int e,i;    -  if(last_identifier) free_string(last_identifier); -  copy_shared_string(last_identifier, $2->u.sval.u.string); +  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string);       $$=0;    for(e=1;e<(int)Pike_compiler->new_program->num_inherits;e++)
2898:    * Some error-handling    */    - /* FIXME: Should probably set last_identifier. */ + /* FIXME: Should probably set Pike_compiler->last_identifier. */   bad_identifier: bad_expr_ident    | TOK_CLASS    { yyerror("class is a reserved word."); }
3140:      void cleanup_compiler(void)   { -  if(last_identifier) -  { -  free_string(last_identifier); -  last_identifier=0; +    } - } +