src/sem_types.c
static char *
stringOfType(Type *type) {
  switch (type->type) {
    case TYP_S8:
      return "s8";
    case TYP_S16:
      return "s16";
    case TYP_S32:
      return "s32";
    case TYP_S64:
      return "s64";
    case TYP_U8:
      return "u8";
    case TYP_U16:
      return "u16";
    case TYP_U32:
      return "u32";
    case TYP_CHAR:
      return "char";
    case TYP_U64:
      return "u64";
    case TYP_VOID:
      return "void";
    case TYP_BOOL:
      return "bool";
    case TYP_ARRAY:
      return msprintf("[%ld]%s", type->array.size,
                      stringOfType(type->array.type));
    case TYP_PTR:
      if (type->ptr.mut) {
        return msprintf("&mut %s", stringOfType(type->ptr.type));
      }
      return msprintf("&%s", stringOfType(type->ptr.type));
    case TYP_BINDING:
      return msprintf("%.*s", (int)type->typeEntry->id.len,
                      type->typeEntry->id.text);

    case TYP_INTLIT:
      return "integer literal";
    case TYP_FUN:
      return "function pointer";
    case TYP_RECORD:
      return "record";
  }
  assert(false);
  return NULL;
}
/* This is only needed because the current error handling system does not
 * allow you to just pass a type and have the error printer call printType
 * This means an actual string must be allocated When the error system is
 * improved this can be deleted */
This is only needed because the current error handling system does not
allow you to just pass a type and have the error printer call printType
This means an actual string must be allocated When the error system is
improved this can be deleted
This is only needed because the current error handling system does not allow you to just pass a type and have the error printer call printType This means an actual string must be allocated When the error system is improved this can be deleted
static char *
stringOfType(Type *type) {
  switch (type->type) {
    case TYP_S8:
      return "s8";
    case TYP_S16:
      return "s16";
    case TYP_S32:
      return "s32";
    case TYP_S64:
      return "s64";
    case TYP_U8:
      return "u8";
    case TYP_U16:
      return "u16";
    case TYP_U32:
      return "u32";
    case TYP_CHAR:
      return "char";
    case TYP_U64:
      return "u64";
    case TYP_VOID:
      return "void";
    case TYP_BOOL:
      return "bool";
    case TYP_ARRAY:
      return msprintf("[%ld]%s", type->array.size,
                      stringOfType(type->array.type));
    case TYP_PTR:
      if (type->ptr.mut) {
        return msprintf("&mut %s", stringOfType(type->ptr.type));
      }
      return msprintf("&%s", stringOfType(type->ptr.type));
    case TYP_BINDING:
      return msprintf("%.*s", (int)type->typeEntry->id.len,
                      type->typeEntry->id.text);
    case TYP_INTLIT:
      return "integer literal";
    case TYP_FUN:
      return "function pointer";
    case TYP_RECORD:
      return "record";
  }
  assert(false);
  return NULL;
}
static char * stringOfType ( Type * type ) { switch ( type -> type ) { case TYP_S8 : return " " ; case TYP_S16 : return " " ; case TYP_S32 : return " " ; case TYP_S64 : return " " ; case TYP_U8 : return " " ; case TYP_U16 : return " " ; case TYP_U32 : return " " ; case TYP_CHAR : return " " ; case TYP_U64 : return " " ; case TYP_VOID : return " " ; case TYP_BOOL : return " " ; case TYP_ARRAY : return msprintf ( " " , type -> array . size , stringOfType ( type -> array . type ) ) ; case TYP_PTR : if ( type -> ptr . mut ) { return msprintf ( " " , stringOfType ( type -> ptr . type ) ) ; } return msprintf ( " " , stringOfType ( type -> ptr . type ) ) ; case TYP_BINDING : return msprintf ( " " , ( int ) type -> typeEntry -> id . len , type -> typeEntry -> id . text ) ; case TYP_INTLIT : return " " ; case TYP_FUN : return " " ; case TYP_RECORD : return " " ; } assert ( false ) ; return NULL ; }
This is only needed because the current error handling system does not
 allow you to just pass a type and have the error printer call printType
 This means an actual string must be allocated When the error system is
 improved this can be deleted
This is only needed because the current error handling system does not allow you to just pass a type and have the error printer call printType This means an actual string must be allocated When the error system is improved this can be deleted