123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- #ifndef __NS_EELINT_H__
- #define __NS_EELINT_H__
- #ifdef _WIN32
- #include <windows.h>
- #else
- #include "../wdltypes.h"
- #endif
- #include "ns-eel.h"
- #include "ns-eel-addfuncs.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- enum {
-
- FN_MULTIPLY=0,
- FN_DIVIDE,
- FN_JOIN_STATEMENTS,
- FN_DENORMAL_LIKELY,
- FN_DENORMAL_UNLIKELY,
- FN_ADD,
- FN_SUB,
- FN_AND,
- FN_OR,
- FN_UMINUS,
- FN_NOT,
- FN_NOTNOT,
- FN_XOR,
- FN_SHL,
- FN_SHR,
- FN_MOD,
- FN_POW,
- FN_LT,
- FN_GT,
- FN_LTE,
- FN_GTE,
- FN_EQ,
- FN_EQ_EXACT,
- FN_NE,
- FN_NE_EXACT,
- FN_LOGICAL_AND,
- FN_LOGICAL_OR,
- FN_IF_ELSE,
- FN_MEMORY,
- FN_GMEMORY,
- FN_NONCONST_BEGIN,
- FN_ASSIGN=FN_NONCONST_BEGIN,
- FN_ADD_OP,
- FN_SUB_OP,
- FN_MOD_OP,
- FN_OR_OP,
- FN_AND_OP,
- FN_XOR_OP,
- FN_DIV_OP,
- FN_MUL_OP,
- FN_POW_OP,
- FN_WHILE,
- FN_LOOP,
- FUNCTYPE_SIMPLEMAX,
- FUNCTYPE_FUNCTIONTYPEREC=1000,
- FUNCTYPE_EELFUNC,
- };
- #define YYSTYPE opcodeRec *
- #define NSEEL_CLOSEFACTOR 0.00001
-
-
- typedef struct opcodeRec opcodeRec;
- typedef struct _codeHandleFunctionRec
- {
- struct _codeHandleFunctionRec *next;
- struct _codeHandleFunctionRec *derivedCopies;
- void *startptr;
- opcodeRec *opcodes;
- int startptr_size;
- int tmpspace_req;
-
- int num_params;
- int rvMode;
- int fpStackUsage;
- int canHaveDenormalOutput;
-
-
-
-
- int localstorage_size;
- EEL_F **localstorage;
- int isCommonFunction;
- int usesNamespaces;
- unsigned int parameterAsNamespaceMask;
- char fname[NSEEL_MAX_FUNCSIG_NAME+1];
- } _codeHandleFunctionRec;
-
- #define LLB_DSIZE (65536-64)
- typedef struct _llBlock {
- struct _llBlock *next;
- int sizeused;
- char block[LLB_DSIZE];
- } llBlock;
- typedef struct {
- llBlock *blocks,
- *blocks_data;
- void *workTable;
- void *code;
- int code_size;
- int code_stats[4];
- int want_stack;
- void *stack;
- void *ramPtr;
- int workTable_size;
- int compile_flags;
- } codeHandleType;
- typedef struct
- {
- EEL_F *value;
- int refcnt;
- char isreg;
- char str[1];
- } varNameRec;
- typedef struct
- {
- void *ptr;
- int size, alloc;
- } eel_growbuf;
- #define EEL_GROWBUF(type) union { eel_growbuf _growbuf; type *_tval; }
- #define EEL_GROWBUF_RESIZE(gb, newsz) __growbuf_resize(&(gb)->_growbuf, (newsz)*(int)sizeof((gb)->_tval[0]))
- #define EEL_GROWBUF_GET(gb) ((gb)->_tval)
- #define EEL_GROWBUF_GET_SIZE(gb) ((gb)->_growbuf.size/(int)sizeof((gb)->_tval[0]))
- typedef struct _compileContext
- {
- eel_function_table *registered_func_tab;
- const char *(*func_check)(const char *fn_name, void *user);
- void *func_check_user;
- EEL_GROWBUF(varNameRec *) varNameList;
- EEL_F *varValueStore;
- int varValueStore_left;
- int errVar,gotEndOfInput;
- opcodeRec *result;
- char last_error_string[256];
- void *scanner;
- const char *rdbuf_start, *rdbuf, *rdbuf_end;
- llBlock *tmpblocks_head,
- *blocks_head,
- *blocks_head_data,
- *pblocks;
- int l_stats[4];
- int has_used_global_vars;
- _codeHandleFunctionRec *functions_local, *functions_common;
-
- int optimizeDisableFlags;
- int current_compile_flags;
- struct opcodeRec *directValueCache;
- int isSharedFunctions;
- int isGeneratingCommonFunction;
- int function_usesNamespaces;
- int function_globalFlag;
-
-
-
- int function_localTable_Size[3];
- char **function_localTable_Names[3];
- EEL_F **function_localTable_ValuePtrs;
- const char *function_curName;
- EEL_F (*onString)(void *caller_this, struct eelStringSegmentRec *list);
- EEL_F (*onNamedString)(void *caller_this, const char *name);
- EEL_F *(*getVariable)(void *userctx, const char *name);
- void *getVariable_userctx;
- codeHandleType *tmpCodeHandle;
-
- struct
- {
- int needfree;
- int maxblocks;
- double closefact;
- EEL_F *blocks[NSEEL_RAM_BLOCKS];
- } ram_state
- #ifdef __GNUC__
- __attribute__ ((aligned (8)))
- #endif
- ;
- void *gram_blocks;
- void *caller_this;
- }
- compileContext;
- #define NSEEL_NPARAMS_FLAG_CONST 0x80000
- typedef struct functionType {
- const char *name;
- void *afunc;
- void *func_e;
- int nParams;
- void *replptrs[4];
- NSEEL_PPPROC pProc;
- } functionType;
- functionType *nseel_getFunctionByName(compileContext *ctx, const char *name, int *mchk);
- opcodeRec *nseel_createCompiledValue(compileContext *ctx, EEL_F value);
- opcodeRec *nseel_createCompiledValuePtr(compileContext *ctx, EEL_F *addrValue, const char *namestr);
- opcodeRec *nseel_createMoreParametersOpcode(compileContext *ctx, opcodeRec *code1, opcodeRec *code2);
- opcodeRec *nseel_createSimpleCompiledFunction(compileContext *ctx, int fn, int np, opcodeRec *code1, opcodeRec *code2);
- opcodeRec *nseel_createMemoryAccess(compileContext *ctx, opcodeRec *code1, opcodeRec *code2);
- opcodeRec *nseel_createIfElse(compileContext *ctx, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3);
- opcodeRec *nseel_createFunctionByName(compileContext *ctx, const char *name, int np, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3);
- opcodeRec *nseel_resolve_named_symbol(compileContext *ctx, opcodeRec *rec, int parmcnt, int *errOut);
- opcodeRec *nseel_setCompiledFunctionCallParameters(compileContext *ctx, opcodeRec *fn, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3, opcodeRec *postCode, int *errOut);
- struct eelStringSegmentRec *nseel_createStringSegmentRec(compileContext *ctx, const char *str, int len);
- opcodeRec *nseel_eelMakeOpcodeFromStringSegments(compileContext *ctx, struct eelStringSegmentRec *rec);
- EEL_F *nseel_int_register_var(compileContext *ctx, const char *name, int isReg, const char **namePtrOut);
- _codeHandleFunctionRec *eel_createFunctionNamespacedInstance(compileContext *ctx, _codeHandleFunctionRec *fr, const char *nameptr);
- typedef struct nseel_globalVarItem
- {
- EEL_F data;
- struct nseel_globalVarItem *_next;
- char name[1];
- } nseel_globalVarItem;
- extern nseel_globalVarItem *nseel_globalreg_list;
- #include "y.tab.h"
- const char *nseel_simple_tokenizer(const char **ptr, const char *endptr, int *lenOut, int *state);
- int nseel_filter_escaped_string(char *outbuf, int outbuf_sz, const char *rdptr, size_t rdptr_size, char delim_char);
- opcodeRec *nseel_translate(compileContext *ctx, const char *tmp, size_t tmplen);
- int nseel_lookup(compileContext *ctx, opcodeRec **opOut, const char *sname);
- EEL_F * NSEEL_CGEN_CALL __NSEEL_RAMAlloc(EEL_F **blocks, unsigned int w);
- EEL_F * NSEEL_CGEN_CALL __NSEEL_RAMAllocGMEM(EEL_F ***blocks, unsigned int w);
- EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemSet(EEL_F **blocks,EEL_F *dest, EEL_F *v, EEL_F *lenptr);
- EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemFree(void *blocks, EEL_F *which);
- EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemTop(void *blocks, EEL_F *which);
- EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemCpy(EEL_F **blocks,EEL_F *dest, EEL_F *src, EEL_F *lenptr);
- EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_Mem_SetValues(EEL_F **blocks, INT_PTR np, EEL_F **parms);
- EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_Mem_GetValues(EEL_F **blocks, INT_PTR np, EEL_F **parms);
- extern EEL_F nseel_ramalloc_onfail;
- extern EEL_F * volatile nseel_gmembuf_default;
- #ifdef __cplusplus
- }
- #endif
- #endif
|