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

📄 php_syntree.h

📁 电驴的MAC源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
//// This file is part of the aMule Project.//// Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )// Copyright (C) 2005-2008 Froenchenko Leonid ( lfroen@amule.org )//// Any parts of this program derived from the xMule, lMule or eMule project,// or contributed by third-party developers are copyrighted by their// respective authors.//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA///* * Syntax tree implementation for amule-PHP interpreter. */#ifndef _PHP_SYNTREE_H_#define _PHP_SYNTREE_H_#ifndef __STDC_FORMAT_MACROS	#define __STDC_FORMAT_MACROS#endif#include <inttypes.h>#if !defined PRIu64# if defined(__alpha__) || defined(__ia64__) || defined(__ppc64__) || defined(__x86_64__) \ || defined(__mips64__) || defined(__hppa64__) || defined(__sparc64__)#  define PRIu64 "lu"# else#  define PRIu64 "llu"# endif#endiftypedef enum PHP_VALUE_TYPE {	/* simple values */	PHP_VAL_NONE, PHP_VAL_INT, PHP_VAL_FLOAT, PHP_VAL_STRING, PHP_VAL_BOOL,	/* both point to same map<string, var> but meaning is different */	PHP_VAL_ARRAY, PHP_VAL_OBJECT,	/* Internally used (not ref counted) data */	PHP_VAL_INT_DATA,	/* ptr_val points to VAR_NODE */	PHP_VAL_VAR_NODE} PHP_VALUE_TYPE;typedef struct PHP_VALUE_NODE {    PHP_VALUE_TYPE type;    union {        uint64_t int_val;        double float_val;        char *str_val;        /* used for arrays and internal objects:         * * array contain std::map of key:value pairs         * * object contain internally interpreted data         */        void *ptr_val;        struct {        	void *inst_ptr;        	const char *class_name;        } obj_val;    };} PHP_VALUE_NODE;/* * Flags for different variable types/usages */#define PHP_VARFLAG_STATIC		0x0001#define PHP_VARFLAG_GLOBAL		0x0002#define PHP_VARFLAG_BYREF		0x0004/*  Data about variable.*/typedef struct PHP_VAR_NODE {    PHP_VALUE_NODE value;    /* php support references */    int ref_count;    int flags;} PHP_VAR_NODE;/* Node in expression tree. Contain either (left op right) or (value)*/typedef enum PHP_EXP_OP {    PHP_OP_VAR, PHP_OP_VAL, PHP_OP_ASS,        /* dereference */    PHP_OP_ARRAY_BY_KEY, PHP_OP_VAR_BY_EXP,    	/* array construct */	PHP_OP_ARRAY, PHP_OP_ARRAY_PAIR, PHP_OP_ARRAY_REF_PAIR,		/* object access "->" and "::" */	PHP_OP_OBJECT_DEREF, PHP_OP_CLASS_DEREF,  	/* casting */ 	PHP_OP_CAST_INT, PHP_OP_CAST_FLOAT, PHP_OP_CAST_BOOL, PHP_OP_CAST_STR, 	    /* arithmetics */    PHP_OP_MUL, PHP_OP_DIV, PHP_OP_ADD, PHP_OP_SUB, PHP_OP_REM,    /* str concat */    PHP_OP_CAT,    /* bits */    PHP_OP_SHL, PHP_OP_SHR, PHP_OP_OR, PHP_OP_AND, PHP_OP_XOR, PHP_OP_NOT,    /* logical */    PHP_OP_LOG_OR, PHP_OP_LOG_AND, PHP_OP_LOG_XOR, PHP_OP_LOG_NOT,    /* compare */    PHP_OP_EQ, PHP_OP_NEQ, PHP_OP_SAME, PHP_OP_NOT_SAME,    PHP_OP_GRT, PHP_OP_GRT_EQ, PHP_OP_LWR, PHP_OP_LWR_EQ,	/* conditional assign (mux) */	PHP_OP_MUX,		/* specials */	PHP_OP_FUNC_CALL, PHP_OP_PRINT, PHP_OP_ECHO, PHP_MAKE_REF,	/* list of expressions */	PHP_OP_LIST,	/* for "switch" list of cases */	PHP_OP_CASE} PHP_EXP_OP;struct PHP_EXP_NODE {    PHP_EXP_OP op;    union {        struct {            struct PHP_EXP_NODE *left;            /* In the 'switch' statement expression points             * to beginning of code*/            union {            	struct PHP_EXP_NODE *right;            	struct PHP_SYN_NODE *syn_right;            };        } tree_node;        struct PHP_EXP_NODE *next;    };    union {        PHP_VALUE_NODE val_node;        // for "internal" variables, like function param list        PHP_VAR_NODE *var_node;        struct PHP_SCOPE_ITEM *var_si_node;        struct PHP_EXP_NODE *exp_node;    };};typedef struct PHP_EXP_NODE PHP_EXP_NODE;typedef struct PHP_LIST_ASSIGN_NODE PHP_LIST_ASSIGN_NODE;struct PHP_LIST_ASSIGN_NODE {	int is_list;	union {		PHP_VAR_NODE *var;		PHP_LIST_ASSIGN_NODE *list;	};	PHP_LIST_ASSIGN_NODE *next_node;};typedef struct PHP_FUNC_PARAM_ITEM PHP_FUNC_PARAM_ITEM;struct PHP_FUNC_PARAM_ITEM {	char *name;	char *class_name;	int byref;	PHP_FUNC_PARAM_ITEM *next_item;};typedef struct PHP_SYN_NODE PHP_SYN_NODE;/* * Scope table: holding variable definition and declarations for * functions and classes * Can be present in several locations: *  1. Representing stack frame block, inside of called function *  2. As global scope - holder of global vars, classes and global functions *  3. At class scope - holder of class members *  4. Copied to class instanse *  */typedef enum PHP_SCOPE_ITEM_TYPE {	PHP_SCOPE_NONE,	PHP_SCOPE_VAR, PHP_SCOPE_FUNC, PHP_SCOPE_CLASS,	PHP_SCOPE_PARAM} PHP_SCOPE_ITEM_TYPE;typedef struct PHP_SCOPE_ITEM {	PHP_SCOPE_ITEM_TYPE type;	union {		PHP_VAR_NODE *var;		PHP_SYN_NODE *func;		PHP_SYN_NODE *class_decl;		struct {			PHP_VAR_NODE *var;			int num;		} param;	};} PHP_SCOPE_ITEM;/* thre's stl object behind it */typedef void *PHP_SCOPE_TABLE;typedef void *PHP_SCOPE_STACK;/* Syntax tree node, representing 1 statement.*/typedef enum PHP_STATMENT_TYPE {	PHP_ST_EXPR, PHP_ST_IF,	PHP_ST_WHILE, PHP_ST_DO_WHILE, PHP_ST_FOR, PHP_ST_FOREACH, PHP_ST_SWITCH,	PHP_ST_CONTINUE, PHP_ST_BREAK, PHP_ST_RET,	PHP_ST_FUNC_DECL, PHP_ST_CLASS_DECL,	PHP_ST_ECHO} PHP_STATMENT_TYPE;/*  * Syntax tree constructs: regular statements and declarations */typedef struct PHP_SYN_IF_NODE {    PHP_EXP_NODE *cond;    PHP_SYN_NODE *code_if, *code_else;} PHP_SYN_IF_NODE;typedef struct PHP_SYN_WHILE_NODE {    PHP_EXP_NODE *cond;    PHP_SYN_NODE *code;} PHP_SYN_WHILE_NODE;typedef struct PHP_SYN_FOR_NODE {    PHP_EXP_NODE *do_start, *cond, *do_next;    PHP_SYN_NODE *code;} PHP_SYN_FOR_NODE;typedef struct PHP_SYN_FOREACH_NODE {    PHP_EXP_NODE *elems;  	PHP_SCOPE_ITEM *i_key;  	PHP_SCOPE_ITEM *i_val;    PHP_SYN_NODE *code;    int byref;} PHP_SYN_FOREACH_NODE;typedef struct PHP_SYN_SWITCH_NODE {    PHP_EXP_NODE *cond;    PHP_EXP_NODE *case_list;} PHP_SYN_SWITCH_NODE;/* for built-in or native functions */typedef void (*PHP_NATIVE_FUNC_PTR)(PHP_VALUE_NODE *result);typedef struct PHP_FUNC_PARAM_DEF {	char *class_name;	int byref;	PHP_VALUE_NODE def_value;	/*	 * In PHP, user can choose per-call whether parameter is passed	 * by value of by reference. So, save ptr to original varnode,	 * for "byvalue" case since we don't have other lvalue to put in	 * that scope item.	 */	PHP_VAR_NODE *var;	PHP_SCOPE_ITEM *si_var;} PHP_FUNC_PARAM_DEF;typedef struct PHP_SYN_FUNC_DECL_NODE {	char *name;	PHP_SCOPE_TABLE scope;	int is_native;	union {

⌨️ 快捷键说明

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