pike.git / src / lpc_types.c

version» Context lines:

pike.git/src/lpc_types.c:25:    * data type, if the type is not known it is T_MIXED, ie:    * T_ARRAY <data type>    * mappings are followed by two arguments, the first is the type    * for the indices, and the second is the type of the data, ie:    * T_MAPPING <indice type> <data type>    * list works similarly to arrays.    * functions are _very_ special:    * they are coded like this:    * T_FUNCTION <arg type> <arg type> ... <arg type> T_MANY <arg type> <return type>    * note that the type after T_MANY can be T_VOID -  * T_TRUE matches anything +     * T_MIXED matches anything except T_VOID    * T_UNKNOWN only matches T_MIXED and T_UNKNOWN    */      struct lpc_string *string_type_string;   struct lpc_string *int_type_string;   struct lpc_string *float_type_string;   struct lpc_string *function_type_string;   struct lpc_string *object_type_string;   struct lpc_string *program_type_string;
pike.git/src/lpc_types.c:87:    case T_LIST:    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_TRUE: +     case T_UNKNOWN:    break;    }    return t-q;   }      static void internal_parse_type(char **s)   {    char buf[80];    unsigned int len;
pike.git/src/lpc_types.c:166:    pop_stack_mark();    }    ++*s;    type_stack_mark();    internal_parse_type(s); /* return type */    type_stack_reverse();    if(**s != ')') error("Missing ')' in function type.\n");    ++*s;    type_stack_reverse();    }else{ -  push_type(T_TRUE); +     push_type(T_MIXED); -  +  push_type(T_MIXED);    push_type(T_MANY);    }    push_type(T_FUNCTION);    }    else if(!strcmp(buf,"mapping"))    {    while(isspace(**s)) ++*s;    if(**s == '(')    {    ++*s;
pike.git/src/lpc_types.c:273: Inside #if defined(DEBUG)
   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_FUNCTION: printf("function"); break;    case T_ARRAY: printf("array"); break;    case T_MAPPING: printf("mapping"); break;    case T_LIST: printf("list"); break;       case T_UNKNOWN: printf("unknown"); break; -  case T_TRUE: printf("true"); break; +     case T_MANY: printf("many"); break;    case T_OR: printf("or"); break;    case T_VOID: printf("void"); break;    case T_MIXED: printf("mixed"); break;       default: printf("%d",EXTRACT_UCHAR(a+e)); break;    }    }    printf("\n");   } -  +  + void simple_describe_type(struct lpc_string *s) + { +  stupid_describe_type(s->str,s->len); + }   #endif      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_TRUE: -  my_strcat("true"); -  break; -  +     case T_UNKNOWN:    my_strcat("unknown");    break;       case T_INT:    my_strcat("int");    break;       case T_FLOAT:    my_strcat("float");
pike.git/src/lpc_types.c:388:      TYPE_T compile_type_to_runtime_type(struct lpc_string *s)   {    char *t;    t=s->str;       switch(EXTRACT_UCHAR(t))    {    case T_OR:    case T_MANY: -  case T_TRUE: +     case T_UNKNOWN:    return T_MIXED;       default:    return EXTRACT_UCHAR(t);    }   }      /*    * match two type strings, return zero if they don't match, and return
pike.git/src/lpc_types.c:424:       if(EXTRACT_UCHAR(b) == T_OR)    {    b++;    ret=low_match_types(a,b);    if(ret) return ret;    b+=type_length(b);    return low_match_types(a,b);    }    -  if(EXTRACT_UCHAR(a)==T_TRUE) return a; -  if(EXTRACT_UCHAR(b)==T_TRUE) return a; -  -  /* 'mixed' matches anything except 'void' */ -  if(EXTRACT_UCHAR(a) == T_MIXED && EXTRACT_UCHAR(b) != T_VOID) return a; -  if(EXTRACT_UCHAR(b) == T_MIXED && EXTRACT_UCHAR(a) != T_VOID) return a; +  /* 'mixed' matches anything */ +  if(EXTRACT_UCHAR(a) == T_MIXED) return a; +  if(EXTRACT_UCHAR(b) == T_MIXED) 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/lpc_types.c:451:    if(EXTRACT_UCHAR(a)==T_MANY)    {    a_tmp=a+1;    }else{    a_tmp=a;    a+=type_length(a);    }       if(EXTRACT_UCHAR(b)==T_MANY)    { -  b_tmp=a+1; +  b_tmp=b+1;    }else{    b_tmp=b;    b+=type_length(b);    }       if(!low_match_types(a_tmp, b_tmp)) return 0;    }    /* check the 'many' type */    a++;    b++; -  if(EXTRACT_UCHAR(b)==T_VOID) +  if(EXTRACT_UCHAR(b)==T_VOID || EXTRACT_UCHAR(a)==T_VOID)    { -  b++; +     a+=type_length(a); -  +  b+=type_length(b);    }else{    if(!low_match_types(a,b)) return 0;    }    /* check the returntype */    if(!low_match_types(a,b)) return 0;    break;       case T_MAPPING:    if(!low_match_types(++a,++b)) return 0;    if(!low_match_types(a+type_length(a),b+type_length(b))) return 0;
pike.git/src/lpc_types.c:489:    case T_ARRAY:    if(!low_match_types(++a,++b)) return 0;       case T_INT:    case T_FLOAT:    case T_STRING:    case T_OBJECT:    case T_PROGRAM:    case T_VOID:    case T_MIXED: -  case T_TRUE: +     break;    -  +     default:    fatal("error in type string.\n");    }    return ret;   }      /*    * Return the return type from a function call.    */   static int low_get_return_type(char *a,char *b)