📄 slang.h
字号:
#ifndef DAVIS_SLANG_H_#define DAVIS_SLANG_H_/* -*- mode: C; mode: fold; -*- *//* Copyright (c) 1992, 1999, 2001, 2002, 2003 John E. Davis * This file is part of the S-Lang library. * * You may distribute under the terms of either the GNU General Public * License or the Perl Artistic License. */#define SLANG_VERSION 10409#define SLANG_VERSION_STRING "1.4.9"/*{{{ System Dependent Macros and Typedefs */#if defined(__WATCOMC__) && defined(DOS)# ifndef __MSDOS__# define __MSDOS__# endif# ifndef DOS386# define DOS386# endif# ifndef IBMPC_SYSTEM# define IBMPC_SYSTEM# endif#endif /* __watcomc__ */#if defined(unix) || defined(__unix)# ifndef __unix__# define __unix__ 1# endif#endif#if !defined(__GO32__)# ifdef __unix__# define REAL_UNIX_SYSTEM# endif#endif/* Set of the various defines for pc systems. This includes OS/2 */#ifdef __GO32__# ifndef __DJGPP__# define __DJGPP__ 1# endif# ifndef IBMPC_SYSTEM# define IBMPC_SYSTEM# endif#endif#ifdef __BORLANDC__# ifndef IBMPC_SYSTEM# define IBMPC_SYSTEM# endif#endif#ifdef __MSDOS__# ifndef IBMPC_SYSTEM# define IBMPC_SYSTEM# endif#endif#if defined(OS2) || defined(__os2__)# ifndef IBMPC_SYSTEM# define IBMPC_SYSTEM# endif# ifndef __os2__# define __os2__# endif#endif#if defined(__NT__) || defined(__MINGW32__) /* || defined(__CYGWIN32__) */# ifndef IBMPC_SYSTEM# define IBMPC_SYSTEM# endif#endif#if defined(IBMPC_SYSTEM) || defined(VMS)# ifdef REAL_UNIX_SYSTEM# undef REAL_UNIX_SYSTEM# endif#endif#ifdef __cplusplusextern "C" {#endif#if 0}#endif#include <stdio.h>#include <stdarg.h>#if defined(__STDC__) || defined(__BORLANDC__) || defined(__cplusplus)# include <stddef.h> /* for offsetof */#endif/* ---------------------------- Generic Macros ----------------------------- *//* __SC__ is defined for Symantec C++ DOS386 is defined for -mx memory model, 32 bit DOS extender. */#if defined(__SC__) && !defined(DOS386)# include <dos.h>#endif#if defined(__BORLANDC__)# include <alloc.h>#endif#ifdef __GNUC__# define _SLATTRIBUTE_(x) __attribute__ (x)#else# define _SLATTRIBUTE_(x)#endif#define _SLATTRIBUTE_PRINTF(a,b) _SLATTRIBUTE_((format(printf,a,b))) #if defined (__cplusplus) || defined(__STDC__) || defined(IBMPC_SYSTEM)typedef void *VOID_STAR;#define SLCONST const#elsetypedef unsigned char *VOID_STAR;#define SLCONST#endiftypedef int (*FVOID_STAR)(void);#if defined(__MSDOS__) && defined(__BORLANDC__)# define SLFREE(buf) farfree((void far *)(buf))# define SLMALLOC(x) farmalloc((unsigned long) (x))# define SLREALLOC(buf, n) farrealloc((void far *) (buf), (unsigned long) (n))# define SLCALLOC(n, m) farcalloc((unsigned long) (n), (unsigned long) (m))#else# if defined(VMS) && !defined(__DECC)# define SLFREE VAXC$FREE_OPT# define SLMALLOC VAXC$MALLOC_OPT# define SLREALLOC VAXC$REALLOC_OPT# define SLCALLOC VAXC$CALLOC_OPT# else# define SLFREE(x) free((char *)(x))# define SLMALLOC malloc# define SLREALLOC realloc# define SLCALLOC calloc# endif#endif extern char *SLdebug_malloc (unsigned long); extern char *SLdebug_calloc (unsigned long, unsigned long); extern char *SLdebug_realloc (char *, unsigned long); extern void SLdebug_free (char *); extern void SLmalloc_dump_statistics (void); extern char *SLstrcpy(register char *, register char *); extern int SLstrcmp(register char *, register char *); extern char *SLstrncpy(char *, register char *, register int); extern void SLmemset (char *, char, int); extern char *SLmemchr (register char *, register char, register int); extern char *SLmemcpy (char *, char *, int); extern int SLmemcmp (char *, char *, int);/*}}}*//*{{{ Interpreter Typedefs */typedef unsigned char SLtype; /* This will be unsigned int in V2 */typedef struct _SLang_Name_Type{ char *name; struct _SLang_Name_Type *next; char name_type; /* These values must be less than 0x10 because they map directly * to byte codes. See _slang.h. */#define SLANG_LVARIABLE 0x01#define SLANG_GVARIABLE 0x02#define SLANG_IVARIABLE 0x03 /* intrinsic variables */ /* Note!!! For Macro MAKE_VARIABLE below to work, SLANG_IVARIABLE Must be 1 less than SLANG_RVARIABLE!!! */#define SLANG_RVARIABLE 0x04 /* read only variable */#define SLANG_INTRINSIC 0x05#define SLANG_FUNCTION 0x06#define SLANG_MATH_UNARY 0x07#define SLANG_APP_UNARY 0x08#define SLANG_ICONSTANT 0x09#define SLANG_DCONSTANT 0x0A#define SLANG_PVARIABLE 0x0B /* private */#define SLANG_PFUNCTION 0x0C /* private */ /* Rest of fields depend on name type */}SLang_Name_Type;typedef struct{ char *name; struct _SLang_Name_Type *next; /* this is for the hash table */ char name_type; FVOID_STAR i_fun; /* address of object */ /* Do not change this without modifying slang.c:execute_intrinsic_fun */#define SLANG_MAX_INTRIN_ARGS 7 SLtype arg_types [SLANG_MAX_INTRIN_ARGS]; unsigned char num_args; SLtype return_type;}SLang_Intrin_Fun_Type;typedef struct{ char *name; SLang_Name_Type *next; char name_type; VOID_STAR addr; SLtype type;}SLang_Intrin_Var_Type;typedef struct{ char *name; SLang_Name_Type *next; char name_type; int unary_op;}SLang_App_Unary_Type;typedef struct{ char *name; SLang_Name_Type *next; char name_type; int unary_op;}SLang_Math_Unary_Type;typedef struct{ char *name; SLang_Name_Type *next; char name_type; int i;}SLang_IConstant_Type;typedef struct{ char *name; SLang_Name_Type *next; char name_type; double d;}SLang_DConstant_Type;typedef struct{ char *field_name; /* gets replaced by slstring at run-time */ unsigned int offset; SLtype type; unsigned char read_only;}SLang_IStruct_Field_Type;typedef SLCONST struct{ char *field_name; unsigned int offset; SLtype type; unsigned char read_only;}SLang_CStruct_Field_Type;extern int SLadd_intrin_fun_table (SLang_Intrin_Fun_Type *, char *);extern int SLadd_intrin_var_table (SLang_Intrin_Var_Type *, char *);extern int SLadd_app_unary_table (SLang_App_Unary_Type *, char *);extern int SLadd_math_unary_table (SLang_Math_Unary_Type *, char *);extern int SLadd_iconstant_table (SLang_IConstant_Type *, char *);extern int SLadd_dconstant_table (SLang_DConstant_Type *, char *);extern int SLadd_istruct_table (SLang_IStruct_Field_Type *, VOID_STAR, char *);typedef struct _SLang_NameSpace_Type SLang_NameSpace_Type;extern int SLns_add_intrin_fun_table (SLang_NameSpace_Type *, SLang_Intrin_Fun_Type *, char *);extern int SLns_add_intrin_var_table (SLang_NameSpace_Type *, SLang_Intrin_Var_Type *, char *);extern int SLns_add_app_unary_table (SLang_NameSpace_Type *, SLang_App_Unary_Type *, char *);extern int SLns_add_math_unary_table (SLang_NameSpace_Type *, SLang_Math_Unary_Type *, char *);extern int SLns_add_iconstant_table (SLang_NameSpace_Type *, SLang_IConstant_Type *, char *);extern int SLns_add_dconstant_table (SLang_NameSpace_Type *, SLang_DConstant_Type *, char *);extern int SLns_add_istruct_table (SLang_NameSpace_Type *, SLang_IStruct_Field_Type *, VOID_STAR, char *);extern SLang_NameSpace_Type *SLns_create_namespace (char *);extern void SLns_delete_namespace (SLang_NameSpace_Type *);extern int SLns_load_file (char *, char *);extern int SLns_load_string (char *, char *);extern int (*SLns_Load_File_Hook) (char *, char *);int SLang_load_file_verbose (int); /* if non-zero, display file loading messages */typedef struct SLang_Load_Type{ int type; VOID_STAR client_data; /* Pointer to data that client needs for loading */ int auto_declare_globals; /* if non-zero, undefined global variables are declared as static */ char *(*read)(struct SLang_Load_Type *); /* function to call to read next line from obj. */ unsigned int line_num; /* Number of lines read, used for error reporting */ int parse_level; /* 0 if at top level of parsing */ char *name; /* Name of this object, e.g., filename. This name should be unique because * it alone determines the name space for static objects associated with * the compilable unit. */ char *namespace_name; unsigned long reserved[3]; /* For future expansion */} SLang_Load_Type;extern SLang_Load_Type *SLallocate_load_type (char *);extern void SLdeallocate_load_type (SLang_Load_Type *);extern SLang_Load_Type *SLns_allocate_load_type (char *, char *); /* Returns SLang_Error upon failure */extern int SLang_load_object (SLang_Load_Type *);extern int (*SLang_Load_File_Hook)(char *);extern int (*SLang_Auto_Declare_Var_Hook) (char *);extern int SLang_generate_debug_info (int);#if defined(ultrix) && !defined(__GNUC__)# ifndef NO_PROTOTYPES# define NO_PROTOTYPES# endif#endif#ifndef NO_PROTOTYPES# define _PROTO(x) x#else# define _PROTO(x) ()#endiftypedef struct SL_OOBinary_Type{ SLtype data_type; /* partner type for binary op */ int (*binary_function)_PROTO((int, SLtype, VOID_STAR, unsigned int, SLtype, VOID_STAR, unsigned int, VOID_STAR)); int (*binary_result) _PROTO((int, SLtype, SLtype, SLtype *)); struct SL_OOBinary_Type *next;}SL_OOBinary_Type;typedef struct _SL_Typecast_Type{ SLtype data_type; /* to_type */ int allow_implicit; int (*typecast)_PROTO((SLtype, VOID_STAR, unsigned int, SLtype, VOID_STAR)); struct _SL_Typecast_Type *next;}SL_Typecast_Type;typedef struct _SLang_Struct_Type SLang_Struct_Type;typedef struct _SLang_Foreach_Context_Type SLang_Foreach_Context_Type;#if 0#if defined(SL_APP_WANTS_FOREACH)typedef struct _SLang_Foreach_Context_Type SLang_Foreach_Context_Type;/* It is up to the application to define struct _SLang_Foreach_Context_Type */#elsetypedef int SLang_Foreach_Context_Type;#endif#endiftypedef struct{ unsigned char cl_class_type;#define SLANG_CLASS_TYPE_MMT 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -