pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:1:   /*   || 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.309 2007/06/29 17:06:05 grubba Exp $ + || $Id: pike_types.c,v 1.310 2007/07/02 10:49:10 grubba Exp $   */      #include "global.h"   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"
pike.git/src/pike_types.c:41:   #define NO_MAX_ARGS 4   #define NO_SHORTCUTS 8      /*    * Flags used by pike_types_le()    */   #define LE_WEAK_OBJECTS 1 /* Perform weaker checking of objects. */   #define LE_A_B_SWAPPED 2 /* Argument A and B have been swapped.    * Relevant for markers.    */ + #ifdef TYPE_GROUPING   #define LE_A_GROUPED 0/*4*/ /* Argument A has been grouped.    * Perform weaker checking for OR-nodes. */   #define LE_B_GROUPED 0/*8*/ /* Argument B has been grouped.    * Perform weaker checking for OR-nodes. */   #define LE_A_B_GROUPED 0/*12*/ /* Both the above two flags. */ -  + #endif      /*    * Flags used by low_get_first_arg_type()    */   #define FILTER_KEEP_VOID 1 /* Keep void during the filtering. */      /*    * Flags used as flag_method to mk_type()    */   #define PT_COPY_CAR 1
pike.git/src/pike_types.c:3764:    goto recurse;       case T_OR:    /* OK, if both of the parts are a subset,    * unless we are grouped, in which case    * only one part needs to be a subset.    */    if (a->car->type == T_VOID) {    /* Special case for T_VOID */    /* FIXME: Should probably be handled as T_ZERO. */ + #ifdef TYPE_GROUPING    if (flags & LE_A_GROUPED) return 1; -  + #endif    a = a->cdr;    goto recurse;    } else {    ret = low_pike_types_le(a->car, b, array_cnt, flags); -  + #ifdef TYPE_GROUPING    if (!ret == !(flags & LE_A_GROUPED)) return ret; -  + #else +  if (!ret) return 0; + #endif    if (a->cdr->type == T_VOID) {    /* Special case for T_VOID */    /* FIXME: Should probably be handled as T_ZERO. */    return 1;    } else {    a = a->cdr;    goto recurse;    }    }       case PIKE_T_RING:    a = a->car;    goto recurse;       case PIKE_T_SCOPE: -  + #ifdef TYPE_GROUPING    flags |= LE_A_GROUPED; -  + #endif    /* FALL_THROUGH */    case PIKE_T_NAME:    case PIKE_T_ATTRIBUTE:    a = a->cdr;    goto recurse;       case T_NOT:    if (b->type == T_NOT) {    struct pike_type *tmp = a->car;    a = b->car;    b = tmp;    array_cnt = -array_cnt; -  flags ^= LE_A_B_SWAPPED|LE_A_B_GROUPED; +  flags ^= LE_A_B_SWAPPED + #ifdef TYPE_GROUPING +  |LE_A_B_GROUPED + #endif +  ;    goto recurse;    }    /* Some common cases. */    switch(a->car->type) {    case T_NOT:    a = a->car->car;    goto recurse;    case T_MIXED:    a = zero_type_string;    goto recurse;    case T_ZERO:    case T_VOID:    a = mixed_type_string;    goto recurse;    }    if (low_pike_types_le(a->car, b, array_cnt, flags)) {    return 0;    }    /* FIXME: This is wrong... */    return !low_pike_types_le(b, a->car, -array_cnt, -  flags ^ (LE_A_B_SWAPPED|LE_A_B_GROUPED)); +  flags ^ (LE_A_B_SWAPPED + #ifdef TYPE_GROUPING +  |LE_A_B_GROUPED + #endif +  ));       case T_ASSIGN:    ret = low_pike_types_le(a->cdr, b, array_cnt, flags);    if(ret && (b->type != T_VOID))    {    int m = CAR_TO_INT(a);    struct pike_type *tmp;    int i;       type_stack_mark();
pike.git/src/pike_types.c:3904:    if(!ret) return 0;    b = b->cdr;    goto recurse;       case T_OR:    /* OK if a is a subset of either of the parts,    * unless we are grouped, in which case both    * parts need to be a subset.    */    ret = low_pike_types_le(a, b->car, array_cnt, flags); + #ifdef TYPE_GROUPING    if (!ret != !(flags & LE_B_GROUPED)) return ret; -  + #else +  if (ret) return ret; + #endif    b = b->cdr;    goto recurse;       case PIKE_T_RING:    b = b->car;    goto recurse;       case PIKE_T_SCOPE: -  + #ifdef TYPE_GROUPING    flags |= LE_B_GROUPED; -  + #endif    /* FALL_THROUGH */    case PIKE_T_NAME:    case PIKE_T_ATTRIBUTE:    b = b->cdr;    goto recurse;       case T_NOT:    /* Some common cases. */    switch(b->car->type) {    case T_NOT:
pike.git/src/pike_types.c:3939:    case T_ZERO:    case T_VOID:    b = mixed_type_string;    goto recurse;    }    if (low_pike_types_le(a, b->car, array_cnt, flags)) {    return 0;    }    /* FIXME: This is wrong... */    return !low_pike_types_le(b->car, a, -array_cnt, -  flags ^ (LE_A_B_SWAPPED|LE_A_B_GROUPED)); +  flags ^ (LE_A_B_SWAPPED + #ifdef TYPE_GROUPING +  |LE_A_B_GROUPED + #endif +  ));       case T_ASSIGN:    ret = low_pike_types_le(a, b->cdr, array_cnt, flags);    if(ret && (a->type != T_VOID))    {    int m = CAR_TO_INT(b);    struct pike_type *tmp;    int i;       type_stack_mark();
pike.git/src/pike_types.c:4154:    }       b_tmp = b->car;    if (b->type == T_FUNCTION)    {    b = b->cdr;    }       if (a_tmp->type != T_VOID) {    if (!low_pike_types_le(b_tmp, a_tmp, 0, -  flags ^ (LE_A_B_SWAPPED|LE_A_B_GROUPED))) { +  flags ^ (LE_A_B_SWAPPED + #ifdef TYPE_GROUPING +  |LE_A_B_GROUPED + #endif +  ))) {    return 0;    }    }    }    /* FALL_THROUGH */    case TWOT(T_MANY, T_MANY):    /* check the 'many' type */    if ((a->car->type != T_VOID) && (b->car->type != T_VOID)) {    if (!low_pike_types_le(b->car, a->car, 0, -  flags ^ (LE_A_B_SWAPPED|LE_A_B_GROUPED))) { +  flags ^ (LE_A_B_SWAPPED + #ifdef TYPE_GROUPING +  |LE_A_B_GROUPED + #endif +  ))) {    return 0;    }    }       a = a->cdr;    b = b->cdr;       /* check the returntype */    /* FIXME: Check array_cnt */    if ((b->type != T_VOID) && (a->type != T_VOID)) {