Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skParseNode.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019   * $Id: skParseNode_8h-source.html,v 1.15 2003/11/20 17:20:22 sdw Exp $
00020   */
00021 
00022 #ifndef PARSENODE_H
00023 #define PARSENODE_H
00024 #include "skStringList.h"
00025 #include "skAlist.h"
00026 
00027 
00028 static const int s_If=4;
00029 static const int s_While=5;
00030 static const int s_Return=6;
00031 static const int s_Assign=7;
00032 static const int s_Method=8;
00033 static const int s_IdList=9;
00034 static const int s_String=10;
00035 static const int s_Integer=11;
00036 static const int s_Not=12;
00037 static const int s_And=13;
00038 static const int s_Or=14;
00039 static const int s_Less=15;
00040 static const int s_More=16;
00041 static const int s_Equals=17;
00042 static const int s_Plus=18;
00043 static const int s_Minus=19;
00044 static const int s_Subtract=20;
00045 static const int s_Concat=21;
00046 static const int s_Divide=22;
00047 static const int s_Mult=23;
00048 static const int s_Mod=24;
00049 static const int s_Float=25;
00050 static const int s_Character=26;
00051 static const int s_CaseList=27;
00052 static const int s_Case=28;
00053 static const int s_Switch=29;
00054 static const int s_Id=30;
00055 static const int s_NotEquals=31;
00056 static const int s_ForEach=32;
00057 static const int s_LessEqual=33;
00058 static const int s_MoreEqual=34;
00059 static const int s_For=35;
00060 static const int s_MethodDef=36;
00061 
00062 // Switch on to check size of node tree
00063 //#define _DEBUG_SIZE
00064 
00065 #ifndef EXECUTE_PARSENODES
00066 const int NOT_PRESENT_INDEX=0xfff;
00067 
00084 // integers whose absolute value is less than this will be stored directly in the byte code
00085 const int INLINE_INT=((1<<24)/2);
00086 const int PARAM_MASK=0xffffff;
00087 const int PARAM1_MASK=0xfff000;
00088 const int PARAM2_MASK=0x000fff;
00093 class skCompiledCode 
00094 #ifdef __SYMBIAN32__
00095 : public CBase
00096 #endif
00097 {
00098  public:
00102 enum skInstruction{
00103   b_NullStat,        // param1 = 0                 param2 = line
00104   b_StatList,        // param1 = num stats         param2 = number of bytes in stat list
00105   b_Switch,          // param1 = has default       param2 = line
00106   b_If,              // param1 = has else          param2 = line
00107   b_Return,          // param1 = has return expr   param2 = line
00108   b_While,           // param1 = 0                 param2 = line
00109   b_ForEach,         // param1 = id index          param2 = line
00110   b_QualifierIndex,  // param1 = qualifier index   param2 = number of bytes in stat list
00111   b_For,             // param1 = has step expr     param2 = line
00112   b_Assign,          // param1 = 0                 param2 = line
00113   b_Method,          // param1 = 0                 param2 = line
00114   b_IdList,          // param1 = number of ids     param2 = attribute index
00115   b_IdWithMethod,    // param1 = id index          param2 = has array index
00116   b_Id,              // param1 = id index          param2 = has array index
00117   b_ExprList,        // param1 = 0                 param2 = number of expressions
00118   b_String,          // param1 = string index
00119   b_Int,             // param1 = int index
00120   b_IntInline,       // param1 = int value
00121   b_Char,            // param1 = char value
00122 #ifdef USE_FLOATING_POINT
00123   b_Float,           // param1 = float index
00124 #endif
00125   b_Op,              // param1 = op type           param2 = has 2nd expression
00126   b_CaseList,        // param1 = number of cases   param2 = number of byte codes in case list
00127   b_StatsSize,       // param1 = 0                 param2 = number of bytes in stat list
00128   b_NUMCODES
00129 };
00130 
00132   void addInstruction(skInstruction instruction,int parameter1,int parameter2);
00136   int addId(const skString& id);
00140   int addString(const skString& id);
00144   int addInt(int i);
00145 #ifdef USE_FLOATING_POINT
00146 
00149   int addFloat(float f);
00150 #endif
00151 
00154   void setInstruction(USize pc,skInstruction instruction,int parameter1,int parameter2);
00158   void getInstruction(USize pc,skInstruction& instruction,int& parameter1,int& parameter2);
00162   void getInstruction(USize pc,skInstruction& instruction,int& parameter1,bool& parameter2);
00166   skString getId(int id);
00170   int getInt(int id);
00174   skString getString(int id);
00175 #ifdef USE_FLOATING_POINT
00176 
00179   float getFloat(int id);
00180 #endif
00181 
00184   USize getPC() const;
00185 #ifdef _DEBUG_SIZE
00186 
00189   USize getSize() const;
00190 #endif
00191 
00194   void moveIdentifiers(skStringList& identifiers);
00195  private:
00199   skTVAList<USize> m_Instructions;
00203   skStringList m_LiteralStrings;
00207   skStringList m_Identifiers;
00211   skTVAList<int> m_LiteralInts;
00212 #ifdef USE_FLOATING_POINT
00213 
00216   skTVAList<float> m_LiteralFloats;
00217 #endif
00218 };
00219 #endif
00220 
00224 class  skParseNode 
00225 #ifdef __SYMBIAN32__
00226 : public CBase
00227 #endif
00228 {
00229  public:
00232   skParseNode(int linenum){
00233     m_LineNum=linenum;
00234   }
00236   virtual ~skParseNode(){
00237   }
00239   virtual int getType(){
00240     return 0;
00241   }
00243   virtual void clear(){
00244   }
00245   int getLineNum() const{
00246     return m_LineNum;
00247   }
00248 #ifdef _DEBUG_SIZE
00249   virtual USize getSize() const=0;
00250 #endif
00251  protected:
00253   int m_LineNum;
00254  private:
00255   skParseNode(const skParseNode& ){
00256   }
00257   skParseNode& operator=(const skParseNode&){
00258     return *this;
00259   }
00260 };
00261 class  skParseNodeList : public skTAList<skParseNode>{
00262 };
00263 typedef  skTAListIterator<skParseNode> skParseNodeListIterator;
00264 class  skStatNode : public skParseNode {
00265  public:
00266   skStatNode(int linenum) 
00267     : skParseNode(linenum){
00268   }
00269   virtual ~skStatNode(){
00270   }
00271 #ifdef _DEBUG_SIZE
00272   virtual USize getSize() const {
00273     return sizeof(this)+sizeof(void *);
00274   }
00275 #endif
00276 #ifndef EXECUTE_PARSENODES
00277  public:
00281   virtual void compile(skCompiledCode& compiled_code);
00282 #endif
00283 };
00284 class  skExprNode : public skParseNode {
00285  public:
00286   skExprNode(int linenum) 
00287     : skParseNode(linenum){
00288   }
00289   virtual ~skExprNode(){
00290   }
00291 #ifndef EXECUTE_PARSENODES
00292 
00295   virtual void compile(skCompiledCode& compiled_code)=0;
00296 #endif
00297 };
00298 #ifndef EXECUTE_PARSENODES
00299 class skCompiledExprNode : public skParseNode{
00300  public:
00301   skCompiledExprNode(skExprNode * node)
00302     : skParseNode(0),m_Node(node)
00303     {
00304   }
00305   skCompiledCode& getCompiledCode(){
00306     return m_Compiled;
00307   }
00308   void compile();
00309 #ifdef _DEBUG_SIZE
00310   USize getSize() const{
00311     USize size=m_Compiled.getSize();
00312     if (m_Node)
00313       size+=m_Node->getSize();
00314     return size;
00315   }
00316 #endif
00317  private:
00318   skExprNode * m_Node;
00319   skCompiledCode m_Compiled;
00320 };
00321 #endif
00322 typedef skTAList<skStatNode> skStatList;
00323 typedef skTAListIterator<skStatNode> skStatListIterator;
00324 
00325 class  skStatListNode : public skParseNode {
00326  public:
00327   skStatListNode(int linenum)
00328     : skParseNode(linenum){
00329   }
00330   inline ~skStatListNode(){
00331     m_Stats.clearAndDestroy();
00332   }
00336   inline void addStat(skStatNode * stat){
00337     m_Stats.append(stat);
00338   }
00339   inline void clear(){
00340     m_Stats.clear();
00341   }
00342   inline USize numStats(){
00343     return m_Stats.entries();
00344   }
00345   inline skStatNode * getStat(USize i){
00346     return m_Stats[i];
00347   }
00348 #ifdef _DEBUG_SIZE
00349   virtual USize getSize() const {
00350     USize size=sizeof(this)+sizeof(void *);
00351     for (USize i=0;i<m_Stats.entries();i++)
00352       size+=+m_Stats[i]->getSize();
00353     size+=m_Stats.getArraySize()*sizeof(skStatNode *);
00354     return size;
00355   }
00356 #endif
00357 #ifndef EXECUTE_PARSENODES
00358  public:
00362   void compile(skCompiledCode& compiled_code);
00363 #endif
00364  private:
00365   skStatList m_Stats;
00366 };
00367 typedef skTAList<skExprNode> skExprList;
00368 typedef skTAListIterator<skExprNode> skExprListIterator;
00369 class  skExprListNode : public skParseNode {
00370  public:
00371   skExprListNode(int linenum)
00372     : skParseNode(linenum){
00373   }
00374   inline ~skExprListNode(){
00375     m_Exprs.clearAndDestroy();
00376   }
00380   inline void addExpr(skExprNode * expr){
00381     m_Exprs.append(expr);
00382   }
00383   inline int numExprs(){
00384     return m_Exprs.entries();
00385   }
00386   inline void clear(){
00387     m_Exprs.clear();
00388   }
00389   skExprList& getExprs(){
00390     return m_Exprs;
00391   }
00392 #ifdef _DEBUG_SIZE
00393   virtual USize getSize() const {
00394     USize size=sizeof(this)+sizeof(void *);
00395     for (USize i=0;i<m_Exprs.entries();i++)
00396       size+=+m_Exprs[i]->getSize();
00397     size+=m_Exprs.getArraySize()*sizeof(skExprNode *);
00398     return size;
00399   }
00400 #endif
00401 #ifndef EXECUTE_PARSENODES
00402 
00405   void compile(skCompiledCode& compiled_code);
00406 #endif
00407  private:
00408   skExprList m_Exprs;
00409 };
00410 class  skIdNode : public skExprNode {
00411  public:
00412 #ifdef EXECUTE_PARSENODES
00413   inline skIdNode(int linenum,skString * id,skExprNode * arrayIndex,skExprListNode * exprs) 
00414     : skExprNode(linenum),m_Id(*id),m_Exprs(exprs),m_ArrayIndex(arrayIndex)
00415     {
00416   }
00417 #else
00418   inline skIdNode(int linenum,int id,skExprNode * arrayIndex,skExprListNode * exprs) 
00419     : skExprNode(linenum),m_Id(id),m_Exprs(exprs),m_ArrayIndex(arrayIndex)
00420     {
00421   }
00422 #endif
00423   inline ~skIdNode(){
00424     delete m_Exprs;
00425     delete m_ArrayIndex;
00426   }
00427   inline void clear(){
00428     m_Exprs=0;
00429     m_ArrayIndex=0;
00430   }
00431   inline int getType(){
00432     return s_Id;
00433   }
00434 #ifdef EXECUTE_PARSENODES
00435   inline skString getId() const{
00436     return m_Id;
00437   }
00438 #else
00439   inline int getId() const{
00440     return m_Id;
00441   }
00442 #endif
00443   inline skExprListNode * getExprs(){
00444     return m_Exprs;
00445   }
00446   inline skExprNode * getArrayIndex(){
00447     return m_ArrayIndex;
00448   }
00449 #ifdef _DEBUG_SIZE
00450   virtual USize getSize() const {
00451     USize size=sizeof(this)+sizeof(void *);
00452 #ifdef EXECUTE_PARSENODES
00453     size+=m_Id.length();
00454 #endif
00455     if (m_Exprs)
00456       size+=m_Exprs->getSize();
00457     if (m_ArrayIndex)
00458       size+=m_ArrayIndex->getSize();
00459     return size;
00460   }
00461 #endif
00462 #ifndef EXECUTE_PARSENODES
00463 
00466   virtual void compile(skCompiledCode& compiled_code);
00467 #endif
00468  private:
00469 #ifdef EXECUTE_PARSENODES
00470   skString m_Id;
00471 #else
00472   int m_Id;
00473 #endif
00474   skExprListNode * m_Exprs;
00475   skExprNode * m_ArrayIndex;
00476 };
00477 class  skIdNodeList : public skTAList<skIdNode>{
00478 };
00479 typedef  skTAListIterator<skIdNode> skIdNodeListIterator;
00480 class  skIdListNode : public skExprNode {
00481  public:
00482   inline skIdListNode(int linenum) 
00483     : skExprNode(linenum)
00484 #ifndef EXECUTE_PARSENODES
00485     ,m_Attribute(NOT_PRESENT_INDEX)
00486 #endif
00487     {
00488   }
00489   inline ~skIdListNode(){
00490     m_Ids.clearAndDestroy();
00491   }
00495   inline void addId(skIdNode * node){
00496     m_Ids.append(node);
00497   }
00501   inline void prependId(skIdNode * node){
00502     m_Ids.prepend(node);
00503   }
00504   inline USize numIds(){
00505     return m_Ids.entries();
00506   }
00507   inline void clear(){
00508     m_Ids.clear();
00509   }
00510   inline skIdNode * getLastId(){
00511     return m_Ids[m_Ids.entries()-1];
00512   }
00513   inline skIdNode * getId(USize i){
00514     return m_Ids[i];
00515   }
00516   inline int getType(){
00517     return s_IdList;
00518   }
00519 #ifdef EXECUTE_PARSENODES
00520   inline void setAttribute(skString * attr){
00521     m_Attribute=*attr;
00522   }
00523   inline skString getAttribute() const {
00524     return m_Attribute;
00525   }
00526 #else
00527   inline void setAttribute(int attr){
00528     m_Attribute=attr;
00529   }
00530 #endif
00531 #ifdef _DEBUG_SIZE
00532   virtual USize getSize() const {
00533     USize size=sizeof(this)+sizeof(void *);
00534 #ifdef EXECUTE_PARSENODES
00535     size+=m_Attribute.length();
00536 #endif
00537     for (USize i=0;i<m_Ids.entries();i++)
00538       size+=m_Ids[i]->getSize();
00539     size+=m_Ids.getArraySize()*sizeof(skIdNode *);
00540     return size;
00541   }
00542 #endif
00543 #ifndef EXECUTE_PARSENODES
00544 
00547   void compile(skCompiledCode& compiled_code);
00548 #endif
00549  private:
00550 #ifdef EXECUTE_PARSENODES
00551   skString m_Attribute;
00552 #else
00553   int m_Attribute;
00554 #endif
00555   skIdNodeList m_Ids;
00556 };
00557 class  skCaseNode : public skParseNode {
00558  public:
00559   inline skCaseNode(int linenum,skExprNode * expr,skStatListNode * stat) 
00560     : skParseNode(linenum), m_Expr(expr),m_Stats(stat){
00561   }
00562   inline ~skCaseNode(){
00563     delete m_Expr;
00564     delete m_Stats;
00565   }
00566   inline void clear(){
00567     m_Expr=0;
00568     m_Stats=0;
00569   }
00570   inline int getType(){
00571     return s_Case;
00572   }
00573   inline skExprNode * getExpr(){
00574     return m_Expr;
00575   }
00576   inline skStatListNode * getStats(){
00577     return m_Stats;
00578   }
00579 #ifdef _DEBUG_SIZE
00580   virtual USize getSize() const {
00581     return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00582   }
00583 #endif
00584 #ifndef EXECUTE_PARSENODES
00585 
00588   void compile(skCompiledCode& compiled_code);
00589 #endif
00590  private:
00591   skExprNode * m_Expr;
00592   skStatListNode * m_Stats;
00593 };
00594 typedef skTAList<skCaseNode> skCaseList;
00595 typedef skTAListIterator<skCaseNode> skCaseListIterator;
00596 class  skCaseListNode : public skParseNode {
00597  public:
00598   inline skCaseListNode(int linenum) 
00599     : skParseNode(linenum){
00600   }
00601   inline ~skCaseListNode(){
00602     m_Cases.clearAndDestroy();
00603   }
00607   inline void addCase(skCaseNode * expr){
00608     m_Cases.append(expr);
00609   }
00610   inline int numCases(){
00611     return m_Cases.entries();;
00612   }
00613   inline void clear(){
00614     m_Cases.clear();
00615   }
00616   inline skCaseList& getCases(){
00617     return m_Cases;
00618   }
00619 #ifdef _DEBUG_SIZE
00620   virtual USize getSize() const {
00621     USize size=sizeof(this)+sizeof(void *);
00622     for (USize i=0;i<m_Cases.entries();i++)
00623       size+=m_Cases[i]->getSize();
00624     size+=m_Cases.getArraySize()*sizeof(skCaseNode*);
00625     return size;
00626   }
00627 #endif
00628 #ifndef EXECUTE_PARSENODES
00629  public:
00633   void compile(skCompiledCode& compiled_code);
00634 #endif
00635  private:
00636   skCaseList m_Cases;
00637 };
00638 class  skSwitchNode : public skStatNode {
00639  public:
00640   inline skSwitchNode(int linenum,skExprNode * expr,skCaseListNode * cases,skStatListNode * defaultStat) 
00641     : skStatNode(linenum),m_Expr(expr),m_Cases(cases),m_Default(defaultStat){
00642   }
00643   inline ~skSwitchNode(){
00644     delete m_Expr;
00645     delete m_Cases;
00646     delete m_Default;
00647   }
00648   inline void clear(){
00649     m_Expr=0;
00650     m_Cases=0;
00651     m_Default=0;
00652   }
00653   inline int getType(){
00654     return s_Switch;
00655   }
00656   inline skExprNode * getExpr(){
00657     return m_Expr;
00658   }
00659   inline skCaseListNode * getCases(){
00660     return m_Cases;
00661   }
00662   inline skStatListNode * getDefault(){
00663     return m_Default;
00664   }
00665 #ifdef _DEBUG_SIZE
00666   virtual USize getSize() const {
00667     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Cases->getSize();
00668     if (m_Default)
00669       size+=m_Default->getSize();
00670     return size;
00671   }
00672 #endif
00673 #ifndef EXECUTE_PARSENODES
00674  public:
00678   void compile(skCompiledCode& compiled_code);
00679 #endif
00680  private:
00681   skExprNode * m_Expr;
00682   skCaseListNode * m_Cases;
00683   skStatListNode * m_Default;
00684 };
00685 class  skIfNode : public skStatNode {
00686  public:
00687   inline skIfNode(int linenum,skExprNode * expr,skStatListNode * stat,skStatListNode * elseStat) 
00688     : skStatNode(linenum),m_Expr(expr),m_Stats(stat),m_Else(elseStat){
00689   }
00690   inline ~skIfNode(){
00691     delete m_Expr;
00692     delete m_Stats;
00693     delete m_Else;
00694   }
00695   inline void clear(){
00696     m_Expr=0;
00697     m_Stats=0;
00698     m_Else=0;
00699   }
00700   inline int getType(){
00701     return s_If;
00702   }
00703   inline skExprNode * getExpr(){
00704     return m_Expr;
00705   }
00706   inline skStatListNode * getStats(){
00707     return m_Stats;
00708   }
00709   inline skStatListNode * getElse(){
00710     return m_Else;
00711   }
00712 #ifdef _DEBUG_SIZE
00713   virtual USize getSize() const {
00714     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00715     if (m_Else)
00716       size+=m_Else->getSize();
00717     return size;
00718   }
00719 #endif
00720 #ifndef EXECUTE_PARSENODES
00721  public:
00725   void compile(skCompiledCode& compiled_code);
00726 #endif
00727  private:
00728   skExprNode * m_Expr;
00729   skStatListNode * m_Stats;
00730   skStatListNode * m_Else;
00731 };
00732 class  skReturnNode : public skStatNode {
00733  public:
00734   inline skReturnNode(int linenum,skExprNode * expr) 
00735     : skStatNode(linenum),m_Expr(expr){
00736   }
00737   inline skReturnNode(int linenum) 
00738     : skStatNode(linenum),m_Expr(0){
00739   }
00740   inline ~skReturnNode(){
00741     delete m_Expr;
00742   }
00743   inline void clear(){
00744     m_Expr=0;
00745   }
00746   inline int getType(){
00747     return s_Return;
00748   }
00749   inline skExprNode * getExpr(){
00750     return m_Expr;
00751   }
00752 #ifdef _DEBUG_SIZE
00753   virtual USize getSize() const {
00754     USize size=sizeof(this);
00755     if (m_Expr)
00756       size+=m_Expr->getSize();
00757     retirn size;
00758   }
00759 #endif
00760 #ifndef EXECUTE_PARSENODES
00761  public:
00765   void compile(skCompiledCode& compiled_code);
00766 #endif
00767  private:
00768   skExprNode * m_Expr;
00769 };
00770 class  skWhileNode : public skStatNode {
00771  public:
00772   inline skWhileNode(int linenum,skExprNode * expr,skStatListNode * stat) 
00773     : skStatNode(linenum),m_Expr(expr),m_Stats(stat){
00774   }
00775   inline ~skWhileNode(){
00776     delete m_Expr;
00777     delete m_Stats;
00778   }
00779   inline void clear(){
00780     m_Expr=0;
00781     m_Stats=0;
00782   }
00783   inline int getType(){
00784     return s_While;
00785   }
00786   inline skExprNode * getExpr(){
00787     return m_Expr;
00788   }
00789   inline skStatListNode * getStats(){
00790     return m_Stats;
00791   }
00792 #ifdef _DEBUG_SIZE
00793   virtual USize getSize() const {
00794     return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00795   }
00796 #endif
00797 #ifndef EXECUTE_PARSENODES
00798  public:
00802   void compile(skCompiledCode& compiled_code);
00803 #endif
00804  private:
00805   skExprNode * m_Expr;
00806   skStatListNode * m_Stats;
00807 };
00808 class  skForEachNode : public skStatNode {
00809  public:
00810 #ifdef EXECUTE_PARSENODES
00811   inline skForEachNode(int linenum,skString * id,skExprNode * expr,skStatListNode * stat) 
00812     : skStatNode(linenum),m_Id(*id),m_Expr(expr),m_Stats(stat){
00813   }
00814   inline skForEachNode(int linenum,skString * qualifier,skString * id,skExprNode * expr,skStatListNode * stat) 
00815     : skStatNode(linenum),m_Id(*id),m_Qualifier(*qualifier),m_Expr(expr),m_Stats(stat){
00816   }
00817 #else
00818   inline skForEachNode(int linenum,int id,skExprNode * expr,skStatListNode * stat) 
00819     : skStatNode(linenum),m_Id(id),m_Qualifier(NOT_PRESENT_INDEX),m_Expr(expr),m_Stats(stat){
00820   }
00821   inline skForEachNode(int linenum,int qualifier,int id,skExprNode * expr,skStatListNode * stat) 
00822     : skStatNode(linenum),m_Id(id),m_Qualifier(qualifier),m_Expr(expr),m_Stats(stat){
00823   }
00824 #endif
00825   inline ~skForEachNode(){
00826     delete m_Expr;
00827     delete m_Stats;
00828   }
00829   inline void clear(){
00830     m_Expr=0;
00831     m_Stats=0;
00832   }
00833   inline int getType(){
00834     return s_ForEach;
00835   }
00836   inline skExprNode * getExpr(){
00837     return m_Expr;
00838   }
00839   inline skStatListNode * getStats(){
00840     return m_Stats;
00841   }
00842 #ifdef EXECUTE_PARSENODES
00843   inline skString getId() const{
00844     return m_Id;
00845   }
00846   inline skString getQualifier() const{
00847     return m_Qualifier;
00848   }
00849 #endif
00850 #ifdef _DEBUG_SIZE
00851   virtual USize getSize() const {
00852     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00853 #ifdef EXECUTE_PARSENODES
00854     size+=m_Id.length()+m_Qualifier.length();
00855 #endif
00856     return size;
00857   }
00858 #endif
00859 #ifndef EXECUTE_PARSENODES
00860  public:
00864   void compile(skCompiledCode& compiled_code);
00865 #endif
00866  private:
00867 #ifdef EXECUTE_PARSENODES
00868   skString m_Id;
00869   skString m_Qualifier;
00870 #else
00871   int m_Id;
00872   int m_Qualifier;
00873 #endif
00874   skExprNode * m_Expr;
00875   skStatListNode * m_Stats;
00876 };
00877 class  skForNode : public skStatNode {
00878  public:
00879 #ifdef EXECUTE_PARSENODES
00880   inline skForNode(int linenum,skString * id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat) 
00881     : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00882     m_Stats=stat;
00883   }
00884   inline skForNode(int linenum,skString *id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat) 
00885     : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00886   }
00887 #else
00888   inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat) 
00889     : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00890     m_Stats=stat;
00891   }
00892   inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat) 
00893     : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00894   }
00895 #endif
00896   inline ~skForNode(){
00897     delete m_StartExpr;
00898     delete m_EndExpr;
00899     delete m_StepExpr;
00900     delete m_Stats;
00901   }
00902   inline void clear(){
00903     m_StartExpr=0;
00904     m_EndExpr=0;
00905     m_StepExpr=0;
00906     m_Stats=0;
00907   }
00908   inline int getType(){
00909     return s_For;
00910   }
00911   inline skExprNode * getStartExpr(){
00912     return m_StartExpr;
00913   }
00914   inline skExprNode * getEndExpr(){
00915     return m_EndExpr;
00916   }
00917   inline skExprNode * getStepExpr(){
00918     return m_StepExpr;
00919   }
00920   inline skStatListNode * getStats(){
00921     return m_Stats;
00922   }
00923 #ifdef EXECUTE_PARSENODES
00924   inline skString getId() const{
00925     return m_Id;
00926   }
00927 #endif
00928 #ifdef _DEBUG_SIZE
00929   virtual USize getSize() const {
00930     USize size=sizeof(this)+sizeof(void *)+m_StartExpr->getSize()+m_EndExpr->getSize()+m_Stats->getSize();
00931 #ifdef EXECUTE_PARSENODES
00932     size+=m_Id.length();
00933 #endif
00934     if (m_StepExpr)
00935       size+=m_StepExpr->getSize();
00936     return size;
00937   }
00938 #endif
00939 #ifndef EXECUTE_PARSENODES
00940  public:
00944   void compile(skCompiledCode& compiled_code);
00945 #endif
00946  private:
00947 #ifdef EXECUTE_PARSENODES
00948   skString m_Id;
00949 #else
00950   int m_Id;
00951 #endif
00952   skExprNode * m_StartExpr;
00953   skExprNode * m_EndExpr;
00954   skExprNode * m_StepExpr;
00955   skStatListNode * m_Stats;
00956 };
00957 class  skAssignNode : public skStatNode {
00958  public:
00959 #ifdef EXECUTE_PARSENODES
00960   inline skAssignNode(int linenum,skIdListNode * idlist, skString * attribute,skExprNode * expr) 
00961     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00962     m_Ids->setAttribute(attribute);
00963   }
00964 #else
00965   inline skAssignNode(int linenum,skIdListNode * idlist, int attribute,skExprNode * expr) 
00966     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00967     m_Ids->setAttribute(attribute);
00968   }
00969 #endif
00970   inline skAssignNode(int linenum,skIdListNode * idlist, skExprNode * expr) 
00971     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00972   }
00973   inline ~skAssignNode(){
00974     delete m_Ids;
00975     delete m_Expr;
00976   }
00977   inline void clear(){
00978     m_Ids=0;
00979     m_Expr=0;
00980   }
00981   inline int getType(){
00982     return s_Assign;
00983   }
00984   inline skExprNode * getExpr(){
00985     return m_Expr;
00986   }
00987   inline skIdListNode * getIds(){
00988     return m_Ids;
00989   }
00990 #ifdef _DEBUG_SIZE
00991   virtual USize getSize() const {
00992     return sizeof(this)+sizeof(void *)+m_Ids->getSize()+m_Expr->getSize();
00993   }
00994 #endif
00995 #ifndef EXECUTE_PARSENODES
00996  public:
01000   void compile(skCompiledCode& compiled_code);
01001 #endif
01002  private:
01003   skIdListNode * m_Ids;
01004   skExprNode * m_Expr;
01005 };
01006 class  skMethodStatNode : public skStatNode {
01007  public:
01008   inline skMethodStatNode(int linenum,skIdListNode * idlist) 
01009     : skStatNode(linenum),m_Ids(idlist){
01010   }
01011   inline ~skMethodStatNode(){
01012     delete m_Ids;
01013   }
01014   inline void clear(){
01015     m_Ids->clear();
01016     m_Ids=0;
01017   }
01018   inline int getType(){
01019     return s_Method;
01020   }
01021   inline skIdListNode * getIds(){
01022     return m_Ids;
01023   }
01024 #ifdef _DEBUG_SIZE
01025   virtual USize getSize() const {
01026     return sizeof(this)+sizeof(void *)+m_Ids->getSize();
01027   }
01028 #endif
01029 #ifndef EXECUTE_PARSENODES
01030 
01033   void compile(skCompiledCode& compiled_code);
01034 #endif
01035  private:
01036   skIdListNode * m_Ids;
01037 };
01038 class  skLiteralNode : public skExprNode {
01039  public:
01040   inline skLiteralNode(int linenum,skString * s) 
01041     : skExprNode(linenum),m_String(s),m_Type(s_String){
01042   }
01043   inline skLiteralNode(int linenum,int i)
01044     : skExprNode(linenum),m_Int(i),m_Type(s_Integer){
01045   }
01046   inline skLiteralNode(int linenum,Char i)
01047     : skExprNode(linenum),m_Char(i),m_Type(s_Character){
01048   }
01049 #ifdef USE_FLOATING_POINT
01050   inline skLiteralNode(int linenum,float f)
01051     : skExprNode(linenum),m_Float(f),m_Type(s_Float){
01052   }
01053 #endif
01054   inline ~skLiteralNode(){
01055     if (m_Type==s_String)
01056       delete m_String;
01057   }
01058   inline void clear(){
01059     m_String=0;
01060   }
01061   inline int getType(){
01062     return m_Type;
01063   }
01064   inline skString getString() {
01065     return * m_String;
01066   }
01067 #ifdef USE_FLOATING_POINT
01068   inline float getFloat(){
01069     return m_Float;
01070   }
01071 #endif
01072   inline int getInt(){
01073     return m_Int;
01074   }
01075   inline Char getChar(){
01076     return m_Char;
01077   }
01078 #ifdef _DEBUG_SIZE
01079   virtual USize getSize() const {
01080     USize size=sizeof(this)+sizeof(void *);
01081     if (m_Type==s_String)
01082       size+=sizeof(skString)+m_String->length();
01083     return size;
01084   }
01085 #endif
01086 #ifndef EXECUTE_PARSENODES
01087 
01090   void compile(skCompiledCode& compiled_code);
01091 #endif
01092  private:
01093   unsigned char m_Type;
01094   union {
01095     skString * m_String;
01096 #ifdef USE_FLOATING_POINT
01097     float m_Float;
01098 #endif
01099     int m_Int;
01100     Char m_Char;
01101   };
01102 };
01103 class  skOpNode : public skExprNode {
01104  public:
01105   inline skOpNode(int linenum,int type,skExprNode * expr1,skExprNode * expr2)
01106     : skExprNode(linenum),m_Expr1(expr1),m_Expr2(expr2),m_Type(type){
01107   }
01108   virtual ~skOpNode(){
01109     delete m_Expr1;
01110     delete m_Expr2;
01111   }
01112   inline void clear(){
01113     m_Expr1=0;
01114     m_Expr2=0;
01115   }
01116   inline int getType(){
01117     return m_Type;
01118   }
01119   inline skExprNode * getExpr1(){
01120     return m_Expr1;
01121   }
01122   inline skExprNode * getExpr2(){
01123     return m_Expr2;
01124   }
01125 #ifdef _DEBUG_SIZE
01126   virtual USize getSize() const {
01127     USize size=sizeof(this)+sizeof(void *)+m_Expr1->getSize();
01128     if (m_Expr2)
01129       size+=m_Expr2->getSize();
01130     return size;
01131   }
01132 #endif
01133 #ifndef EXECUTE_PARSENODES
01134 
01137   void compile(skCompiledCode& compiled_code);
01138 #endif
01139  private:
01140   skExprNode * m_Expr1;
01141   skExprNode * m_Expr2;
01142   unsigned char m_Type;
01143 };
01148 class  skMethodDefNode : public skParseNode {
01149  public:
01151   inline skMethodDefNode(int linenum,skStatListNode * stats) 
01152     : skParseNode(linenum),m_Stats(stats),m_Params(0){
01153   }
01155   inline skMethodDefNode(int linenum,skIdListNode * params,skStatListNode * stats) 
01156     : skParseNode(linenum),m_Stats(stats),m_Params(params){
01157   }
01159   inline ~skMethodDefNode(){
01160     delete m_Stats;
01161     delete m_Params;
01162   }
01164   inline void clear(){
01165     m_Stats=0;
01166     m_Params=0;
01167   }
01168   inline int getType(){
01169     return s_MethodDef;
01170   }
01171   inline skIdListNode * getParams(){
01172     return m_Params;
01173   }
01174   inline void setParams(skIdListNode * p){
01175     m_Params=p;
01176   }
01177   inline skStatListNode * getStats(){
01178     return m_Stats;
01179   }
01180  private:
01182   skStatListNode * m_Stats;
01184   skIdListNode * m_Params;
01185   skMethodDefNode(const skMethodDefNode& ) 
01186     : skParseNode(0){
01187   }
01188   skMethodDefNode& operator=(const skMethodDefNode&){
01189     return *this;
01190   }
01191 #ifdef _DEBUG_SIZE
01192   virtual USize getSize() const {
01193     return m_Stats->getSize();
01194   }
01195 #endif
01196 #ifndef EXECUTE_PARSENODES
01197  public:
01201   void compile();
01202   skCompiledCode& getCompiledCode(){
01203     return m_Compiled;
01204   }
01205  private:
01206   skCompiledCode m_Compiled;
01207 #endif
01208 };
01209 #include "skParseNode.inl"
01210 #endif
01211 

Generated on Thu Nov 20 15:48:33 2003 for Simkin by doxygen1.3