⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 script3.h

📁 GNU ccScript is a C++ class framework for creating a virtual machine execution system for use with a
💻 H
📖 第 1 页 / 共 3 页
字号:
	/**	 * Add a trap handler symbolic identity to the keyword table.	 * These are used to handle signal mask coercion and event	 * branch points in the compiler.	 *	 * @param name of requested trap to add to the trap table.	 * @param inherited status of trap.	 * @return assigned id number for the trap.	 */	int trap(const char *name, bool inherited = true);	/**	 * Get count of active traps.	 *	 * @return count of active trap identifiers.	 */	inline unsigned getCount(void)		{return trap_count;};	/**	 * Return true if the trap id is inherited.	 */	bool isInherited(unsigned id);	/**	 * Perform compile time check of a specified symbol.	 *	 * @return syntax error message string.	 * @param chk object pointer to check member function.	 * @param line pointer to line being checked.	 * @param img pointer to image being compiled.	 */	virtual const char *check(Check chk, Line *line, ScriptImage *img);public:	/**	 * Create an initialized script command box.	 */	ScriptCommand();	/**	 * Create a ScriptCommand box initialized from another.	 */	ScriptCommand(ScriptCommand *ini);	/**	 * Get activity counter.	 *	 * @return activity counter.	 */	inline unsigned getActivity(void)		{return activity;};};class __EXPORT ScriptBinder : public Script{private:	friend class __EXPORT ScriptInterp;	friend class __EXPORT ScriptCompiler;	friend class __EXPORT ScriptCommand;	static ScriptBinder *first;	ScriptBinder *next;	const char *id;protected:	void bind(Script::Define *extensions);		virtual void attach(ScriptInterp *interp);	virtual void detach(ScriptInterp *interp);	virtual bool select(ScriptInterp *interp);	virtual bool reload(ScriptCompiler *img);	virtual bool control(ScriptImage *img, char **args);	virtual void down(void);	virtual const char *use(Line *line, ScriptImage *img);public:	ScriptBinder(const char *id = NULL);	ScriptBinder(Script::Define *extensions);	virtual ~ScriptBinder();	static const char *check(Line *line, ScriptImage *img);	static void shutdown(void);	static bool rebuild(ScriptCompiler *img);};class __EXPORT ScriptRuntime : public ScriptCommand{public:	ScriptRuntime();};class __EXPORT ScriptRipple : public ScriptCommand{public:        ScriptRipple();};class __EXPORT ScriptChecks : public ScriptCommand{public:	/**	 * Default compiler syntax to accept any syntax.	 */	const char *chkIgnore(Line *line, ScriptImage *img);	/**	 * Performs DSO load phase for USE modules.	 */	const char *chkUse(Line *line, ScriptImage *img);	/**	 * A check used by "inc" and "dec".	 *	 * @return synxtax error message string or NULL.	 * @param line statement being examined.	 * @param img pointer to image being examined.	 */	const char *chkHasModify(Line *line, ScriptImage *img);	/**	 * Check if member is NULL or a property reference.	 *	 * @param line pointer to line checked for property reference.	 * @param img pointer to image being compiled.	 * @return syntax error message string or NULL.	 */	const char *chkProperty(Line *line, ScriptImage *img);	/**	 * A check for first var...	 *	 * @return syntax error message string or NULL.	 * @param line statement being examined.	 * @param img pointer to image being compiled.	 */	const char *chkFirstVar(Line *line, ScriptImage *img);	/**	 * A basic type check for simple type declarations...	 *	 * @return syntax error message string or NULL.	 * @param line statement being examined.	 * @param img pointer to image being compiled.	 */	const char *chkType(Line *line, ScriptImage *img);	/**	 * Script compiler syntax check for certain variable using	 * statements such as "clear".  Assumes list of valid variable	 * arguments.	 *         * @return syntax error message string or NULL.         * @param line statement being examined.         * @param img pointer to image being compiled.	 */	const char *chkHasVars(Line *line, ScriptImage *img);	/**	 * Script compiler syntax check for assignment statements	 * such as "set", "for", etc.	 *	 * @return syntax error message string or NULL.	 * @param line statement being examined.	 * @param img pointer to image being compiled.	 */	const char *chkHasList(Line *line, ScriptImage *img);	/**	 * Script compiler syntax check for commands that require	 * no arguments to be present.	 *	 * @return syntax error message string or NULL.	 * @param line statement being examined.	 * @param img pointer to image being compiled.	 */	const char *chkNoArgs(Line *line, ScriptImage *img);	/**	 * Script compiler syntax check for commands that require	 * all arguments to be symbols.	 *	 * @return syntax error message string or NULL.	 * @param line pointer being examined.	 * @param img pointer to image being compiled.	 */	const char *chkAllVars(Line *line, ScriptImage *img);	/**	 * Script compiler syntax check for commands that require	 * one or more arguments to be present.	 *	 * @return syntax error message string or NULL.	 * @param line statement being examined.	 * @param img pointer to image being compiled.	 */	const char *chkHasArgs(Line *line, ScriptImage *img);	/**	 * Script compiler syntax check for commands that require	 * one or more arguments but use no keywords.	 *         * @return syntax error message string or NULL.         * @param line statement being examined.         * @param img pointer to image being compiled.	 */	const char *chkOnlyArgs(Line *line, ScriptImage *img);	const char *chkOnlyOneArg(Line *line, ScriptImage *img);	const char *chkRefArgs(Line *line, ScriptImage *img);	const char *chkSlog(Line *line, ScriptImage *img);	const char *chkExpression(Line *line, ScriptImage *img);	const char *chkConditional(Line *line, ScriptImage *img);	const char *chkGoto(Line *line, ScriptImage *img);	const char *chkLabel(Line *line, ScriptImage *img);	const char *chkCall(Line *line, ScriptImage *img);	const char *chkReturn(Line *line, ScriptImage *img);	const char *chkRestart(Line *line, ScriptImage *img);	const char *chkVar(Line *line, ScriptImage *img);	const char *chkVarType(Line *line, ScriptImage *img);	const char *chkDecimal(Line *line, ScriptImage *img);	const char *chkNumber(Line *line, ScriptImage *img);	const char *chkString(Line *line, ScriptImage *img);	const char *chkChar(Line *line, ScriptImage *img);	const char *chkExpr(Line *line, ScriptImage *img);	const char *chkIndex(Line *line, ScriptImage *img);	const char *chkError(Line *line, ScriptImage *img);	const char *chkConst(Line *line, ScriptImage *img);	const char *chkSequence(Line *line, ScriptImage *img);	const char *chkSignal(Line *line, ScriptImage *img);	const char *chkThrow(Line *line, ScriptImage *img);	const char *chkSet(Line *line, ScriptImage *img);	const char *chkRepeat(Line *line, ScriptImage *img);	const char *chkArray(Line *line, ScriptImage *img);	const char *chkFor(Line *line, ScriptImage *img);	const char *chkForeach(Line *line, ScriptImage *img);	const char *chkCat(Line *line, ScriptImage *img);	const char *chkRemove(Line *line, ScriptImage *img);	const char *chkOnlyCommand(Line *line, ScriptImage *img);	const char *chkCounter(Line *line, ScriptImage *img);	const char *chkTimer(Line *line, ScriptImage *img);	const char *chkClear(Line *line, ScriptImage *img);	const char *chkPack(Line *line, ScriptImage *img);	const char *chkLock(Line *line, ScriptImage *img);	const char *chkSession(Line *line, ScriptImage *img);	const char *chkKeywords(Line *line, ScriptImage *img);	const char *chkDefine(Line *line, ScriptImage *img);};/** * A linkable list of objects that can be destroyed when a script image * is removed from memory. * * @author David Sugar <dyfet@ostel.com> * @short Object list in image. */class __EXPORT ScriptObject : public Script{private:	friend class __EXPORT ScriptImage;	ScriptObject *next;protected:	ScriptObject(ScriptImage *image);	virtual ~ScriptObject();};/** * A derivable class to hold compiled script images for active processes. * This includes the script image compiler itself.  Typically, a script is * compiled one file at a time from a directory, and the committed, during * the constructor in a derived class. * * @author David Sugar <dyfet@ostel.com>. * @short Script compiler image set. */class __EXPORT ScriptImage : public Keydata, public Script, public Assoc{protected:	friend class __EXPORT ScriptObject;	ScriptCommand *cmds;	unsigned refcount;	Name *index[SCRIPT_INDEX_SIZE + 1], *current;	Line *select, *selecting, *registration;	Line *advertising[SCRIPT_ROUTE_SLOTS];	Mutex duplock;	ScriptObject *objects;	static unsigned long serial;	unsigned long instance;		class	__EXPORT InitialList : public Script::Initial	{	public:		InitialList *next;	}	*ilist;	friend class __EXPORT ScriptInterp;	/**	 * Get the interpreter method pointer for a given keyword.	 *	 * @return method handler.	 * @param keyword to search.	 */	Method getHandler(const char *keyword)		{return cmds->getHandler(keyword);};public:	/**	 * Get memory for assoc data...	 *	 * @return memory pointer.	 * @param size of memory request.	 */	void *getMemory(size_t size);	/**	 * Fast branch linkback code.	 */	virtual void fastBranch(ScriptInterp *interp);	/**	 * Get current entity being compiled...	 *	 * @return pointer to script currently compiling.	 */	inline Name *getCurrent(void)		{return current;};	/**	 * Add a select record to the currently compiled script.	 *	 * @param line statement to add to list.	 */	void addSelect(Line *line);	/**	 * Add a registration record to the compiled script.	 *	 * @param line statement to add to list.	 */	void addRegistration(Line *line);	/**	 * Get a registration record to use.	 *	 * @return registration object.	 */	ScriptRegistry *getRegistry(void);	/**	 * Add an advertised route in a priority slot.	 *	 * @param line statement to add to list.	 * @param pri of route to add to.	 */	void addRoute(Line *line, unsigned pri);	/**	 * Get the selection list from the image.	 *	 * @return selection list.	 */	inline Line *getSelect(void)		{return select;};	/**	 * Get the registration list from the image.	 *	 * @return registration list.	 */	inline Line *getRegistration(void)		{return registration;};	/**	 * Get an advertised priority record from the image.	 *	 * @return priority list.	 */	inline Line *getRoute(unsigned pri)		{return advertising[pri];};	/**	 * Get the session instance of the image.	 */	inline unsigned long getInstance(void)		{return instance;};	/**	 * Construct a new working image.  This must be derived to an	 * application specific compiler that can scan directories and	 * invoke the compiler as needed.	 *	 * @param cmdset of keyword table object used.	 * @param symset of predefined symbols being used.	 */	ScriptImage(ScriptCommand *cmdset, const char *symset);	/**	 * Destruct the ScriptImage itself by removing linked objects.	 */	~ScriptImage();	/**	 * Purge and reload the script image workspace.	 */	void purge(void);	/**	 * Used in the derived constructor to "commit" the current image         * for new processes.  This is usually the last statement in the	 * derived constructor.	 */	void commit(void);	/**	 * Used by a derived constructor to load an initialization list.	 *	 * @param ilist initialization list of symbol pairs to load.	 */	void load(Initial *ilist);	/**	 * Used to load a single initialization list entry.	 *	 * @param keyword name to initialize.	 * @param value of keyword.	 * @param size of keyword data field.	 */	void initial(const char *keyword, const char *value, unsigned size = 0);	/**	 * Fetch named script.	 *	 * @param name of script to find.	 * @return script or NULL.	 */	virtual Name *getScript(const char *name);	/**	 * Get the command object associated with the image.	 *	 * @return command object.	 */	inline ScriptCommand *getCommand(void)		{return cmds;};	/**	 * Get the ripple flag for the current image.	 *	 * @return true if a ripple image.	 */	bool isRipple(void)		{return cmds->ripple;};	/**	 * Fetch list of relational scripts.	 *	 * @param suffix extension of scripts being fetched.	 * @param array of script objects gathered from image.	 * @param size limit of array to gather.	 * @return count of entries found.	 */	unsigned gather(const char *suffix, Name **array, unsigned size);	/**	 * inc the reference count.	 */	inline void incRef(void)		{++refcount;};	/**	 * dec the reference count.	 */	inline void decRef(void)		{--refcount;};	/**	 * See if the image is referenced...	 *	 * @return true if is referenced.	 */	inline bool isRef(void)		{return (bool)(refcount > 0);};	/**	 * Get the active image from command.  Useful when compiling.	 *	 * @return ScriptImage of currently active image.	 */	inline ScriptImage *getActive(void)		{return cmds->getActive();};};/** * A derivable class to hold compiled script images for active processes. * This includes the script image compiler itself.  Typically, a script is * compiled one file at a time from a directory, and the committed, during * the constructor in a derived class. * * @author David Sugar <dyfet@ostel.com>. * @short Script compiler image set. */class __EXPORT ScriptCompiler : public ScriptImage{protected:	std::ifstream scrSource;	std::istream *scrStream;	char *buffer;	unsigned bufsize;	char *bp;	bool quote;	unsigned paren;	unsigned inccount;	const char *incfiles[256];	typedef struct _merge	{		struct _merge *next;		Name *target;		const char *source;		const char *prefix;	}	merge_t;	merge_t *mlist;		friend class __EXPORT ScriptInterp;	virtual bool checkSegment(Name *scr);public:	char *getToken(char **pre = NULL);	/**	 * Fast branch linkback code.	 */	virtual void fastBranch(ScriptInterp *interp);	/**	 * Construct a new working image.  This must be derived to an	 * application specific compiler that can scan directories and	 * invoke the compiler as needed.	 *	 * @param cmdset of keyword table object used.	 * @param symset of symbols to set.	 */	ScriptCompiler(ScriptCommand *cmdset, const char *symset);	/**	 * A method to invoke the script compiler to include a script

⌨️ 快捷键说明

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