Branch: Tag:

2021-12-16

2021-12-16 10:39:50 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Improved handling of markers in type_binop().

Also removes some debug.

4595:    return pop_unfinished_type();    }    -  if (remap_flags & PT_FLAG_REMAP_TRACE) { -  fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); -  } -  +     /* Check consolidated types. */    switch(a?a->type:PIKE_T_UNKNOWN) {    case T_OR:
4775:    }       /* -  * NB: At this point a and b are either NULL or a basic type. +  * NB: At this point a and b are either NULL, a basic type or a marker.    */    -  +  loop: +  switch(a ? a->type : PIKE_T_UNKNOWN) { +  case '0': case '1': case '2': case '3': case '4': +  case '5': case '6': case '7': case '8': case '9': +  { +  int marker = remap_marker(remap, a->type, remap_flags); +  if (!marker) { +  a = NULL; +  break; +  } +  +  tmp = remap_markers(b, NULL, remap, +  remap_flags ^ PT_FLAG_REMAP_SWAP_MARKERS); +  if (!tmp) { +  b = NULL; +  break; +  } +  type_stack_mark(); +  push_finished_type(tmp); +  push_type(marker); +  push_binop(op); +  free_type(tmp); +  return pop_unfinished_type(); +  } +  } +  switch(b ? b->type : PIKE_T_UNKNOWN) { +  case '0': case '1': case '2': case '3': case '4': +  case '5': case '6': case '7': case '8': case '9': +  { +  int marker = remap_marker(remap, b->type, +  remap_flags ^ PT_FLAG_REMAP_SWAP_MARKERS); +  if (!marker) { +  b = NULL; +  break; +  } +  +  tmp = remap_markers(a, NULL, remap, remap_flags); +  if (!tmp) { +  a = NULL; +  break; +  } +  type_stack_mark(); +  push_type(marker); +  push_finished_type(tmp); +  push_binop(op); +  free_type(tmp); +  return pop_unfinished_type(); +  } +  } +     /* Handle a or b being NULL. */    /* NB: We know that a != b due to an earlier test. */    if (!a) {
4801:    return NULL;    }    +  /* +  * NB: At this point a and b are basic types. +  */ +     /* Check implicit casting. */ -  loop: +     switch(TWOT(a->type & PIKE_T_MASK, b->type & PIKE_T_MASK)) {    case TWOT(T_PROGRAM, T_TYPE):    case TWOT(T_PROGRAM, T_PROGRAM):
5242:   #endif    }    -  switch(a->type) { -  case '0': case '1': case '2': case '3': case '4': -  case '5': case '6': case '7': case '8': case '9': -  { -  int marker = remap_marker(remap, a->type, remap_flags); -  if (!marker) return NULL; -  -  tmp = remap_markers(b, NULL, remap, -  remap_flags ^ PT_FLAG_REMAP_SWAP_MARKERS); -  if (!tmp) return NULL; -  type_stack_mark(); -  push_finished_type(tmp); -  push_type(marker); -  push_binop(op); -  free_type(tmp); -  return pop_unfinished_type(); -  } -  } -  switch(b->type) { -  case '0': case '1': case '2': case '3': case '4': -  case '5': case '6': case '7': case '8': case '9': -  { -  int marker = remap_marker(remap, b->type, -  remap_flags ^ PT_FLAG_REMAP_SWAP_MARKERS); -  if (!marker) return NULL; -  -  tmp = remap_markers(a, NULL, remap, remap_flags); -  if (!tmp) return NULL; -  type_stack_mark(); -  push_type(marker); -  push_finished_type(tmp); -  push_binop(op); -  free_type(tmp); -  return pop_unfinished_type(); -  } -  } -  +     if (a->type != b->type) {    if (a->type == T_VOID) {    if (bflags & PT_FLAG_CMP_VOIDABLE) {