script.h

来自「类PASCAL语言的编译器,LINUX环境的,我没试过是否正确.」· C头文件 代码 · 共 1,385 行 · 第 1/4 页

H
1,385
字号
  uchar *name; /* Identifier. Must be absolutely unique and not more than                  MAX_COMMAND_LEN characters long. */  union {    struct ExternalFunction external;    struct InsideFunction inside;    struct fplVariable variable;  } data;    unsigned long flags; /* See below! */  uchar *file;	/* file name of the file in which we find this identifier */    struct Identifier *func; /* It exists only under this function. Pointer might			      be NULL if in no function! */  long level; /* In which level this exists.		 Variables exist in all levels below (with a higher number)		 where it was declared. Two declarations using the same		 name in the same level is not allowed!		 LONG_MAX if global! */    unsigned long hash; /* Hash value. To get the proper hash table entry for			 this, use [hash%HASH_TABLE_SIZE] */    /* Bidirectional links to keep a hash value sorted order among     functions using the same hash table entry: */  struct Identifier *prev;  struct Identifier *next;};/****** Identifier.flags defines:  ******//* Data type */#define FPL_STRING_VARIABLE   (1<<0)  /* string variable */#define FPL_INT_VARIABLE      (1<<1)  /* integer variable */#define FPL_REFERENCE         (1<<2)  /* identifier reference */#define FPL_INTERNAL_FUNCTION (1<<3)  /* internal FPL function */#define FPL_EXTERNAL_FUNCTION (1<<4)  /* user supplied external function */#define FPL_INSIDE_FUNCTION   (1<<5)  /* inside function in any program */#define FPL_KEYWORD	      (1<<6)  /* this is a keyword identifier! */#define FPL_KEYWORD_DECLARE   (1<<7)  /* declaring keyword */#define FPL_INSIDE_NOTFOUND   (1<<8)  /* This inside function has not been					 discovered yet. The position the					 data points to is the search start					 position. */#define FPL_IGNORE            (1<<9) /* Read this and then drop it! *//* Data status */#define FPL_READONLY          (1<<10) /* const variable! */#define FPL_EXTERNAL_VARIABLE (1<<11) /* external variable! new from V10 */#define FPL_EXPORT_SYMBOL     (1<<12) /* cross program accessible */#define FPL_GLOBAL_SYMBOL     (1<<13) /* global accessible in one file */#define FPL_SHORT_VARIABLE    (1<<14) /* short (16-bit) variable */#define FPL_CHAR_VARIABLE     (1<<15) /* char (8-bit) variable */#define FPL_UNSIGNED_VARIABLE (1<<16) /* unsigned variable */#define FPL_STATIC_VARIABLE   (1<<17) /* static variable! */#define FPL_DEALLOC_NAME_ANYWAY (1<<18) /* In normal cases, this name should                                           not get freed, but this is not a                                           normal case... ;-P */#define FPL_COMPILER_ADDED    (1<<19)	/* added by a compiled program */#define FPL_STATUS (FPL_READONLY|FPL_HIJACKED_VARIABLE|FPL_EXPORT_SYMBOL\		    FPL_GLOBAL_SYMBOL|FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE\		    FPL_UNSIGNED_VARIABLE|FPL_STATIC_VARIABLE|FPL_REFEREMCE)/* * These two lower flags should be combined with the "Data status" flags * when declaring variables! */#define FPLDECL_STRING	      (1<<31) /* Keyword declaring string */#define FPLDEC_INT	      (1<<30) /* Keyword declaring int */#define FPL_VARIABLE_LESS32 (FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE)#define FPL_VARIABLE (FPL_STRING_VARIABLE|FPL_INT_VARIABLE)#define FPL_FUNCTION (FPL_INTERNAL_FUNCTION|FPL_EXTERNAL_FUNCTION |\		      FPL_INSIDE_FUNCTION)/***** Identifier.ID defines: ******/struct Position {  /*   * This struct should be used from now on when storing and using the   * interpret position!   */  uchar *text;       /* Current interpret position */  long prg;         /* Current line number */  uchar *virfile;    /* virtual file name pointer */  long virprg;	    /* virtual line number */};#define FPL_INSIDE_FUNCTION_ID -3;struct Condition {  uchar *bracetext;  /* pointer to the character to the right of the open		       brace */  long braceprg;    /* line number of the above data */  uchar *check;      /* pointer to the expression. Used by while() and for() */  long checkl;      /* the line number of the expression */  uchar *postexpr;   /* USED BY "for" : pointer to statement3 */  long postexprl;   /* USED BY "for" : statement3's line number */};struct Expr {  /* the numerical expression linked list */  union {    long val;		/* numerical return */    struct fplStr *str; /* string return */  } val;  Operator operator;  /* see the operator enums! */  struct Unary *unary; /* unary/primary operators linked list! */  short flags;	      /* see below */  struct Expr *next; };/**** struct Expr.flags defines: ****/#define FPL_STRING     (1<<0) /* Expr structure is a string. */#define FPL_NOFREE     (1<<1) /* A returned string should not be freed */#define FPL_OPERAND    (1<<2) /* Next part in the expression is a operand */#define FPL_ACTION     (1<<3) /* The expression includes any variable change(s) */#define FPL_BREAK      (1<<4) /* The val member specifies number of levels				 left to break from! */#define FPL_RETURN     (1<<5) /* There is a return call received, return to the				 last function caller. */#define FPL_CONTINUE   (1<<6) /* Continue is flagged! */#define FPL_DEFUNCTION (1<<7) /* The Expression() just called declared AND				 defined a function! */#define FPL_BRACE      (1<<8) /* This invoke returned due to a closing brace! */struct Local {  /*   * This structure will create a linked list of all local variables declared   * in this level. When leaving this level, *ALL* variables with the names   * that the ->ident member points to must be deleted, using DelIdentifier().   */  struct Identifier *ident;		/* This pointer points to the Identifier structure,		   that means this should *NOT* be freed individually		   but only the entire structure and the Identifier structure		   (and members) at the same time! */  struct Local *next; /* Next member in this chain */};/* * All fplFunction ID's below zero are reserved for FPL internal use. * We use the funcdata member to set some flags: */#define FPL_HASH_INSIDE   1#define FPL_HASH_INTERNAL 2struct CompiledInfo {  struct Identifier **list; /* the identifier pointer list */  long listentries; /* amount of identifiers in the list */  long listsize;    /* allocated size of the list */#define DEFAULT_LISTSIZE 32 /* allocate sybol list with this step */};struct Program {  struct Program *next;  uchar *name;		/* unique name of program */  long running;		/* true if running */  long openings;	/* number of invokes! */  uchar *program;	/* program pointer or NULL if not present in memory */  long lines;		/* number of lines */  long size;		/* total size in number of bytes */  long flags;		/* see defines below */  long date;		/* date in seconds (system dependent) */  char foundstart;	/* this program's "main" function is found! */  long startcol;	/* Where "main" started. Column number */  long startprg;	/* Where "main" started. Line number */  long virprg;		/* Virtual line number of "main" */  uchar *virfile;	/* virtual file name of "main" */  long column;		/* Last interpreted column!			   _ONLY_ to read if this program isn't opened! */  long warnings;	/* number of warnings found in this file! */  long index;           /* where the execution starts */  struct CompiledInfo globalinfo; /* global symbol list for this program */};/* Program.flags: */#define PR_USERSUPPLIED (1<<0)/* This program is user supplied. That means that FPL has *not* allocated the   memory this program uses, making no straight flushes allowed! */#define PR_CACHEFILE (1<<1)/* This program should be cached until anything else is said! */#define PR_FILENAMEFLUSH (1<<2)#define PR_NAME_IS_FILENAME PR_FILENAMEFLUSH/* When this program is flushed, it can always be restored by using the   program name as file name to read from! */#define PR_TEMPORARY (1<<3)/* This isn't a real program but only created for a temporary usage reason! */#define PR_GLOBALSTORED (1<<4)/* This program has got it's global symbols stored! */#define PR_CACHEEXPORTS (1<<5)/* This program should be cached only if exports are declared */#define PR_FLUSH_NOT_IN_USE (1<<6)/* This program should be flushed from memory when not in use, to save system   memory! */#define PR_REREAD_CHANGES (1<<7)/* This program should be re-read into memory if accessed and the actual file   on disk has changed! */   #define PR_KIDNAP_CACHED (1<<8)/* This program should get kidnapped if it is PR_USERSUPPLIED and should get   cached! */#define PR_COMPILED (1<<9)/* This program is compiled! */#define PR_SELECTED_FPC (1<<10)/* The .FPC extention program was found newer than the .FPL and thus   loaded and used (even though the .FPL extension will be displayed in   order to know */struct FuncList {  /*   * This struct is a general purpose linked list struct for keeping track   * of a list of char pointers.   */  struct FuncList *next;  long opens;  uchar flags;  uchar *name;};#if 0struct Store {  /*   * This is all data that should be backuped when recursing, and   * restored when the recursing function ends.   */  uchar *text;  long prg;  uchar *virfile;    /* virtual file name pointer */  long virprg;	    /* virtual line number */  uchar strret;  long level;  long varlevel;  uchar *interpret;  struct Local *globals;  struct fplMsg *msg;  struct Program *prog;  struct Local *locals;};#endifstruct Data {  /*   * Allocated at fplInit() and freed at fplFree().   */#ifdef AMIGA  uchar *stack_base;	/* our new stack base */  long stack_size;	/* requested stack size! */  long stack_max;	/* Maximum stack left after a FPL function call */  long stack_limit;	/* absolute maximum stack usage allowed */  long stack_margin;	/* minimum stack required to call the interface			   function! */  long registers[11];	/* Storage for the eleven registers that should be			   brought back when calling the interface function */  struct Task *task;	/* pointer to our task! */  uchar *old_topstack;   /* previous top stack in the task struct */  uchar *old_botstack;   /* previous bot stack in the task struct */  long extern_stack;	/* external stack pointer */  long intern_stack;    /* internal stack pointer */  struct FuncList *funclibs; /* a linked list with the current opened funclib                                names */#endif  /* --------------------------------------------------------------------- */  /* If anything is changed among the above, check validity of liballoc.i! */  /* --------------------------------------------------------------------- */  void * ASM (*Alloc)(DREG(0) long,                      AREG(0) void *);  /* allocate routine to use */  void ASM (*Dealloc)(AREG(1) void *,                      DREG(0) long,                      AREG(0) void *); /* dealloc routine */  long ASM (*function) (AREG(0) void *); /* Pointer to function handler. */  long ASM (*interfunc) (AREG(0) void *); /* Function to be called every now					     and then when executing, enabling					     your programming to keep track of					     different things even if FPL is in					     charge! */  /********* START OF STORE STRUCT ***********/  uchar store_from;    uchar *text;       /* Current interpret position */  long prg;         /* Current line number */  uchar *virfile;    /* virtual file name pointer */  long virprg;	    /* virtual line number */  uchar strret;	    /* The Script() now executing should return a		       string! (TRUE/FALSE) */  long level;	    /* Nesting level */  long varlevel;    /* current variable level */  uchar *interpret;  /* if we whould interpret anything else but the main		       function! Set this with the FPLTAG_INTERPRET tag. */  struct Local *globals; /* Pointer to list holding all global symbols			    currently declared in this program. They might be			    removed when this program quits if the user has			    set that flag or if we miss certain information */  struct fplMsg *msg; /* Pointer to any pending message to FPL sent from the			 user. We expect return codes from user functions to			 be sent using this. */  struct Program *prog; /* Pointer to the "struct Program" holding information			   about the program we're currently interpreting */  struct Local *locals; /* Linked list of local variables! If any error			   code is returned, there might be local variables			   left to free in any precious local level! Use this			   list to delete 'em all!			   			   We add *ALL* levels to one list, separated with a			   NULL name. Deleting only the latest level, deletes			   to the nearest NULL name!			   */  uchar store_end;  /********* END OF STORE STRUCT *************/  struct Program *programs; /* list with all files information */  long ret;		/* Return value of the FPL block */  uchar *buf;		/* Global buffer pointer (Why use more than one buffer			   at a time? It's only a waste of valuable stack!) */  void *userdata;       /* Global Userdata. Free to use. */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?