pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:86:    t+=type_length(t);       case T_ARRAY:    case T_MULTISET:    case T_NOT:    t+=type_length(t);       case T_INT:    case T_FLOAT:    case T_STRING: -  case T_OBJECT: +     case T_PROGRAM:    case T_MIXED:    case T_VOID:    case T_UNKNOWN:    break; -  +  +  +  case T_OBJECT: +  t+=sizeof(INT32); +  break;    }    return t-q;   }         #define STACK_SIZE 100000   static unsigned char type_stack[STACK_SIZE];   static unsigned char *type_stackp=type_stack;   static unsigned char *mark_stack[STACK_SIZE/4];   static unsigned char **mark_stackp=mark_stack;
pike.git/src/pike_types.c:154:   }      void push_type(unsigned char tmp)   {    *type_stackp=tmp;    type_stackp++;    if(type_stackp > type_stack + sizeof(type_stack))    yyerror("Type stack overflow.");   }    + void push_type_int(unsigned INT32 i) + { +  if(type_stackp + sizeof(i)> type_stack + sizeof(type_stack)) +  yyerror("Type stack overflow."); +  +  type_stack_mark(); +  MEMCPY(type_stackp, &i, sizeof(i)); +  type_stackp+=sizeof(i); +  type_stack_reverse(); + } +    void push_unfinished_type(char *s)   {    int e;    e=type_length(s);    for(e--;e>=0;e--) push_type(s[e]);   }      void push_finished_type(struct pike_string *type)   {    int e;
pike.git/src/pike_types.c:210:    for(len=0;isidchar(s[0][len]);len++)    {    if(len>=sizeof(buf)) error("Buffer overflow in parse_type\n");    buf[len] = s[0][len];    }    buf[len]=0;    *s += len;       if(!strcmp(buf,"int")) push_type(T_INT);    else if(!strcmp(buf,"float")) push_type(T_FLOAT); -  else if(!strcmp(buf,"object")) push_type(T_OBJECT); +  else if(!strcmp(buf,"object")) +  { +  push_type_int(0); +  push_type(T_OBJECT); +  }    else if(!strcmp(buf,"program")) push_type(T_PROGRAM);    else if(!strcmp(buf,"string")) push_type(T_STRING);    else if(!strcmp(buf,"void")) push_type(T_VOID);    else if(!strcmp(buf,"mixed")) push_type(T_MIXED);    else if(!strcmp(buf,"unknown")) push_type(T_UNKNOWN);    else if(!strcmp(buf,"function"))    {    while(ISSPACE(**s)) ++*s;    if(**s == '(')    {
pike.git/src/pike_types.c:432: Inside #if defined(DEBUG)
   INT32 e;    for(e=0;e<len;e++)    {    if(e) printf(" ");    switch(EXTRACT_UCHAR(a+e))    {    case T_INT: printf("int"); break;    case T_FLOAT: printf("float"); break;    case T_STRING: printf("string"); break;    case T_PROGRAM: printf("program"); break; -  case T_OBJECT: printf("object"); break; +  case T_OBJECT: +  printf("object(%ld)",(long)EXTRACT_INT(a+e+1)); +  e+=sizeof(INT32); +  break;    case T_FUNCTION: printf("function"); break;    case T_ARRAY: printf("array"); break;    case T_MAPPING: printf("mapping"); break;    case T_MULTISET: printf("multiset"); break;       case T_UNKNOWN: printf("unknown"); break;    case T_MANY: printf("many"); break;    case T_OR: printf("or"); break;    case T_AND: printf("and"); break;    case T_NOT: printf("not"); break;
pike.git/src/pike_types.c:468:   char *low_describe_type(char *t)   {    switch(EXTRACT_UCHAR(t++))    {    case T_VOID: my_strcat("void"); break;    case T_MIXED: my_strcat("mixed"); break;    case T_UNKNOWN: my_strcat("unknown"); break;    case T_INT: my_strcat("int"); break;    case T_FLOAT: my_strcat("float"); break;    case T_PROGRAM: my_strcat("program"); break; -  case T_OBJECT: my_strcat("object"); break; +  case T_OBJECT: +  my_strcat("object"); +  /* Prog id */ +  break;    case T_STRING: my_strcat("string"); break;       case T_FUNCTION:    {    int s;    my_strcat("function(");    s=0;    while(EXTRACT_UCHAR(t) != T_MANY)    {    if(s++) my_strcat(", ");
pike.git/src/pike_types.c:647:       case T_NOT:    if(low_match_types(a,b+1, flags | A_EXACT))    return 0;    return a;    }       /* 'mixed' matches anything */    if(EXTRACT_UCHAR(a) == T_MIXED && !(flags & A_EXACT)) return a;    if(EXTRACT_UCHAR(b) == T_MIXED && !(flags & B_EXACT)) return a; +  +  /* Special case (tm) */ +  if(EXTRACT_UCHAR(a) == T_PROGRAM && EXTRACT_UCHAR(b)==T_FUNCTION) +  { +  return a; +  } +     if(EXTRACT_UCHAR(a) != EXTRACT_UCHAR(b)) return 0;       ret=a;    switch(EXTRACT_UCHAR(a))    {    case T_FUNCTION:    a++;    b++;    while(EXTRACT_UCHAR(a)!=T_MANY || EXTRACT_UCHAR(b)!=T_MANY)    {
pike.git/src/pike_types.c:695:    }    /* check the returntype */    if(!low_match_types(a,b,flags)) return 0;    break;       case T_MAPPING:    if(!low_match_types(++a,++b,flags)) return 0;    if(!low_match_types(a+type_length(a),b+type_length(b),flags)) return 0;    break;    +  case T_OBJECT: +  a++; +  b++; +  if(!EXTRACT_INT(a) || !EXTRACT_INT(b)) break; +  if(EXTRACT_INT(a) != EXTRACT_INT(b)) return 0; +  break; +     case T_MULTISET:    case T_ARRAY:    if(!low_match_types(++a,++b,flags)) return 0;       case T_INT:    case T_FLOAT:    case T_STRING: -  case T_OBJECT: +     case T_PROGRAM:    case T_VOID:    case T_MIXED:    break;       default:    fatal("error in type string.\n");    }    return ret;   }
pike.git/src/pike_types.c:795:    switch(EXTRACT_UCHAR(a))    {    case T_FUNCTION:    a++;    while(EXTRACT_UCHAR(a)!=T_MANY) a+=type_length(a);    a++;    a+=type_length(a);    push_unfinished_type(a);    return 1;    +  case T_PROGRAM: +  push_type_int(0); +  push_type(T_OBJECT); +  return 1; +     default:    push_type(T_MIXED);    return 1;    }    }    return 0;   }         int match_types(struct pike_string *a,struct pike_string *b)