?? arroots.h
字號:
/*
Copyright (c) 2003, Dan Kranz and Arnold Rom
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
* The names of its contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// -------------------------------------------------------------------------
// roots structures
// -------------------------------------------------------------------------
typedef struct tagBlockCplNline {
BYTE *block;
long cpl;
long nline;
long nAlloc;
} BlockCplNline;
typedef struct tagByteArray {
BYTE *array;
long nAlloc;
} ByteArray;
typedef struct tagShortArray {
unsigned short *array;
long nAlloc;
} ShortArray;
typedef struct tagSignedShortArray {
short *array;
long nAlloc;
} SignedShortArray;
typedef struct tagLongArray {
long *array;
long nAlloc;
} LongArray;
typedef struct tagRealArray {
double *array;
long nAlloc;
} RealArray;
typedef struct tagDoubleArray {
double *array;
long nAlloc;
} DoubleArray;
#define MAXLIN 0xffff // maximum base lines
#define MAXARX 30
#define MAXFLD 120
#define MAXLAB 13
#define B_TYPE 1
#define R_TYPE 2
#define T_TYPE 3
#define E_TYPE 4
#define D_TYPE 5
#define Z_TYPE 6
typedef struct tagDataBase {
char name[MAX_PATH]; // data base path & name
BlockCplNline base; // data base block
short nbtabs; // number of tables (per the directory)
BlockCplNline arx[MAXARX]; // table blocks
short nfields; // number of fields
long blkfld[MAXFLD][2]; // field def's to fields
short type[MAXFLD]; // field type: 1=B=D=Z 2=R 3=Tn 4=E
short ARMRtype[MAXFLD]; // field type: 1=B 2=R 3=Tn 4=E 5=D 6=Z
short tabinx[MAXFLD]; // table index to arx[] for T-types
char label[MAXFLD][MAXLAB]; // field names
short labcpl[MAXFLD]; // length of name
short dspcpl[MAXFLD]; // display cpl
short dspdec[MAXFLD]; // decimal for real types
} DataBase;
typedef struct tagDataBaseInternalValue {
short type;
long binary;
double real;
char Estring[256];
} DataBaseInternalValue;
typedef struct tagCompilerRealArray {
double *array;
long nline;
long nAlloc;
} CompilerRealArray;
typedef struct tagFuncArg {
unsigned short nArgs;
short bfi[20];
double array[20];
} FuncArg;
typedef double (*FUNCADD)(FuncArg* array);
typedef struct tagFunctionPointerArray {
FUNCADD *array;
long nline;
long nAlloc;
} FunctionPointerArray;
typedef struct tagFunctionReturnArray {
BYTE *array;
long nline;
long nAlloc;
} FunctionReturnArray;
typedef struct tagPRGTAB {
BYTE Operator;
FUNCADD FunctionAddress;
BYTE FuncRetType; // =0 for void =1 for double
BYTE OperandType; // 0=variable 1=constants
BYTE OperandCount; // used to count function arguments
short OperandIndex; // index to Constants or Variables
} PRGTAB; // -1 for in stack only
typedef struct tagPROGRAM {
PRGTAB *block;
long nline;
long nAlloc;
unsigned short DepthOfStack; // maximum depth of arithemtic stack;
BYTE go; // =0 if an error occurred; =1 otherwise!
BYTE onePass; // =0 if additional passes; =1 otherwise!
} PROGRAM;
#define VARIABLE_READ 0X01
#define VARIABLE_WRITE 0X02
typedef struct tagCompilerArguments {
BlockCplNline VarTab; // table of variable names
ByteArray acc; // variable access flag =0 for no access,
// =1 for reference, =2 for stored in,
// =3 for both ref and store.
RealArray Variables; // double array to go along with VarTab
BlockCplNline FuncTab; // table of function names
FunctionPointerArray FuncAdd; // function addresses of length FuncTab.nline
FunctionReturnArray FuncRet; // function return type; 0=void 1=double
CompilerRealArray Constants; // array to hold literal constants
BlockCplNline Strings; // holds string literal constants (cpl=1)
PROGRAM Prg; // generated program table
} CompilerArguments;
typedef struct tagMessageQueue {
long nmsg; // message count
long msgcpl; // length of current msg.array
ByteArray queue; // array holding the strings
// these are kept as adjacent C-style strings
} MessageQueue;
// -------------------------------------------------------------------------
// processing macros
// -------------------------------------------------------------------------
#define ExpandGeneric(DataType,array,nline) \
if ((array=(DataType *)malloc(sizeof(DataType)*nline))==NULL) { \
RootsSOS("No Free Space\n"); \
abort(); \
}
#define ExpandDouble(Array,NewSize) \
if (Array.nAlloc < NewSize) { \
if (Array.nAlloc==0) Array.array = \
(double *) malloc(sizeof(double)*(NewSize)); \
else Array.array = \
(double *) realloc(Array.array,sizeof(double)*(NewSize)); \
if (Array.array==NULL) { \
RootsSOS("No Free Space\n"); \
abort(); \
} \
memset(Array.array+Array.nAlloc,'\0', \
sizeof(double)*(NewSize-Array.nAlloc)); \
Array.nAlloc=NewSize; \
}
#define ExpandLong(Array,NewSize) \
if (Array.nAlloc<NewSize) { \
if (Array.nAlloc==0) Array.array = \
(long *) malloc(sizeof(long)*(NewSize)); \
else Array.array = \
(long *) realloc(Array.array,sizeof(long)*(NewSize)); \
if (Array.array==NULL) { \
RootsSOS("No Free Space\n"); \
abort(); \
} \
memset(Array.array+Array.nAlloc,'\0', \
sizeof(long)*(NewSize-Array.nAlloc)); \
Array.nAlloc=NewSize; \
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -