Branch: Tag:

2020-12-06

2020-12-06 14:51:49 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Added PT_FLAG_REMAP_TRACE.

Attempt to avoid drowning in debug output by traceing only
relevant operations.

4052:   {    if (!t) return NULL;    +  if (flags & PT_FLAG_REMAP_TRACE) { +  fprintf(stderr, "remap_markers("); +  simple_describe_type(t); +  fprintf(stderr, ", "); +  simple_describe_mapping(markers); +  fprintf(stderr, ", %p, 0x%02x)\n", remap, flags); +  } +     type_stack_mark();    push_remap_markers(t, markers, remap, flags); -  +  +  if (flags & PT_FLAG_REMAP_TRACE) { +  fprintf(stderr, "remap ==> "); +  simple_describe_type(peek_type_stack()); +  fprintf(stderr, "\n"); +  }    return pop_unfinished_type();   }   
4178:    enum pt_cmp_flags avoidable;    enum pt_cmp_flags bvoidable;    +  if (remap_flags & PT_FLAG_REMAP_TRACE) { +  fprintf(stderr, "low_type_binop(0x%04x, ", op); +  simple_describe_type(a); +  fprintf(stderr, ", "); +  simple_describe_type(b); +  fprintf(stderr, ", %p, 0x%04x, 0x%04x, 0x%02x)\n", +  remap, aflags, bflags, remap_flags); +  } +     switch(op) {    case PT_BINOP_AND:    case PT_BINOP_MINUS:
4552:    bflags | bvoidable,    remap_flags);    +  if (remap_flags & PT_FLAG_REMAP_TRACE) { +  fprintf(stderr, "got_empty: %d, got_full: %d\n" +  "tmp: ", +  got_empty, got_full); +  simple_describe_type(tmp); +  fprintf(stderr, "\n"); +  } +     switch(op) {    case PT_BINOP_AND:    if (!tmp) {
4578:    tmp = low_type_binop(op, aret, bret, remap,    aflags | PT_FLAG_CMP_VOIDABLE,    bflags | PT_FLAG_CMP_VOIDABLE, remap_flags); +  +  if (remap_flags & PT_FLAG_REMAP_TRACE) { +  fprintf(stderr, "ret_tmp: "); +  simple_describe_type(tmp); +  fprintf(stderr, "\n"); +  }    if (!tmp) goto function_fail;       nargs = pop_stack_mark();
4615:    if (!aret) aret = ai->cdr;    if (!bret) bret = bi->cdr;    +  /* NB: Ignore the return type if matching against void. */    tmp = low_type_binop(op, aret, bret, NULL,    aflags | PT_FLAG_CMP_VOIDABLE,    bflags | PT_FLAG_CMP_VOIDABLE, remap_flags); -  +  +  if (remap_flags & PT_FLAG_REMAP_TRACE) { +  fprintf(stderr, "got_empty: %d, got_full: %d\n" +  "ret tmp: ", +  got_empty, got_full); +  simple_describe_type(tmp); +  fprintf(stderr, "\n"); +  } +     if (!tmp) {    if (got_full) goto function_next;    got_empty = 1;
8580:    if ((save_type_stackp != Pike_compiler->type_stackp) ||    (save_mark_stackp != Pike_compiler->pike_type_mark_stackp) ||    (res != !tmp2)) { +  struct pike_type *tmp3; +     fprintf(stderr, "pike_types_le mismatch!\n"    "a: ");    simple_describe_type(a);
8590:    fprintf(stderr, "\ntmp2: ");    simple_describe_type(tmp2);    fprintf(stderr, "\n\n"); +  +  tmp3 = low_type_binop(PT_BINOP_MINUS, a, b, &remap, +  0, 0, PT_FLAG_REMAP_TRACE); +  fprintf(stderr, "tmp3: "); +  simple_describe_type(tmp3); +  fprintf(stderr, "\n\n"); +     if ((save_type_stackp != Pike_compiler->type_stackp) ||    (save_mark_stackp != Pike_compiler->pike_type_mark_stackp)) {    Pike_fatal("Stack level corruption!\n"
8598:    Pike_compiler->type_stackp, save_type_stackp,    Pike_compiler->pike_type_mark_stackp, save_mark_stackp);    } +  +  free_type(tmp3);    }       free_type(tmp);