📄 compiler_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>compiler.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center><hr><h1>compiler.h</h1><div class="fragment"><pre>00001 <span class="comment">//-< COMPILE.H >-----------------------------------------------------*--------*</span>00002 <span class="comment">// FastDB Version 1.0 (c) 1999 GARRET * ? *</span>00003 <span class="comment">// (Main Memory Database Management System) * /\| *</span>00004 <span class="comment">// * / \ *</span>00005 <span class="comment">// Created: 20-Nov-98 K.A. Knizhnik * / [] \ *</span>00006 <span class="comment">// Last update: 17-Jan-99 K.A. Knizhnik * GARRET *</span>00007 <span class="comment">//-------------------------------------------------------------------*--------*</span>00008 <span class="comment">// Conditional expresion compiler</span>00009 <span class="comment">//-------------------------------------------------------------------*--------*</span>00010 00011 <span class="preprocessor">#ifndef __COMPILER_H__</span>00012 <span class="preprocessor"></span><span class="preprocessor">#define __COMPILER_H__</span>00013 <span class="preprocessor"></span>00014 <span class="preprocessor">#include <setjmp.h></span>00015 <span class="preprocessor">#ifdef USE_REGEX</span>00016 <span class="preprocessor"></span><span class="preprocessor">#include <regex.h></span>00017 <span class="preprocessor">#endif</span>00018 <span class="preprocessor"></span>00019 BEGIN_FASTDB_NAMESPACE00020 00021 <span class="preprocessor">#if defined(__osf__) || defined(__FreeBSD__)</span>00022 <span class="preprocessor"></span><span class="preprocessor">#define longjmp(b,s) _longjmp(b,s) // do not restore signal context</span>00023 <span class="preprocessor"></span><span class="preprocessor">#define setjmp(b) _setjmp(b)</span>00024 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00025 <span class="preprocessor"></span>00026 <span class="keyword">enum</span> dbvmCodes { 00027 <span class="preprocessor">#define DBVM(cop, type, n_operands, commutative) cop,</span>00028 <span class="preprocessor"></span><span class="preprocessor">#include "compiler.d"</span>00029 dbvmLastCode00030 };00031 00032 <span class="preprocessor">#define IS_CONSTANT(c) \</span>00033 <span class="preprocessor"> (unsigned(c) - dbvmLoadVarBool <= (unsigned)dbvmLoadRectangleConstant - dbvmLoadVarBool)</span>00034 <span class="preprocessor"></span>00035 <span class="keyword">enum</span> nodeType { 00036 tpInteger,00037 tpBoolean,00038 tpReal,00039 tpString,00040 tpReference,00041 tpRectangle,00042 tpArray,00043 tpRawBinary, 00044 tpFreeVar, <span class="comment">// index of EXISTS clause </span>00045 tpList, <span class="comment">// list of expressions</span>00046 tpVoid00047 };00048 00049 <span class="keyword">enum</span> tokens { 00050 tkn_ident,00051 tkn_lpar,00052 tkn_rpar,00053 tkn_lbr,00054 tkn_rbr,00055 tkn_dot,00056 tkn_comma,00057 tkn_power,00058 tkn_iconst,00059 tkn_sconst,00060 tkn_fconst,00061 tkn_add,00062 tkn_sub,00063 tkn_mul,00064 tkn_div,00065 tkn_and,00066 tkn_or,00067 tkn_not,00068 tkn_null,00069 tkn_neg,00070 tkn_eq,00071 tkn_ne,00072 tkn_gt,00073 tkn_ge,00074 tkn_lt,00075 tkn_le,00076 tkn_between,00077 tkn_escape,00078 tkn_exists,00079 tkn_like,00080 tkn_limit,00081 tkn_in,00082 tkn_length,00083 tkn_lower,00084 tkn_upper,00085 tkn_abs,00086 tkn_area,00087 tkn_is,00088 tkn_integer,00089 tkn_real,00090 tkn_string,00091 tkn_first,00092 tkn_last,00093 tkn_current,00094 tkn_var,00095 tkn_col,00096 tkn_true,00097 tkn_false,00098 tkn_where, 00099 tkn_follow,00100 tkn_start,00101 tkn_from,00102 tkn_order,00103 tkn_overlaps,00104 tkn_by,00105 tkn_asc,00106 tkn_desc, 00107 tkn_eof,00108 tkn_insert, 00109 tkn_into, 00110 tkn_select, 00111 tkn_table,00112 tkn_error,00113 tkn_all, 00114 tkn_match,00115 tkn_last_token00116 }; 00117 00118 <span class="keyword">struct </span>dbStrLiteral { 00119 <span class="keywordtype">char</span>* str;00120 <span class="keywordtype">int</span> len;00121 };00122 00123 00124 <span class="keyword">class </span><a class="code" href="classdbUserFunction.html">dbUserFunction</a>;00125 <span class="keyword">class </span>dbExprNodeSegment;00126 00127 <span class="keyword">class </span>FASTDB_DLL_ENTRY dbExprNodeAllocator { 00128 <span class="keyword">private</span>:00129 <span class="keyword">friend</span> <span class="keyword">class </span>dbExprNodeSegment;00130 dbExprNode* freeNodeList;00131 dbExprNodeSegment* segmentList;00132 dbMutex mutex;00133 00134 <span class="keyword">public</span>: 00135 dbMutex& getMutex() {00136 <span class="keywordflow">return</span> mutex;00137 }00138 dbExprNode* allocate();00139 <span class="keywordtype">void</span> deallocate(dbExprNode* node);00140 <span class="keywordtype">void</span> reset();00141 00142 ~dbExprNodeAllocator();00143 <span class="keyword">static</span> dbExprNodeAllocator instance;00144 };00145 00146 <span class="keyword">class </span>FASTDB_DLL_ENTRY dbExprNode { 00147 <span class="keyword">friend</span> <span class="keyword">class </span>dbExprNodeSegment;00148 <span class="keyword">public</span>:00149 nat1 cop;00150 nat1 type;00151 nat2 offs;00152 00153 <span class="keyword">static</span> <span class="keyword">const</span> nat1 nodeTypes[];00154 <span class="keyword">static</span> <span class="keyword">const</span> nat1 nodeOperands[];00155 <span class="keyword">static</span> <span class="keyword">const</span> nat1 commutativeOperator[];00156 00157 <span class="keyword">struct </span>ref_operands { 00158 dbExprNode* base; <span class="comment">// the same as operand[0]</span>00159 <a class="code" href="classdbFieldDescriptor.html">dbFieldDescriptor</a>* field;00160 };00161 00162 <span class="keyword">struct </span>func_operands { 00163 dbExprNode* arg[3]; 00164 <span class="keywordtype">void</span>* fptr;00165 };00166 00167 <span class="preprocessor">#ifdef USE_REGEX</span>00168 <span class="preprocessor"></span> <span class="keyword">struct </span>regex_operands { 00169 dbExprNode* opd; 00170 regex_t re;00171 };00172 <span class="preprocessor">#endif</span>00173 <span class="preprocessor"></span>00174 <span class="keyword">union </span>{ 00175 dbExprNode* operand[3];00176 dbExprNode* next;00177 oid_t oid;00178 db_int8 ivalue;00179 real8 fvalue;00180 <a class="code" href="classrectangle.html">rectangle</a> rvalue;00181 dbStrLiteral svalue;00182 <span class="keywordtype">void</span> <span class="keyword">const</span>* var;00183 ref_operands ref;00184 func_operands func;00185 <span class="preprocessor">#ifdef USE_REGEX</span>00186 <span class="preprocessor"></span> regex_operands regex;00187 <span class="preprocessor">#endif</span>00188 <span class="preprocessor"></span> };00189 00190 dbExprNode(dbExprNode* node);00191 00192 dbExprNode(<span class="keywordtype">int</span> cop, dbExprNode* left = NULL, dbExprNode* right = NULL, 00193 dbExprNode* right2 = NULL)00194 {00195 this->cop = cop;00196 type = nodeTypes[cop];00197 operand[0] = left;00198 operand[1] = right;00199 operand[2] = right2;00200 }00201 dbExprNode(<span class="keywordtype">int</span> cop, dbExprNode* expr1, dbExprNode* expr2, <span class="keywordtype">int</span> offs) { 00202 this->cop = cop;00203 this->offs = (nat2)offs;00204 type = nodeTypes[cop];00205 operand[0] = expr1;00206 operand[1] = expr2;00207 }00208 dbExprNode(<span class="keywordtype">int</span> cop, dbExprNode* expr, <span class="keywordtype">int</span> offs) { 00209 this->cop = cop;00210 this->offs = (nat2)offs;00211 type = nodeTypes[cop];00212 operand[0] = expr;00213 }00214 dbExprNode(<span class="keywordtype">int</span> cop, <a class="code" href="classdbFieldDescriptor.html">dbFieldDescriptor</a>* field, dbExprNode* base = NULL) 00215 {00216 this->cop = cop;00217 this->offs = (nat2)field-><a class="code" href="classdbFieldDescriptor.html#dbFieldDescriptorm17">dbsOffs</a>;00218 type = nodeTypes[cop];00219 ref.field = field;00220 ref.base = base;00221 }00222 dbExprNode(<span class="keywordtype">int</span> cop, db_int8 ivalue) { 00223 this->cop = cop;00224 this->ivalue = ivalue;00225 type = tpInteger;00226 }00227 dbExprNode(<span class="keywordtype">int</span> cop, real8 fvalue) { 00228 this->cop = cop;00229 this->fvalue = fvalue;00230 type = tpReal;00231 }00232 dbExprNode(<span class="keywordtype">int</span> cop, <a class="code" href="classrectangle.html">rectangle</a> rvalue) {00233 this->cop = cop;00234 this->rvalue = rvalue;00235 type = tpRectangle;00236 }00237 dbExprNode(<span class="keywordtype">int</span> cop, dbStrLiteral& svalue) { 00238 this->cop = cop;00239 this->svalue = svalue;00240 type = tpString;00241 }00242 dbExprNode(<span class="keywordtype">int</span> cop, <span class="keywordtype">void</span> <span class="keyword">const</span>* var) { 00243 this->cop = cop;00244 this->var = var;00245 type = nodeTypes[cop];00246 }00247 dbExprNode(<span class="keywordtype">int</span> cop, <span class="keywordtype">void</span>* fptr, dbExprNode* expr1, dbExprNode* expr2 = NULL, dbExprNode* expr3 = NULL) { 00248 this->cop = cop;00249 func.arg[0] = expr1;00250 func.arg[1] = expr2;00251 func.arg[2] = expr3;00252 func.fptr = fptr;00253 type = nodeTypes[cop];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -