pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: pike_types.c,v 1.56 1999/06/03 01:39:36 hubbe Exp $"); + RCSID("$Id: pike_types.c,v 1.57 1999/10/25 10:17:47 hubbe Exp $");   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"   #include "constants.h"   #include "object.h"   #include "multiset.h"
pike.git/src/pike_types.c:96: Inside #if defined(PIKE_DEBUG)
   if(type_length(s->str) != s->len)    {    stupid_describe_type(s->str,s->len);    fatal("Length of type is wrong. (should be %d, is %d)\n",type_length(s->str),s->len);    }   }   #endif      void init_types(void)   { - #define CONSTTYPE(X) make_shared_binary_string(X,CONSTANT_STRLEN(X)) +     string_type_string = CONSTTYPE(tString);    int_type_string = CONSTTYPE(tInt);    object_type_string = CONSTTYPE(tObj);    program_type_string = CONSTTYPE(tPrg);    float_type_string = CONSTTYPE(tFloat);    mixed_type_string=CONSTTYPE(tMix);    array_type_string=CONSTTYPE(tArray);    multiset_type_string=CONSTTYPE(tMultiset);    mapping_type_string=CONSTTYPE(tMapping);    function_type_string=CONSTTYPE(tFunction);
pike.git/src/pike_types.c:1765:    INT32 ret,tmp=max_correct_args;    check_type_string(type);    clear_markers();    type=check_call(function_type_string, type);    if(type) free_string(type);    ret=max_correct_args;    max_correct_args=tmp;    return tmp;   }    +  + struct pike_string *zzap_function_return(char *a, INT32 id) + { +  switch(EXTRACT_UCHAR(a)) +  { +  case T_OR: +  { +  struct pike_string *ar, *br, *ret=0; +  a++; +  ar=zzap_function_return(a,id); +  br=zzap_function_return(a+type_length(a),id); +  if(ar && br) ret=or_pike_types(ar,br); +  if(ar) free_string(ar); +  if(br) free_string(br); +  return ret; +  } +  +  case T_FUNCTION: +  type_stack_mark(); +  push_type_int(id); +  push_type(1); +  push_type(T_OBJECT); +  +  type_stack_mark(); +  a++; +  while(EXTRACT_UCHAR(a)!=T_MANY) +  { +  type_stack_mark(); +  push_unfinished_type(a); +  type_stack_reverse(); +  a+=type_length(a); +  } +  a++; +  push_type(T_MANY); +  type_stack_mark(); +  push_unfinished_type(a); +  type_stack_reverse(); +  type_stack_reverse(); +  push_type(T_FUNCTION); +  return pop_unfinished_type(); +  } + } +    struct pike_string *get_type_of_svalue(struct svalue *s)   {    struct pike_string *ret;    switch(s->type)    {    case T_FUNCTION:    if(s->subtype == FUNCTION_BUILTIN)    {    ret=s->u.efun->type;    }else{
pike.git/src/pike_types.c:1811:    type_stack_mark();    push_type(T_MIXED);    push_type(T_MIXED);    push_type(T_MAPPING);    return pop_unfinished_type();       case T_OBJECT:    type_stack_mark();    if(s->u.object->prog)    { + #ifdef AUTO_BIGNUM +  if(is_bignum_object(s->u.object)) +  { +  push_type_int(MAX_INT32); +  push_type_int(MIN_INT32); +  push_type(T_INT); +  } +  else + #endif +  {    push_type_int(s->u.object->prog->id);    push_type(1); -  +  push_type(T_OBJECT); +  }    }else{    push_type_int(0);    push_type(0); -  } +     push_type(T_OBJECT); -  +  }    return pop_unfinished_type();       case T_INT:    if(s->u.integer)    {    type_stack_mark(); -  /* Fixme, check that the integer is in range of MIN_INT32 .. MAX_INT32!*/ +  /* Fixme, check that the integer is in range of MIN_INT32 .. MAX_INT32! +  */    push_type_int(s->u.integer);    push_type_int(s->u.integer);    push_type(T_INT);    return pop_unfinished_type();    }else{    ret=mixed_type_string;    }    reference_shared_string(ret);    return ret;       case T_PROGRAM:    {    char *a; -  +  struct pike_string *tmp;    int id=FIND_LFUN(s->u.program,LFUN_CREATE);    if(id>=0)    {    a=ID_FROM_INT(s->u.program, id)->type->str;    }else{    a=function_type_string->str;    } -  if(EXTRACT_UCHAR(a)==T_FUNCTION) -  { -  type_stack_mark(); -  push_type_int(s->u.program->id); -  push_type(1); -  push_type(T_OBJECT); -  -  type_stack_mark(); -  a++; -  while(EXTRACT_UCHAR(a)!=T_MANY) -  { -  type_stack_mark(); -  push_unfinished_type(a); -  type_stack_reverse(); -  a+=type_length(a); +  if((tmp=zzap_function_return(a, s->u.program->id))) +  return tmp;    } -  a++; -  push_type(T_MANY); -  type_stack_mark(); -  push_unfinished_type(a); -  type_stack_reverse(); -  type_stack_reverse(); -  push_type(T_FUNCTION); -  return pop_unfinished_type(); -  } -  } +        default:    type_stack_mark();    push_type(s->type);    return pop_unfinished_type();    }   }         char *get_name_of_type(int t)