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.17 1997/03/07 05:21:46 hubbe Exp $"); + RCSID("$Id: pike_types.c,v 1.18 1997/03/08 12:54:08 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:19:   #include "macros.h"   #include "error.h"   #include "las.h"   #include "language.h"      int max_correct_args;      static void internal_parse_type(char **s);   static int type_length(char *t);    + #define TWOT(X,Y) (((X) << 8)+(Y)) + #define EXTRACT_TWOT(X,Y) TWOT(EXTRACT_UCHAR(X), EXTRACT_UCHAR(Y)) +    /*    * basic types are represented by just their value in a string    * basic type are string, int, float, object and program    * arrays are coded like by the value T_ARRAY followed by the    * 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>    * multiset works similarly to arrays.
pike.git/src/pike_types.c:692:    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) */ -  -  /* Handle cloning with prog() */ -  if(EXTRACT_UCHAR(a) == T_PROGRAM && -  EXTRACT_UCHAR(b)==T_FUNCTION) +  /* Special cases (tm) */ +  switch(EXTRACT_TWOT(a,b))    { -  +  case TWOT(T_PROGRAM, T_FUNCTION): +  case TWOT(T_FUNCTION, T_PROGRAM):    return a; -  } -  -  /* Handle the `() operator */ -  if(EXTRACT_UCHAR(a) == T_OBJECT && -  EXTRACT_UCHAR(b)==T_FUNCTION) +  case TWOT(T_OBJECT, T_FUNCTION):    {    struct program *p;    if(p=id_to_program(EXTRACT_INT(a+1)))    {    int i=p->lfuns[LFUN_CALL];    if(i == -1) return 0;    return low_match_types(ID_FROM_INT(p, i)->type->str, b, flags);    }    return a;    }    -  +  case TWOT(T_FUNCTION, T_OBJECT): +  { +  struct program *p; +  if(p=id_to_program(EXTRACT_INT(b+1))) +  { +  int i=p->lfuns[LFUN_CALL]; +  if(i == -1) return 0; +  return low_match_types(a, ID_FROM_INT(p, i)->type->str, flags); +  } +  return a; +  } +  } +     if(EXTRACT_UCHAR(a) != EXTRACT_UCHAR(b)) return 0;       ret=a;    switch(EXTRACT_UCHAR(a))    {    case T_FUNCTION:    correct_args=0;    a++;    b++;    while(EXTRACT_UCHAR(a)!=T_MANY || EXTRACT_UCHAR(b)!=T_MANY)
pike.git/src/pike_types.c:1142:    case T_INT:    if(s->u.integer)    {    ret=int_type_string;    }else{    ret=mixed_type_string;    }    reference_shared_string(ret);    return ret;    +  case T_PROGRAM: +  { +  char *a; +  int id=s->u.program->lfuns[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(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(); +  } +  } +     default:    type_stack_mark();    push_type(s->type);    return pop_unfinished_type();    }   }         char *get_name_of_type(int t)   {