pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:3822:    * the node value (inherit number) and with two global    * variables (inherit_state and inherit_depth).    *    * Note also that inherit number -1 indicates any inherit.    */   inherit_specifier: string_or_identifier TOK_COLON_COLON    {    struct compilation *c = THIS_COMPILATION;    struct program_state *state = Pike_compiler;    int depth; -  int e = -1; +  int e = INHERIT_ALL;       inherit_state = NULL;    inherit_depth = 0;       /* NB: The heuristics here are a bit strange    * (all to make it as backward compatible as possible).    *    * The priority order is as follows:    *    * 1: Direct inherits in the current class.
pike.git/src/language.yacc:3873:    /* Name of direct inherit ==> Done. */    break;    }    }    /* The top-level class does not have a name, so break here. */    if (depth == c->compilation_depth) break;    if (ID_FROM_INT (state->previous->new_program,    state->parent_identifier)->name ==    $1->u.sval.u.string) {    /* Name of surrounding class ==> Done. */ -  e = 0; +  e = INHERIT_SELF;    inherit_state = state;    inherit_depth = depth;    break;    }    } -  if (e == -1) { +  if (e < 0) {    inherit_state = state;    inherit_depth = depth; -  if ($1->u.sval.u.string == this_program_string || $1->u.sval.u.string == this_string) { +  if ($1->u.sval.u.string == this_program_string || +  $1->u.sval.u.string == this_string) {    inherit_state = Pike_compiler;    inherit_depth = 0; -  e = 0; +  e = INHERIT_SELF;    }    else    my_yyerror("No inherit or surrounding class %S.",    $1->u.sval.u.string);    }    free_node($1);    $$ = e;    }    | TOK_GLOBAL TOK_COLON_COLON    {    struct compilation *c = THIS_COMPILATION;    inherit_state = Pike_compiler;    for (inherit_depth = 0; inherit_depth < c->compilation_depth;    inherit_depth++, inherit_state = inherit_state->previous) {} -  $$ = -1; +  $$ = INHERIT_GLOBAL;    }    | inherit_specifier TOK_IDENTIFIER TOK_COLON_COLON    {    int e = 0;    if ($1 < 0) { -  $1 = 0; +  $1 = INHERIT_SELF;    }   #if 0    /* FIXME: The inherit modifiers aren't kept. */    if (!(inherit_state->new_program->inherits[$1].flags & ID_PRIVATE)) {   #endif /* 0 */    e = find_inherit(inherit_state->new_program->inherits[$1].prog,    $2->u.sval.u.string);   #if 0    }   #endif /* 0 */    if (!e) {    if (inherit_state->new_program->inherits[$1].name) {    my_yyerror("No such inherit %S::%S.",    inherit_state->new_program->inherits[$1].name,    $2->u.sval.u.string);    } else {    my_yyerror("No such inherit %S.", $2->u.sval.u.string);    } -  $$ = -1; +  $$ = INHERIT_ALL;    } else {    /* We know stuff about the inherit structure... */    $$ = e + $1;    }    free_node($2);    } -  | inherit_specifier bad_identifier TOK_COLON_COLON { $$ = -1; } +  | inherit_specifier bad_identifier TOK_COLON_COLON { $$ = INHERIT_ALL; }    ;      low_idents: TOK_IDENTIFIER    {    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(Pike_compiler->last_identifier)))    {    /* done, nothing to do here */
pike.git/src/language.yacc:4056:    else    $$=mknode(F_UNDEFINED,0,0);    }       free_node($2);    }    | inherit_specifier bad_identifier { $$=0; }    | inherit_specifier error { $$=0; }    | TOK_COLON_COLON TOK_IDENTIFIER    { -  int e,i; -  -  if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); +  if(Pike_compiler->last_identifier) { +  free_string(Pike_compiler->last_identifier); +  }    copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string);    -  $$ = find_inherited_identifier(Pike_compiler, 0, -2, +  $$ = find_inherited_identifier(Pike_compiler, 0, INHERIT_ALL,    Pike_compiler->last_identifier);    if(!$$)    {    if (Pike_compiler->compiler_pass == 2) {    my_yyerror("Undefined identifier ::%S.", $2->u.sval.u.string);    }    $$=mkintnode(0);    }    free_node($2);    }