Branch: Tag:

2018-11-14

2018-11-14 14:19:50 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Fixed multi-counting of annotations.

Annotations were added in every pass of the compiler. They are
now cleared at the start of each pass.

1758:    debug_add_to_identifiers(dummy);       if (Pike_compiler->current_annotations) { +  /* FIXME: What about annotations for eg variant functions? */    compiler_add_annotations(n, Pike_compiler->current_annotations); -  +  /* Only annotate a single identifier. */ +  free_node(Pike_compiler->current_annotations); +  Pike_compiler->current_annotations = NULL;    }       return n;
3170:   #endif    }    }else{ +  int e;    tmp.u.program=p;    add_ref(p);    if((pass != COMPILER_PASS_FIRST) && name)
3182:    free_type(i->type);    i->type=get_type_of_svalue(&tmp);    } +  +  /* Reset annotations so that they can be readded properly. */ +  for (e = 0; e < p->num_annotations; e++) { +  do_free_array(p->annotations[e]); +  p->annotations[e] = NULL;    } -  +  }    if (pass == COMPILER_PASS_FIRST) {    if(c->compilation_depth >= 1) {    add_ref(p->parent = Pike_compiler->new_program);
5920:    if(n==-1)    yyerror("Pass2: Variable disappeared!");    else { -  struct identifier *id=ID_FROM_INT(Pike_compiler->new_program,n); +  struct reference *ref = PTR_FROM_INT(Pike_compiler->new_program, n); +  struct identifier *id = ID_FROM_PTR(Pike_compiler->new_program, ref); +  +  if (Pike_compiler->current_annotations) { +  compiler_add_annotations(ref->identifier_offset, +  Pike_compiler->current_annotations); +  /* Only annotate a single identifier. */ +  free_node(Pike_compiler->current_annotations); +  Pike_compiler->current_annotations = NULL; +  } +     free_type(id->type);    copy_pike_type(id->type, type);    return n;
6174:    {    yyerror("Pass2: Constant disappeared!");    }else{ -  struct identifier *id; -  id=ID_FROM_INT(Pike_compiler->new_program,n); +  struct reference *ref = PTR_FROM_INT(Pike_compiler->new_program, n); +  struct identifier *id = ID_FROM_PTR(Pike_compiler->new_program, ref); +  +  if (Pike_compiler->current_annotations) { +  compiler_add_annotations(ref->identifier_offset, +  Pike_compiler->current_annotations); +  /* Only annotate a single identifier. */ +  free_node(Pike_compiler->current_annotations); +  Pike_compiler->current_annotations = NULL; +  } +     if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {    /* FIXME: We probably ought to do something here... */    } else if(id->func.const_info.offset>=0) {
6691:       if(!(ref.id_flags & ID_INHERITED)) /* not inherited */    { +  if (Pike_compiler->current_annotations) { +  compiler_add_annotations(ref.identifier_offset, +  Pike_compiler->current_annotations); +  /* Only annotate a single identifier. */ +  free_node(Pike_compiler->current_annotations); +  Pike_compiler->current_annotations = NULL; +  }       if( !( IDENTIFIER_IS_FUNCTION(funp->identifier_flags) &&    ( (!func || func->offset == -1) || (funp->func.offset == -1))))