C:/Users/Dennis/src/lang/Life_start/Life/life-1.02/source/sys.h

Go to the documentation of this file.
00001 /* Copyright by Denys Duchier, Dec 1994
00002    Simon Fraser University
00003 
00004    All new system utilities and extensions to Wild LIFE 1.02
00005    are implemented using the new call_primitive interface
00006    */
00007 /*      $Id: sys.h,v 1.2 1995/07/27 20:16:30 duchier Exp $      */
00008 #ifndef _LIFE_SYS_H_
00009 #define _LIFE_SYS_H_
00010 #include "extern.h"
00011 
00012 /********************************************************************
00013   When calling a primitive, you always need to process the arguments
00014   according to the same protocol.  The call_primitive procedure does
00015   all this work for you.  It should be called as follows:
00016 
00017                        call_primitive(f,n,args,info)
00018 
00019   where f is the primitive implementing the actual functionality, n
00020   is the number of arguments described in args, and args is an array
00021   of argument descriptions, and info is a pointer to extra info to be
00022   passed to f.  Each argument is described by a psi_arg structure
00023   whose 1st field is a string naming the feature, 2nd field is a type
00024   restriction, and 3rd field describes processing options, e.g.:
00025 
00026                   { "1" , quoted_string , REQUIRED }
00027 
00028   describes a required argument on feature 1, that must be a string.
00029   The 3rd field is a mask of boolean flags and is constructed by
00030   ORing some constants chosen from the set:
00031 
00032   OPTIONAL      for an optional argument
00033   REQUIRED      for a required argument (i.e. residuate on it if not
00034                 present
00035   UNEVALED      if the argument should not be evaluated
00036   JUSTFAIL      to just fail is the argument does not meet its type
00037                 restriction
00038   POLYTYPE      sometimes you want to permit several particular sorts
00039                 in that case the 2nd psi_arg field is interpreted as
00040                 a pointer to a NULL terminated array of ptr_definitions
00041   MANDATORY     like REQUIRED, but it is an error for it not to be
00042                 present; don't residuate.  This is useful for
00043                 predicates since it doesn't make sense for them to
00044                 residuate.
00045   NOVALUE       no value required for this argument.
00046 
00047   The primitive must be defined to take the following arguments
00048                 f(argl,result,funct[,info])
00049   where argl is an array containing the arguments obtained by call_
00050   primitive, result is the result in case we are implementing a
00051   function, and info (optional) is extra information, typically a
00052   pointer to a structure.
00053   *******************************************************************/
00054 
00055 #define OPTIONAL  0
00056 #define REQUIRED  1
00057 #define UNEVALED  (1<<1)
00058 #define JUSTFAIL  (1<<2)
00059 #define POLYTYPE  (1<<3)
00060 #define MANDATORY (1<<4)
00061 #define NOVALUE   (1<<5)
00062 
00063 typedef struct {
00064   char *feature;
00065   ptr_definition type;
00066   unsigned int options;
00067 } psi_arg;
00068 
00069 #define SETARG(args,i,the_feature,the_type,the_options) \
00070   { int j = i; \
00071     args[j].feature = the_feature; \
00072     args[j].type    = the_type; \
00073     args[j].options = the_options; }
00074 
00075 #define NARGS(args) (sizeof(args)/sizeof(psi_arg))
00076 
00077 extern long call_primitive();
00078 
00079 #endif /* _LIFE_SYS_H_ */

Generated on Sat Jan 26 08:48:07 2008 for WildLife by  doxygen 1.5.4