Branch: Tag:

2003-01-07

2003-01-07 20:11:56 by Henrik Grubbström (Grubba) <grubba@grubba.org>

More §6.3.4 fixes.

Rev: src/pike_types.c:1.203

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pike_types.c,v 1.202 2002/11/28 19:11:43 mast Exp $ + || $Id: pike_types.c,v 1.203 2003/01/07 20:11:56 grubba Exp $   */      #include "global.h" - RCSID("$Id: pike_types.c,v 1.202 2002/11/28 19:11:43 mast Exp $"); + RCSID("$Id: pike_types.c,v 1.203 2003/01/07 20:11:56 grubba Exp $");   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"
315:   {    unsigned INT32 hash = DO_NOT_WARN((unsigned INT32)    ((ptrdiff_t)type*0x10204081)^ -  (0x8003*(ptrdiff_t)car)^ -  ~(0x10001*(ptrdiff_t)cdr)); +  (0x8003*(((char *)car)-(char *)0))^ +  ~(0x10001*(((char *)cdr)-(char *)0)));    unsigned INT32 index = hash % pike_type_hash_size;    struct pike_type *t;   
788:    if (type->type == T_ASSIGN) {    /* Strip assign */   #if 0 -  fprintf(stderr, "Assign to marker %d.\n", ((ptrdiff_t)type->car)); +  fprintf(stderr, "Assign to marker %d.\n", +  ((char *)type->car)-(char *)0);   #endif /* 0 */    type = type->cdr;    goto recurse;
1300: Inside #if defined(PIKE_DEBUG)
   break;       case T_SCOPE: -  fprintf(stderr, "scope(%ld, ", (long)(ptrdiff_t)s->car); +  fprintf(stderr, "scope(%ld, ", +  (long)(((char *)s->car)-(char *)0));    simple_describe_type(s->cdr);    fprintf(stderr, ")");    break;
1312: Inside #if defined(PIKE_DEBUG)
   fprintf(stderr, ")");    break;    case T_ASSIGN: -  fprintf(stderr, "%ld = ", (long)(ptrdiff_t)s->car); +  fprintf(stderr, "%ld = ", +  (long)(((char *)s->car)-(char *)0));    simple_describe_type(s->cdr);    break;    case T_INT:    { -  INT32 min = (ptrdiff_t)s->car; -  INT32 max = (ptrdiff_t)s->cdr; +  INT32 min = ((char *)s->car)-(char *)0; +  INT32 max = ((char *)s->cdr)-(char *)0;    fprintf(stderr, "int");    if(min!=MIN_INT32 || max!=MAX_INT32)    fprintf(stderr, "(%ld..%ld)",(long)min,(long)max);
1339: Inside #if defined(PIKE_DEBUG)
   case T_OBJECT:    fprintf(stderr, "object(%s %ld)",    s->car?"is":"implements", -  (long)(ptrdiff_t)s->cdr); +  (long)(((char *)s->cdr)-(char *)0));    break;    case T_FUNCTION:    case T_MANY:
1450:       case T_ASSIGN:    my_putchar('('); -  my_putchar('0' + (ptrdiff_t)t->car); +  my_putchar('0' + (((char *)t->car)-(char *)0));    my_putchar('=');    my_describe_type(t->cdr);    my_putchar(')');
1458:       case T_SCOPE:    my_putchar('{'); -  my_putchar((ptrdiff_t)t->car); +  my_putchar(((char *)t->car)-(char *)0);    my_putchar(',');    my_describe_type(t->cdr);    my_putchar('}');
1478:    case PIKE_T_UNKNOWN: my_strcat("unknown"); break;    case T_INT:    { -  INT32 min=(ptrdiff_t)t->car; -  INT32 max=(ptrdiff_t)t->cdr; +  INT32 min=((char *)t->car)-(char *)0; +  INT32 max=((char *)t->cdr)-(char *)0;    my_strcat("int");       if(min!=MIN_INT32 || max!=MAX_INT32)
1507:    char buffer[100];    sprintf(buffer,"object(%s %ld)",    t->car?"is":"implements", -  (long)(ptrdiff_t)t->cdr); +  (long)(((char *)t->cdr)-(char *)0));    my_strcat(buffer);    }else{    my_strcat("object");
1800:    }    else if(t1->type == T_INT && t2->type == T_INT)    { -  INT32 min, max; +  INT32 min1 = ((char *)t1->car)-(char *)0; +  INT32 max1 = ((char *)t1->cdr)-(char *)0; +  INT32 min2 = ((char *)t2->car)-(char *)0; +  INT32 max2 = ((char *)t2->cdr)-(char *)0;    -  if ((((ptrdiff_t)t1->cdr) + 1 < (ptrdiff_t)t2->car) || -  (((ptrdiff_t)t2->cdr) + 1 < (ptrdiff_t)t1->car)) { +  if ((max1 + 1 < min2) || (max2 + 1 < min1)) {    /* No overlap. */    push_finished_type(t1);    push_finished_type(t2);    push_type(T_OR);    } else {    /* Overlap */ -  min = MINIMUM((ptrdiff_t)t1->car, (ptrdiff_t)t2->car); -  max = MAXIMUM((ptrdiff_t)t1->cdr, (ptrdiff_t)t2->cdr); +  min1 = MINIMUM(min1, min2); +  max1 = MAXIMUM(max1, max2);    -  push_int_type(min, max); +  push_int_type(min1, max1);    }    }    else if (t1->type == T_SCOPE)
1821:    if (t2->type == T_SCOPE) {    low_or_pike_types(t1->cdr, t2->cdr, zero_implied);    if (t1->car > t2->car) -  push_scope_type((ptrdiff_t)t1->car); +  push_scope_type(((char *)t1->car)-(char *)0);    else -  push_scope_type((ptrdiff_t)t2->car); +  push_scope_type(((char *)t2->car)-(char *)0);    } else {    low_or_pike_types(t1->cdr, t2, zero_implied); -  push_scope_type((ptrdiff_t)t1->car); +  push_scope_type(((char *)t1->car)-(char *)0);    }    }    else if (t2->type == T_SCOPE)    {    low_or_pike_types(t1, t2->cdr, zero_implied); -  push_scope_type((ptrdiff_t)t2->car); +  push_scope_type(((char *)t2->car)-(char *)0);    push_type(T_SCOPE);    }    else
1878:    if (t1->type == T_INT) {    INT32 i1, i2;    INT32 upper_bound, lower_bound; -  i1 = (ptrdiff_t)t1->cdr; -  i2 = (ptrdiff_t)t2->cdr; +  i1 = ((char *)t1->cdr)-(char *)0; +  i2 = ((char *)t2->cdr)-(char *)0;    upper_bound = MINIMUM(i1,i2);    -  i1 = (ptrdiff_t)t1->car; -  i2 = (ptrdiff_t)t2->car; +  i1 = ((char *)t1->car)-(char *)0; +  i2 = ((char *)t2->car)-(char *)0;    lower_bound = MAXIMUM(i1,i2);       if (upper_bound >= lower_bound) {
1979:    {    INT32 i1,i2;    INT32 upper_bound, lower_bound; -  i1 = (ptrdiff_t)t1->cdr; -  i2 = (ptrdiff_t)t2->cdr; +  i1 = ((char *)t1->cdr)-(char *)0; +  i2 = ((char *)t2->cdr)-(char *)0;    upper_bound = MINIMUM(i1,i2);    -  i1 = (ptrdiff_t)t1->car; -  i2 = (ptrdiff_t)t2->car; +  i1 = ((char *)t1->car)-(char *)0; +  i2 = ((char *)t2->car)-(char *)0;    lower_bound = MAXIMUM(i1,i2);       if (upper_bound >= lower_bound) {
2000:    if (t2->type == T_SCOPE) {    low_and_pike_types(t1->cdr, t2->cdr);    if (t1->car > t2->car) -  push_scope_type((ptrdiff_t)t1->car); +  push_scope_type(((char *)t1->car)-(char *)0);    else -  push_scope_type((ptrdiff_t)t2->car); +  push_scope_type(((char *)t2->car)-(char *)0);    } else {    low_and_pike_types(t1->cdr, t2); -  push_scope_type((ptrdiff_t)t1->car); +  push_scope_type(((char *)t1->car)-(char *)0);    }    }    else if (t2->type == T_SCOPE)    {    low_and_pike_types(t1, t2->cdr); -  push_scope_type((ptrdiff_t)t2->car); +  push_scope_type(((char *)t2->car)-(char *)0);    }    else if((t1->type == t2->type) &&    ((t1->type == T_STRING) ||
2057:   {    struct program *p;    int i; -  p = id_to_program((ptrdiff_t)t->cdr); +  p = id_to_program(((char *)t->cdr)-(char *)0);    if(!p) return 0;    i=FIND_LFUN(p, lfun);    if(i==-1) return 0;
2193:    ret = low_match_types(a->cdr, b, flags);    if(ret && (b->type != T_VOID))    { -  int m = (ptrdiff_t)a->car; +  int m = ((char *)a->car)-(char *)0;    struct pike_type *tmp;      #ifdef PIKE_DEBUG
2228:    }   #endif   #ifdef PIKE_DEBUG -  if((ptrdiff_t)a_markers[m]->type == m+'0') +  if((((char *)a_markers[m]->type)-(char *)0) == m+'0')    Pike_fatal("Cyclic type!\n");   #endif    }
2287:    ret = low_match_types(a, b->cdr, flags);    if(ret && (a->type != T_VOID))    { -  int m = (ptrdiff_t)b->car; +  int m = ((char *)b->car)-(char *)0;    struct pike_type *tmp;    type_stack_mark();    push_finished_type_with_markers(a, a_markers);
2314:    }   #endif   #ifdef PIKE_DEBUG -  if((ptrdiff_t)b_markers[m]->type == m+'0') +  if((((char *)b_markers[m]->type)-(char *)0) == m+'0')    Pike_fatal("Cyclic type!\n");   #endif    }
2430:    }    case TWOT(T_INT, T_ZERO):    { -  if ((((ptrdiff_t)a->car) > 0) || -  (((ptrdiff_t)a->cdr) < 0)) { +  if (((((char *)a->car)-(char *)0) > 0) || +  ((((char *)a->cdr)-(char *)0) < 0)) {    return 0;    }    return a;    }    case TWOT(T_ZERO, T_INT):    { -  if ((((ptrdiff_t)b->car) > 0) || -  (((ptrdiff_t)b->cdr) < 0)) { +  if (((((char *)b->car)-(char *)0) > 0) || +  ((((char *)b->cdr)-(char *)0) < 0)) {    return 0;    }    return a;
2540: Inside #if 0
   * (got "Prototype doesn't match for function foo" even though    * there was no other prototype for that function). /mast */    struct program *ap,*bp; -  ap = id_to_program((ptrdiff_t)a->cdr); -  bp = id_to_program((ptrdiff_t)b->cdr); +  ap = id_to_program(((char *)a->cdr)-(char *)0); +  bp = id_to_program(((char *)b->cdr)-(char *)0);    if (!is_compatible(ap, bp)) return 0;   #endif    break;
2550:       {    struct program *ap,*bp; -  ap = id_to_program((ptrdiff_t)a->cdr); -  bp = id_to_program((ptrdiff_t)b->cdr); +  ap = id_to_program(((char *)a->cdr)-(char *)0); +  bp = id_to_program(((char *)b->cdr)-(char *)0);       if(!ap || !bp) break;   
2577:       case T_INT:    { -  INT32 amin = (ptrdiff_t)a->car; -  INT32 amax = (ptrdiff_t)a->cdr; +  INT32 amin = ((char *)a->car)-(char *)0; +  INT32 amax = ((char *)a->cdr)-(char *)0;    -  INT32 bmin = (ptrdiff_t)b->car; -  INT32 bmax = (ptrdiff_t)b->cdr; +  INT32 bmin = ((char *)b->car)-(char *)0; +  INT32 bmax = ((char *)b->cdr)-(char *)0;       if(amin > bmax || bmin > amax) return 0;    break;
2744:    ret = low_pike_types_le(a->cdr, b, array_cnt, flags);    if(ret && (b->type != T_VOID))    { -  int m = (ptrdiff_t)a->car; +  int m = ((char *)a->car)-(char *)0;    struct pike_type *tmp;    int i;    type_stack_mark();
2828:    ret = low_pike_types_le(a, b->cdr, array_cnt, flags);    if(ret && (a->type != T_VOID))    { -  int m = (ptrdiff_t)b->car; +  int m = ((char *)b->car)-(char *)0;    struct pike_type *tmp;    int i;    type_stack_mark();
3097:    }       { -  struct program *ap = id_to_program((ptrdiff_t)a->cdr); -  struct program *bp = id_to_program((ptrdiff_t)b->cdr); +  struct program *ap = id_to_program(((char *)a->cdr)-(char *)0); +  struct program *bp = id_to_program(((char *)b->cdr)-(char *)0);       if (!ap || !bp) {    /* Shouldn't happen... */
3113:       case T_INT:    { -  INT32 amin = (ptrdiff_t)a->car; -  INT32 amax = (ptrdiff_t)a->cdr; +  INT32 amin = ((char *)a->car)-(char *)0; +  INT32 amax = ((char *)a->cdr)-(char *)0;    -  INT32 bmin = (ptrdiff_t)b->car; -  INT32 bmax = (ptrdiff_t)b->cdr; +  INT32 bmin = ((char *)b->car)-(char *)0; +  INT32 bmax = ((char *)b->cdr)-(char *)0;       if(amin < bmin || amax > bmax) return 0;    break;
3317:    {    case T_OBJECT:    { -  p = id_to_program((ptrdiff_t)t->cdr); +  p = id_to_program(((char *)t->cdr)-(char *)0);       comefrom_int_index:    if(p && n)
3508:    {    case T_OBJECT:    { -  p = id_to_program((ptrdiff_t)t->cdr); +  p = id_to_program(((char *)t->cdr)-(char *)0);       if(p)    {
3690:    {    case T_OBJECT:    { -  struct program *p = id_to_program((ptrdiff_t)t->cdr); +  struct program *p = id_to_program(((char *)t->cdr)-(char *)0);    if(p && n)    {    if(n->token == F_ARROW)
3799:       case T_OBJECT:    { -  struct program *p = id_to_program((ptrdiff_t)type->cdr); +  struct program *p = id_to_program(((char *)type->cdr)-(char *)0);    if(p)    {    if(n->token == F_ARROW)
4288:    }    sval.type = T_PROGRAM;    if ((obj_t->type != T_OBJECT) || -  (!(id = (ptrdiff_t)obj_t->cdr)) || +  (!(id = ((char *)obj_t->cdr)-(char *)0)) ||    (!(sval.u.program = id_to_program(id))) ||    (!(sub = get_type_of_svalue(&sval)))) {    if (res) {
4351:       case T_OBJECT:    { -  struct program *p = id_to_program((ptrdiff_t)type->cdr); +  struct program *p = id_to_program(((char *)type->cdr)-(char *)0);    if(!p) return 1;    return FIND_LFUN(p, lfun)!=-1;    }
4690:    {    INT32 i;    my_putchar(T_OBJECT); -  i = (INT32)(ptrdiff_t)t->car; +  i = (INT32)(((char *)t->car)-(char *)0);    my_putchar( i ); -  i = (INT32)(ptrdiff_t)t->cdr; +  i = (INT32)(((char *)t->cdr)-(char *)0);       if( i > 65535 ) i = 0; /* Not constant between recompilations */   
4707:    {    INT32 i;    my_putchar(T_INT); -  i = (INT32)(ptrdiff_t)t->car; +  i = (INT32)(((char *)t->car)-(char *)0);    my_putchar((i >> 24) & 0xff);    my_putchar((i >> 16) & 0xff);    my_putchar((i >> 8) & 0xff);    my_putchar(i & 0xff); -  i = (INT32)(ptrdiff_t)t->cdr; +  i = (INT32)(((char *)t->cdr)-(char *)0);    my_putchar((i >> 24) & 0xff);    my_putchar((i >> 16) & 0xff);    my_putchar((i >> 8) & 0xff);
4735:    case T_SCOPE:    case T_ASSIGN:    my_putchar(t->type); -  my_putchar('0' + (ptrdiff_t)t->car); +  my_putchar('0' + (((char *)t->car)-(char *)0));    t = t->cdr;    goto recurse;