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.3 2003/04/19 17:56:00 simkin_cvs 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(){
00738     delete m_Expr;
00739   }
00740   inline void clear(){
00741     m_Expr=0;
00742   }
00743   inline int getType(){
00744     return s_Return;
00745   }
00746   inline skExprNode * getExpr(){
00747     return m_Expr;
00748   }
00749 #ifdef _DEBUG_SIZE
00750   virtual USize getSize() const {
00751     return sizeof(this)+sizeof(void *)+m_Expr->getSize();
00752   }
00753 #endif
00754 #ifndef EXECUTE_PARSENODES
00755  public:
00759   void compile(skCompiledCode& compiled_code);
00760 #endif
00761  private:
00762   skExprNode * m_Expr;
00763 };
00764 class  skWhileNode : public skStatNode {
00765  public:
00766   inline skWhileNode(int linenum,skExprNode * expr,skStatListNode * stat) 
00767     : skStatNode(linenum),m_Expr(expr),m_Stats(stat){
00768   }
00769   inline ~skWhileNode(){
00770     delete m_Expr;
00771     delete m_Stats;
00772   }
00773   inline void clear(){
00774     m_Expr=0;
00775     m_Stats=0;
00776   }
00777   inline int getType(){
00778     return s_While;
00779   }
00780   inline skExprNode * getExpr(){
00781     return m_Expr;
00782   }
00783   inline skStatListNode * getStats(){
00784     return m_Stats;
00785   }
00786 #ifdef _DEBUG_SIZE
00787   virtual USize getSize() const {
00788     return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00789   }
00790 #endif
00791 #ifndef EXECUTE_PARSENODES
00792  public:
00796   void compile(skCompiledCode& compiled_code);
00797 #endif
00798  private:
00799   skExprNode * m_Expr;
00800   skStatListNode * m_Stats;
00801 };
00802 class  skForEachNode : public skStatNode {
00803  public:
00804 #ifdef EXECUTE_PARSENODES
00805   inline skForEachNode(int linenum,skString * id,skExprNode * expr,skStatListNode * stat) 
00806     : skStatNode(linenum),m_Id(*id),m_Expr(expr),m_Stats(stat){
00807   }
00808   inline skForEachNode(int linenum,skString * qualifier,skString * id,skExprNode * expr,skStatListNode * stat) 
00809     : skStatNode(linenum),m_Id(*id),m_Qualifier(*qualifier),m_Expr(expr),m_Stats(stat){
00810   }
00811 #else
00812   inline skForEachNode(int linenum,int id,skExprNode * expr,skStatListNode * stat) 
00813     : skStatNode(linenum),m_Id(id),m_Qualifier(NOT_PRESENT_INDEX),m_Expr(expr),m_Stats(stat){
00814   }
00815   inline skForEachNode(int linenum,int qualifier,int id,skExprNode * expr,skStatListNode * stat) 
00816     : skStatNode(linenum),m_Id(id),m_Qualifier(qualifier),m_Expr(expr),m_Stats(stat){
00817   }
00818 #endif
00819   inline ~skForEachNode(){
00820     delete m_Expr;
00821     delete m_Stats;
00822   }
00823   inline void clear(){
00824     m_Expr=0;
00825     m_Stats=0;
00826   }
00827   inline int getType(){
00828     return s_ForEach;
00829   }
00830   inline skExprNode * getExpr(){
00831     return m_Expr;
00832   }
00833   inline skStatListNode * getStats(){
00834     return m_Stats;
00835   }
00836 #ifdef EXECUTE_PARSENODES
00837   inline skString getId() const{
00838     return m_Id;
00839   }
00840   inline skString getQualifier() const{
00841     return m_Qualifier;
00842   }
00843 #endif
00844 #ifdef _DEBUG_SIZE
00845   virtual USize getSize() const {
00846     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00847 #ifdef EXECUTE_PARSENODES
00848     size+=m_Id.length()+m_Qualifier.length();
00849 #endif
00850     return size;
00851   }
00852 #endif
00853 #ifndef EXECUTE_PARSENODES
00854  public:
00858   void compile(skCompiledCode& compiled_code);
00859 #endif
00860  private:
00861 #ifdef EXECUTE_PARSENODES
00862   skString m_Id;
00863   skString m_Qualifier;
00864 #else
00865   int m_Id;
00866   int m_Qualifier;
00867 #endif
00868   skExprNode * m_Expr;
00869   skStatListNode * m_Stats;
00870 };
00871 class  skForNode : public skStatNode {
00872  public:
00873 #ifdef EXECUTE_PARSENODES
00874   inline skForNode(int linenum,skString * id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat) 
00875     : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00876     m_Stats=stat;
00877   }
00878   inline skForNode(int linenum,skString *id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat) 
00879     : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00880   }
00881 #else
00882   inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat) 
00883     : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00884     m_Stats=stat;
00885   }
00886   inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat) 
00887     : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00888   }
00889 #endif
00890   inline ~skForNode(){
00891     delete m_StartExpr;
00892     delete m_EndExpr;
00893     delete m_StepExpr;
00894     delete m_Stats;
00895   }
00896   inline void clear(){
00897     m_StartExpr=0;
00898     m_EndExpr=0;
00899     m_StepExpr=0;
00900     m_Stats=0;
00901   }
00902   inline int getType(){
00903     return s_For;
00904   }
00905   inline skExprNode * getStartExpr(){
00906     return m_StartExpr;
00907   }
00908   inline skExprNode * getEndExpr(){
00909     return m_EndExpr;
00910   }
00911   inline skExprNode * getStepExpr(){
00912     return m_StepExpr;
00913   }
00914   inline skStatListNode * getStats(){
00915     return m_Stats;
00916   }
00917 #ifdef EXECUTE_PARSENODES
00918   inline skString getId() const{
00919     return m_Id;
00920   }
00921 #endif
00922 #ifdef _DEBUG_SIZE
00923   virtual USize getSize() const {
00924     USize size=sizeof(this)+sizeof(void *)+m_StartExpr->getSize()+m_EndExpr->getSize()+m_Stats->getSize();
00925 #ifdef EXECUTE_PARSENODES
00926     size+=m_Id.length();
00927 #endif
00928     if (m_StepExpr)
00929       size+=m_StepExpr->getSize();
00930     return size;
00931   }
00932 #endif
00933 #ifndef EXECUTE_PARSENODES
00934  public:
00938   void compile(skCompiledCode& compiled_code);
00939 #endif
00940  private:
00941 #ifdef EXECUTE_PARSENODES
00942   skString m_Id;
00943 #else
00944   int m_Id;
00945 #endif
00946   skExprNode * m_StartExpr;
00947   skExprNode * m_EndExpr;
00948   skExprNode * m_StepExpr;
00949   skStatListNode * m_Stats;
00950 };
00951 class  skAssignNode : public skStatNode {
00952  public:
00953 #ifdef EXECUTE_PARSENODES
00954   inline skAssignNode(int linenum,skIdListNode * idlist, skString * attribute,skExprNode * expr) 
00955     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00956     m_Ids->setAttribute(attribute);
00957   }
00958 #else
00959   inline skAssignNode(int linenum,skIdListNode * idlist, int attribute,skExprNode * expr) 
00960     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00961     m_Ids->setAttribute(attribute);
00962   }
00963 #endif
00964   inline skAssignNode(int linenum,skIdListNode * idlist, skExprNode * expr) 
00965     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00966   }
00967   inline ~skAssignNode(){
00968     delete m_Ids;
00969     delete m_Expr;
00970   }
00971   inline void clear(){
00972     m_Ids=0;
00973     m_Expr=0;
00974   }
00975   inline int getType(){
00976     return s_Assign;
00977   }
00978   inline skExprNode * getExpr(){
00979     return m_Expr;
00980   }
00981   inline skIdListNode * getIds(){
00982     return m_Ids;
00983   }
00984 #ifdef _DEBUG_SIZE
00985   virtual USize getSize() const {
00986     return sizeof(this)+sizeof(void *)+m_Ids->getSize()+m_Expr->getSize();
00987   }
00988 #endif
00989 #ifndef EXECUTE_PARSENODES
00990  public:
00994   void compile(skCompiledCode& compiled_code);
00995 #endif
00996  private:
00997   skIdListNode * m_Ids;
00998   skExprNode * m_Expr;
00999 };
01000 class  skMethodStatNode : public skStatNode {
01001  public:
01002   inline skMethodStatNode(int linenum,skIdListNode * idlist) 
01003     : skStatNode(linenum),m_Ids(idlist){
01004   }
01005   inline ~skMethodStatNode(){
01006     delete m_Ids;
01007   }
01008   inline void clear(){
01009     m_Ids->clear();
01010     m_Ids=0;
01011   }
01012   inline int getType(){
01013     return s_Method;
01014   }
01015   inline skIdListNode * getIds(){
01016     return m_Ids;
01017   }
01018 #ifdef _DEBUG_SIZE
01019   virtual USize getSize() const {
01020     return sizeof(this)+sizeof(void *)+m_Ids->getSize();
01021   }
01022 #endif
01023 #ifndef EXECUTE_PARSENODES
01024 
01027   void compile(skCompiledCode& compiled_code);
01028 #endif
01029  private:
01030   skIdListNode * m_Ids;
01031 };
01032 class  skLiteralNode : public skExprNode {
01033  public:
01034   inline skLiteralNode(int linenum,skString * s) 
01035     : skExprNode(linenum),m_String(s),m_Type(s_String){
01036   }
01037   inline skLiteralNode(int linenum,int i)
01038     : skExprNode(linenum),m_Int(i),m_Type(s_Integer){
01039   }
01040   inline skLiteralNode(int linenum,Char i)
01041     : skExprNode(linenum),m_Char(i),m_Type(s_Character){
01042   }
01043 #ifdef USE_FLOATING_POINT
01044   inline skLiteralNode(int linenum,float f)
01045     : skExprNode(linenum),m_Float(f),m_Type(s_Float){
01046   }
01047 #endif
01048   inline ~skLiteralNode(){
01049     if (m_Type==s_String)
01050       delete m_String;
01051   }
01052   inline void clear(){
01053     m_String=0;
01054   }
01055   inline int getType(){
01056     return m_Type;
01057   }
01058   inline skString getString() {
01059     return * m_String;
01060   }
01061 #ifdef USE_FLOATING_POINT
01062   inline float getFloat(){
01063     return m_Float;
01064   }
01065 #endif
01066   inline int getInt(){
01067     return m_Int;
01068   }
01069   inline Char getChar(){
01070     return m_Char;
01071   }
01072 #ifdef _DEBUG_SIZE
01073   virtual USize getSize() const {
01074     USize size=sizeof(this)+sizeof(void *);
01075     if (m_Type==s_String)
01076       size+=sizeof(skString)+m_String->length();
01077     return size;
01078   }
01079 #endif
01080 #ifndef EXECUTE_PARSENODES
01081 
01084   void compile(skCompiledCode& compiled_code);
01085 #endif
01086  private:
01087   unsigned char m_Type;
01088   union {
01089     skString * m_String;
01090 #ifdef USE_FLOATING_POINT
01091     float m_Float;
01092 #endif
01093     int m_Int;
01094     Char m_Char;
01095   };
01096 };
01097 class  skOpNode : public skExprNode {
01098  public:
01099   inline skOpNode(int linenum,int type,skExprNode * expr1,skExprNode * expr2)
01100     : skExprNode(linenum),m_Expr1(expr1),m_Expr2(expr2),m_Type(type){
01101   }
01102   virtual ~skOpNode(){
01103     delete m_Expr1;
01104     delete m_Expr2;
01105   }
01106   inline void clear(){
01107     m_Expr1=0;
01108     m_Expr2=0;
01109   }
01110   inline int getType(){
01111     return m_Type;
01112   }
01113   inline skExprNode * getExpr1(){
01114     return m_Expr1;
01115   }
01116   inline skExprNode * getExpr2(){
01117     return m_Expr2;
01118   }
01119 #ifdef _DEBUG_SIZE
01120   virtual USize getSize() const {
01121     USize size=sizeof(this)+sizeof(void *)+m_Expr1->getSize();
01122     if (m_Expr2)
01123       size+=m_Expr2->getSize();
01124     return size;
01125   }
01126 #endif
01127 #ifndef EXECUTE_PARSENODES
01128 
01131   void compile(skCompiledCode& compiled_code);
01132 #endif
01133  private:
01134   skExprNode * m_Expr1;
01135   skExprNode * m_Expr2;
01136   unsigned char m_Type;
01137 };
01142 class  skMethodDefNode : public skParseNode {
01143  public:
01145   inline skMethodDefNode(int linenum,skStatListNode * stats) 
01146     : skParseNode(linenum),m_Stats(stats),m_Params(0){
01147   }
01149   inline skMethodDefNode(int linenum,skIdListNode * params,skStatListNode * stats) 
01150     : skParseNode(linenum),m_Stats(stats),m_Params(params){
01151   }
01153   inline ~skMethodDefNode(){
01154     delete m_Stats;
01155     delete m_Params;
01156   }
01158   inline void clear(){
01159     m_Stats=0;
01160     m_Params=0;
01161   }
01162   inline int getType(){
01163     return s_MethodDef;
01164   }
01165   inline skIdListNode * getParams(){
01166     return m_Params;
01167   }
01168   inline void setParams(skIdListNode * p){
01169     m_Params=p;
01170   }
01171   inline skStatListNode * getStats(){
01172     return m_Stats;
01173   }
01174  private:
01176   skStatListNode * m_Stats;
01178   skIdListNode * m_Params;
01179   skMethodDefNode(const skMethodDefNode& ) 
01180     : skParseNode(0){
01181   }
01182   skMethodDefNode& operator=(const skMethodDefNode&){
01183     return *this;
01184   }
01185 #ifdef _DEBUG_SIZE
01186   virtual USize getSize() const {
01187     return m_Stats->getSize();
01188   }
01189 #endif
01190 #ifndef EXECUTE_PARSENODES
01191  public:
01195   void compile();
01196   skCompiledCode& getCompiledCode(){
01197     return m_Compiled;
01198   }
01199  private:
01200   skCompiledCode m_Compiled;
01201 #endif
01202 };
01203 #include "skParseNode.inl"
01204 #endif
01205 

Generated on Sat Apr 19 18:54:43 2003 for Simkin C++ for Windows CE by doxygen1.3