Branch: Tag:

2017-12-11

2017-12-11 18:05:19 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Add symbolic constants COMPILER_PASS_*.

This is in preparation for adding more passes.

1664:    TYPE ARG) { \    NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \    CHECK_FOO(NUMTYPE,TYPE,NAME); \ -  DO_IF_DEBUG(if (state->compiler_pass != 1) { \ +  DO_IF_DEBUG(if (state->compiler_pass != COMPILER_PASS_FIRST) { \    Pike_fatal("Adding " TOSTR(NAME) " in pass %d.\n", \    state->compiler_pass); \    }); \
1896:    struct node_s *ret;    UNSETJMP(tmp);    -  if (Pike_compiler->compiler_pass == 2 && +  if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST &&    ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&    Pike_sp[-1].u.object == placeholder_object) ||    (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&
1949:    if(i!=-1)    {    if ((p->flags & COMPILATION_FORCE_RESOLVE) && -  (p->compiler_pass == 2) && +  (p->compiler_pass == COMPILER_PASS_LAST) &&    ((p->num_inherits + 1) < p->new_program->num_inherits) &&    (PTR_FROM_INT(p->new_program, i)->inherit_offset >    p->num_inherits)) {
2033:    if (!safe_apply_current2(PC_RESOLV_FUN_NUM, 3, NULL))    handle_compile_exception ("Error resolving '%S'.", ident);    -  if (Pike_compiler->compiler_pass != 2) { +  if (Pike_compiler->compiler_pass != COMPILER_PASS_LAST) {    /* If we get a program that hasn't gone through pass 1 yet then we    * have to register a dependency now in our pass 1 so that our    * pass 2 gets delayed. Otherwise the other program might still be
2049:    report_compiler_dependency (p);    }    -  if (Pike_compiler->compiler_pass == 2 && +  if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST &&    ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&    Pike_sp[-1].u.object == placeholder_object) ||    (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&
2434:    } else if ((id != -1) && (prog != state->new_program)) {    id = really_low_reference_inherited_identifier(state, i, id);    } -  if ((id != -1) && (state->compiler_pass == 2)) { +  if ((id != -1) && (state->compiler_pass == COMPILER_PASS_LAST)) {    if (inherit_num < 0) {    /* Find the closest inherit containing the lfun::`->()    * that is about to be called.
2784:    (sub_ref->id_flags & ID_USED)) {    struct identifier *sub_id = ID_FROM_PTR(inh->prog, sub_ref);    if (IDENTIFIER_IS_FUNCTION(sub_id->identifier_flags)) { -  if ((Pike_compiler->compiler_pass == 2) && +  if ((Pike_compiler->compiler_pass == COMPILER_PASS_LAST) &&    !pike_types_le(ID_FROM_PTR(Pike_compiler->new_program,    new_ref)->type, sub_id->type)) {    yytype_report(REPORT_WARNING,
4266:    if (type)    {    struct pike_type * temp = type; -  if ((Pike_compiler->compiler_pass == 2) && !ref->inherit_offset && +  if ((Pike_compiler->compiler_pass == COMPILER_PASS_LAST) && +  !ref->inherit_offset &&    !check_variant_overload(id->type, type)) {    /* This symbol is shadowed by later variants. */    yytype_report(REPORT_WARNING,
4332:    }       if (finish == 1) { -  if (Pike_compiler->compiler_pass == 1) { +  if (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) {    /* Called from end_program(). */    if (Pike_compiler->init_node) {    /* Make sure that the __INIT symbol exists, so that
4347:    OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);    }    } -  Pike_compiler->compiler_pass = 2; +  Pike_compiler->compiler_pass = COMPILER_PASS_LAST;    }       /*
4458:    c->compilation_depth, Pike_compiler->compiler_pass);   #endif    -  if(!Pike_compiler->compiler_frame && (Pike_compiler->compiler_pass==2 || !prog) && c->resolve_cache) +  if(!Pike_compiler->compiler_frame && +  (Pike_compiler->compiler_pass == COMPILER_PASS_LAST || !prog) && +  c->resolve_cache)    {    free_mapping(dmalloc_touch(struct mapping *, c->resolve_cache));    c->resolve_cache=0;
4800:       p = np->inherits[i].prog;    -  if ((q?q:Pike_compiler)->compiler_pass == 2) { +  if ((q?q:Pike_compiler)->compiler_pass == COMPILER_PASS_LAST) {    struct identifier *id = ID_FROM_INT(p, f);    if (((id->identifier_flags & IDENTIFIER_TYPE_MASK) ==    IDENTIFIER_PIKE_FUNCTION) && (id->func.offset == -1)) {
5050:    return;    }    -  if (Pike_compiler->compiler_pass == 2) { +  if (Pike_compiler->compiler_pass != COMPILER_PASS_FIRST) {    struct program *old_p =    Pike_compiler->new_program->inherits[Pike_compiler->num_inherits+1].prog;    Pike_compiler->num_inherits += old_p->num_inherits;
5616: Inside #if defined(PIKE_DEBUG)
   if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED))    Pike_fatal("Attempting to add variable to fixed program\n");    -  if(Pike_compiler->compiler_pass==2) +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST)    Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"    "Added identifier: \"%s\"\n", name->str);   #endif
5740: Inside #if defined(PIKE_DEBUG)
   if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED))    Pike_fatal("Attempting to add variable to fixed program\n");    -  if(Pike_compiler->compiler_pass==2) +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST)    Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"    "Added identifier: \"%s\"\n", name->str);   #endif
5882:    "variable/functions %S", name);       if(!(IDENTIFIERP(n)->id_flags & ID_INLINE) || -  Pike_compiler->compiler_pass!=1) +  Pike_compiler->compiler_pass != COMPILER_PASS_LAST)    {    int n2;   
6133: Inside #if defined(PIKE_DEBUG)
   if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED))    Pike_fatal("Attempting to add constant to fixed program\n");    -  if(Pike_compiler->compiler_pass==2) { +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST) {    dump_program_tables(Pike_compiler->new_program, 2);    Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"    " Attempted to add the identifier \"%s\"\n",
6407: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Bad entry in lfun_types for key \"%s\"\n", name->str);    }   #endif /* PIKE_DEBUG */ -  if (Pike_compiler->compiler_pass == 2) { +  if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST) {    /* Inhibit deprecation warnings during the comparison. */    c->lex.pragmas |= ID_NO_DEPRECATION_WARNINGS;    if (!pike_types_le(type, lfun_type->u.type)) {
6487:    my_yyerror("Illegal to redefine a current variable with a getter/setter: %S.", symbol);    } else {    if ((ref->id_flags | ID_USED) != (flags | ID_USED)) { -  if (Pike_compiler->compiler_pass == 1) { +  if (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) {    yywarning("Modifier mismatch for variable %S.", symbol);    }    ref->id_flags &= flags | ID_USED;
6522:    if(IDENTIFIER_IS_C_FUNCTION(function_flags))    prog->flags |= PROGRAM_HAS_C_METHODS;    -  if (Pike_compiler->compiler_pass == 1) { +  if (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) {    /* Mark the type as tentative by setting the runtime-type    * to T_MIXED.    *
6532:    }       i = isidentifier(name); -  if (Pike_compiler->compiler_pass == 1) { +  if (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) {    if (flags & ID_VARIANT) {    if (i >= 0) {    if (!is_variant_dispatcher(prog, i)) {
6637:    * pass 2. Only do this in pass 2, and only if the previous    * type isn't from pass 1.    */ -  if ((Pike_compiler->compiler_pass == 2) && +  if ((Pike_compiler->compiler_pass == COMPILER_PASS_LAST) &&    (funp->run_time_type == T_FUNCTION)) {    /* match types against earlier prototype or vice versa */    if(!match_types(type, funp->type))
6678:    my_yyerror("Illegal to redefine 'final' function %S.", name);    }    -  if (!(flags & ID_VARIANT) && (Pike_compiler->compiler_pass == 1) && +  if (!(flags & ID_VARIANT) && +  (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) &&    (funp->func.c_fun == f_dispatch_variant) &&    (!func || (func->c_fun != f_dispatch_variant) ||    !IDENTIFIER_IS_C_FUNCTION(function_flags)) &&
6777:    make_a_new_def:      #ifdef PIKE_DEBUG -  if(Pike_compiler->compiler_pass==2) +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST)    Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"    "Added identifier: \"%s\"\n", name->str);   #endif
7059:    /* if(fun->func.offset == -1) continue; * Prototype */    if(!is_same_string(fun->name,name)) continue;    if(type && (fun->type != type)) { -  if ((Pike_compiler->compiler_pass == 2) && +  if ((Pike_compiler->compiler_pass == COMPILER_PASS_LAST) &&    !(funp->id_flags & ID_INHERITED) &&    match_types(fun->type, type)) {    tentative = i;