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.1 2003/04/14 15:53:25 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
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_NUMCODES
00128 };
00129 
00131   void addInstruction(skInstruction instruction,int parameter1,int parameter2);
00135   int addId(const skString& id);
00139   int addString(const skString& id);
00143   int addInt(int i);
00144 #ifdef USE_FLOATING_POINT
00145 
00148   int addFloat(float f);
00149 #endif
00150 
00153   void setInstruction(USize pc,skInstruction instruction,int parameter1,int parameter2);
00157   void getInstruction(USize pc,skInstruction& instruction,int& parameter1,int& parameter2);
00161   void getInstruction(USize pc,skInstruction& instruction,int& parameter1,bool& parameter2);
00165   skString getId(int id);
00169   int getInt(int id);
00173   skString getString(int id);
00174 #ifdef USE_FLOATING_POINT
00175 
00178   float getFloat(int id);
00179 #endif
00180 
00183   USize getPC() const;
00184 #ifdef _DEBUG_SIZE
00185 
00188   USize getSize() const;
00189 #endif
00190 
00193   void moveIdentifiers(skStringList& identifiers);
00194  private:
00198   skTVAList<USize> m_Instructions;
00202   skStringList m_LiteralStrings;
00206   skStringList m_Identifiers;
00210   skTVAList<int> m_LiteralInts;
00211 #ifdef USE_FLOATING_POINT
00212 
00215   skTVAList<float> m_LiteralFloats;
00216 #endif
00217 };
00218 #endif
00219 
00223 class  skParseNode 
00224 #ifdef __SYMBIAN32__
00225 : public CBase
00226 #endif
00227 {
00228  public:
00231   skParseNode(int linenum){
00232     m_LineNum=linenum;
00233   }
00235   virtual ~skParseNode(){
00236   }
00238   virtual int getType(){
00239     return 0;
00240   }
00242   virtual void clear(){
00243   }
00244   int getLineNum() const{
00245     return m_LineNum;
00246   }
00247 #ifdef _DEBUG_SIZE
00248   virtual USize getSize() const=0;
00249 #endif
00250  protected:
00252   int m_LineNum;
00253  private:
00254   skParseNode(const skParseNode& ){
00255   }
00256   skParseNode& operator=(const skParseNode&){
00257     return *this;
00258   }
00259 };
00260 class  skParseNodeList : public skTAList<skParseNode>{
00261 };
00262 typedef  skTAListIterator<skParseNode> skParseNodeListIterator;
00263 class  skStatNode : public skParseNode {
00264  public:
00265   skStatNode(int linenum) 
00266     : skParseNode(linenum){
00267   }
00268   virtual ~skStatNode(){
00269   }
00270 #ifdef _DEBUG_SIZE
00271   virtual USize getSize() const {
00272     return sizeof(this)+sizeof(void *);
00273   }
00274 #endif
00275 #ifndef EXECUTE_PARSENODES
00276  public:
00280   virtual void compile(skCompiledCode& compiled_code);
00281 #endif
00282 };
00283 class  skExprNode : public skParseNode {
00284  public:
00285   skExprNode(int linenum) 
00286     : skParseNode(linenum){
00287   }
00288   virtual ~skExprNode(){
00289   }
00290 #ifndef EXECUTE_PARSENODES
00291 
00294   virtual void compile(skCompiledCode& compiled_code)=0;
00295 #endif
00296 };
00297 #ifndef EXECUTE_PARSENODES
00298 class skCompiledExprNode : public skParseNode{
00299  public:
00300   skCompiledExprNode(skExprNode * node)
00301     : skParseNode(0),m_Node(node)
00302     {
00303   }
00304   skCompiledCode& getCompiledCode(){
00305     return m_Compiled;
00306   }
00307   void compile();
00308 #ifdef _DEBUG_SIZE
00309   USize getSize() const{
00310     USize size=m_Compiled.getSize();
00311     if (m_Node)
00312       size+=m_Node->getSize();
00313     return size;
00314   }
00315 #endif
00316  private:
00317   skExprNode * m_Node;
00318   skCompiledCode m_Compiled;
00319 };
00320 #endif
00321 typedef skTAList<skStatNode> skStatList;
00322 typedef skTAListIterator<skStatNode> skStatListIterator;
00323 
00324 class  skStatListNode : public skParseNode {
00325  public:
00326   skStatListNode(int linenum)
00327     : skParseNode(linenum){
00328   }
00329   inline ~skStatListNode(){
00330     m_Stats.clearAndDestroy();
00331   }
00335   inline void addStat(skStatNode * stat){
00336     m_Stats.append(stat);
00337   }
00338   inline void clear(){
00339     m_Stats.clear();
00340   }
00341   inline USize numStats(){
00342     return m_Stats.entries();
00343   }
00344   inline skStatNode * getStat(USize i){
00345     return m_Stats[i];
00346   }
00347 #ifdef _DEBUG_SIZE
00348   virtual USize getSize() const {
00349     USize size=sizeof(this)+sizeof(void *);
00350     for (USize i=0;i<m_Stats.entries();i++)
00351       size+=+m_Stats[i]->getSize();
00352     size+=m_Stats.getArraySize()*sizeof(skStatNode *);
00353     return size;
00354   }
00355 #endif
00356 #ifndef EXECUTE_PARSENODES
00357  public:
00361   void compile(skCompiledCode& compiled_code);
00362 #endif
00363  private:
00364   skStatList m_Stats;
00365 };
00366 typedef skTAList<skExprNode> skExprList;
00367 typedef skTAListIterator<skExprNode> skExprListIterator;
00368 class  skExprListNode : public skParseNode {
00369  public:
00370   skExprListNode(int linenum)
00371     : skParseNode(linenum){
00372   }
00373   inline ~skExprListNode(){
00374     m_Exprs.clearAndDestroy();
00375   }
00379   inline void addExpr(skExprNode * expr){
00380     m_Exprs.append(expr);
00381   }
00382   inline int numExprs(){
00383     return m_Exprs.entries();
00384   }
00385   inline void clear(){
00386     m_Exprs.clear();
00387   }
00388   skExprList& getExprs(){
00389     return m_Exprs;
00390   }
00391 #ifdef _DEBUG_SIZE
00392   virtual USize getSize() const {
00393     USize size=sizeof(this)+sizeof(void *);
00394     for (USize i=0;i<m_Exprs.entries();i++)
00395       size+=+m_Exprs[i]->getSize();
00396     size+=m_Exprs.getArraySize()*sizeof(skExprNode *);
00397     return size;
00398   }
00399 #endif
00400 #ifndef EXECUTE_PARSENODES
00401 
00404   void compile(skCompiledCode& compiled_code);
00405 #endif
00406  private:
00407   skExprList m_Exprs;
00408 };
00409 class  skIdNode : public skExprNode {
00410  public:
00411 #ifdef EXECUTE_PARSENODES
00412   inline skIdNode(int linenum,skString * id,skExprNode * arrayIndex,skExprListNode * exprs) 
00413     : skExprNode(linenum),m_Id(*id),m_Exprs(exprs),m_ArrayIndex(arrayIndex)
00414     {
00415   }
00416 #else
00417   inline skIdNode(int linenum,int id,skExprNode * arrayIndex,skExprListNode * exprs) 
00418     : skExprNode(linenum),m_Id(id),m_Exprs(exprs),m_ArrayIndex(arrayIndex)
00419     {
00420   }
00421 #endif
00422   inline ~skIdNode(){
00423     delete m_Exprs;
00424     delete m_ArrayIndex;
00425   }
00426   inline void clear(){
00427     m_Exprs=0;
00428     m_ArrayIndex=0;
00429   }
00430   inline int getType(){
00431     return s_Id;
00432   }
00433 #ifdef EXECUTE_PARSENODES
00434   inline skString getId() const{
00435     return m_Id;
00436   }
00437 #else
00438   inline int getId() const{
00439     return m_Id;
00440   }
00441 #endif
00442   inline skExprListNode * getExprs(){
00443     return m_Exprs;
00444   }
00445   inline skExprNode * getArrayIndex(){
00446     return m_ArrayIndex;
00447   }
00448 #ifdef _DEBUG_SIZE
00449   virtual USize getSize() const {
00450     USize size=sizeof(this)+sizeof(void *);
00451 #ifdef EXECUTE_PARSENODES
00452     size+=m_Id.length();
00453 #endif
00454     if (m_Exprs)
00455       size+=m_Exprs->getSize();
00456     if (m_ArrayIndex)
00457       size+=m_ArrayIndex->getSize();
00458     return size;
00459   }
00460 #endif
00461 #ifndef EXECUTE_PARSENODES
00462 
00465   virtual void compile(skCompiledCode& compiled_code);
00466 #endif
00467  private:
00468 #ifdef EXECUTE_PARSENODES
00469   skString m_Id;
00470 #else
00471   int m_Id;
00472 #endif
00473   skExprListNode * m_Exprs;
00474   skExprNode * m_ArrayIndex;
00475 };
00476 class  skIdNodeList : public skTAList<skIdNode>{
00477 };
00478 typedef  skTAListIterator<skIdNode> skIdNodeListIterator;
00479 class  skIdListNode : public skExprNode {
00480  public:
00481   inline skIdListNode(int linenum) 
00482     : skExprNode(linenum)
00483 #ifndef EXECUTE_PARSENODES
00484     ,m_Attribute(NOT_PRESENT_INDEX)
00485 #endif
00486     {
00487   }
00488   inline ~skIdListNode(){
00489     m_Ids.clearAndDestroy();
00490   }
00494   inline void addId(skIdNode * node){
00495     m_Ids.append(node);
00496   }
00500   inline void prependId(skIdNode * node){
00501     m_Ids.prepend(node);
00502   }
00503   inline USize numIds(){
00504     return m_Ids.entries();
00505   }
00506   inline void clear(){
00507     m_Ids.clear();
00508   }
00509   inline skIdNode * getLastId(){
00510     return m_Ids[m_Ids.entries()-1];
00511   }
00512   inline skIdNode * getId(USize i){
00513     return m_Ids[i];
00514   }
00515   inline int getType(){
00516     return s_IdList;
00517   }
00518 #ifdef EXECUTE_PARSENODES
00519   inline void setAttribute(skString * attr){
00520     m_Attribute=*attr;
00521   }
00522   inline skString getAttribute() const {
00523     return m_Attribute;
00524   }
00525 #else
00526   inline void setAttribute(int attr){
00527     m_Attribute=attr;
00528   }
00529 #endif
00530 #ifdef _DEBUG_SIZE
00531   virtual USize getSize() const {
00532     USize size=sizeof(this)+sizeof(void *);
00533 #ifdef EXECUTE_PARSENODES
00534     size+=m_Attribute.length();
00535 #endif
00536     for (USize i=0;i<m_Ids.entries();i++)
00537       size+=m_Ids[i]->getSize();
00538     size+=m_Ids.getArraySize()*sizeof(skIdNode *);
00539     return size;
00540   }
00541 #endif
00542 #ifndef EXECUTE_PARSENODES
00543 
00546   void compile(skCompiledCode& compiled_code);
00547 #endif
00548  private:
00549 #ifdef EXECUTE_PARSENODES
00550   skString m_Attribute;
00551 #else
00552   int m_Attribute;
00553 #endif
00554   skIdNodeList m_Ids;
00555 };
00556 class  skCaseNode : public skParseNode {
00557  public:
00558   inline skCaseNode(int linenum,skExprNode * expr,skStatListNode * stat) 
00559     : skParseNode(linenum), m_Expr(expr),m_Stats(stat){
00560   }
00561   inline ~skCaseNode(){
00562     delete m_Expr;
00563     delete m_Stats;
00564   }
00565   inline void clear(){
00566     m_Expr=0;
00567     m_Stats=0;
00568   }
00569   inline int getType(){
00570     return s_Case;
00571   }
00572   inline skExprNode * getExpr(){
00573     return m_Expr;
00574   }
00575   inline skStatListNode * getStats(){
00576     return m_Stats;
00577   }
00578 #ifdef _DEBUG_SIZE
00579   virtual USize getSize() const {
00580     return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00581   }
00582 #endif
00583 #ifndef EXECUTE_PARSENODES
00584 
00587   void compile(skCompiledCode& compiled_code);
00588 #endif
00589  private:
00590   skExprNode * m_Expr;
00591   skStatListNode * m_Stats;
00592 };
00593 typedef skTAList<skCaseNode> skCaseList;
00594 typedef skTAListIterator<skCaseNode> skCaseListIterator;
00595 class  skCaseListNode : public skParseNode {
00596  public:
00597   inline skCaseListNode(int linenum) 
00598     : skParseNode(linenum){
00599   }
00600   inline ~skCaseListNode(){
00601     m_Cases.clearAndDestroy();
00602   }
00606   inline void addCase(skCaseNode * expr){
00607     m_Cases.append(expr);
00608   }
00609   inline int numCases(){
00610     return m_Cases.entries();;
00611   }
00612   inline void clear(){
00613     m_Cases.clear();
00614   }
00615   inline skCaseList& getCases(){
00616     return m_Cases;
00617   }
00618 #ifdef _DEBUG_SIZE
00619   virtual USize getSize() const {
00620     USize size=sizeof(this)+sizeof(void *);
00621     for (USize i=0;i<m_Cases.entries();i++)
00622       size+=m_Cases[i]->getSize();
00623     size+=m_Cases.getArraySize()*sizeof(skCaseNode*);
00624     return size;
00625   }
00626 #endif
00627 #ifndef EXECUTE_PARSENODES
00628  public:
00632   void compile(skCompiledCode& compiled_code);
00633 #endif
00634  private:
00635   skCaseList m_Cases;
00636 };
00637 class  skSwitchNode : public skStatNode {
00638  public:
00639   inline skSwitchNode(int linenum,skExprNode * expr,skCaseListNode * cases,skStatListNode * defaultStat) 
00640     : skStatNode(linenum),m_Expr(expr),m_Cases(cases),m_Default(defaultStat){
00641   }
00642   inline ~skSwitchNode(){
00643     delete m_Expr;
00644     delete m_Cases;
00645     delete m_Default;
00646   }
00647   inline void clear(){
00648     m_Expr=0;
00649     m_Cases=0;
00650     m_Default=0;
00651   }
00652   inline int getType(){
00653     return s_Switch;
00654   }
00655   inline skExprNode * getExpr(){
00656     return m_Expr;
00657   }
00658   inline skCaseListNode * getCases(){
00659     return m_Cases;
00660   }
00661   inline skStatListNode * getDefault(){
00662     return m_Default;
00663   }
00664 #ifdef _DEBUG_SIZE
00665   virtual USize getSize() const {
00666     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Cases->getSize();
00667     if (m_Default)
00668       size+=m_Default->getSize();
00669     return size;
00670   }
00671 #endif
00672 #ifndef EXECUTE_PARSENODES
00673  public:
00677   void compile(skCompiledCode& compiled_code);
00678 #endif
00679  private:
00680   skExprNode * m_Expr;
00681   skCaseListNode * m_Cases;
00682   skStatListNode * m_Default;
00683 };
00684 class  skIfNode : public skStatNode {
00685  public:
00686   inline skIfNode(int linenum,skExprNode * expr,skStatListNode * stat,skStatListNode * elseStat) 
00687     : skStatNode(linenum),m_Expr(expr),m_Stats(stat),m_Else(elseStat){
00688   }
00689   inline ~skIfNode(){
00690     delete m_Expr;
00691     delete m_Stats;
00692     delete m_Else;
00693   }
00694   inline void clear(){
00695     m_Expr=0;
00696     m_Stats=0;
00697     m_Else=0;
00698   }
00699   inline int getType(){
00700     return s_If;
00701   }
00702   inline skExprNode * getExpr(){
00703     return m_Expr;
00704   }
00705   inline skStatListNode * getStats(){
00706     return m_Stats;
00707   }
00708   inline skStatListNode * getElse(){
00709     return m_Else;
00710   }
00711 #ifdef _DEBUG_SIZE
00712   virtual USize getSize() const {
00713     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00714     if (m_Else)
00715       size+=m_Else->getSize();
00716     return size;
00717   }
00718 #endif
00719 #ifndef EXECUTE_PARSENODES
00720  public:
00724   void compile(skCompiledCode& compiled_code);
00725 #endif
00726  private:
00727   skExprNode * m_Expr;
00728   skStatListNode * m_Stats;
00729   skStatListNode * m_Else;
00730 };
00731 class  skReturnNode : public skStatNode {
00732  public:
00733   inline skReturnNode(int linenum,skExprNode * expr) 
00734     : skStatNode(linenum),m_Expr(expr){
00735   }
00736   inline ~skReturnNode(){
00737     delete m_Expr;
00738   }
00739   inline void clear(){
00740     m_Expr=0;
00741   }
00742   inline int getType(){
00743     return s_Return;
00744   }
00745   inline skExprNode * getExpr(){
00746     return m_Expr;
00747   }
00748 #ifdef _DEBUG_SIZE
00749   virtual USize getSize() const {
00750     return sizeof(this)+sizeof(void *)+m_Expr->getSize();
00751   }
00752 #endif
00753 #ifndef EXECUTE_PARSENODES
00754  public:
00758   void compile(skCompiledCode& compiled_code);
00759 #endif
00760  private:
00761   skExprNode * m_Expr;
00762 };
00763 class  skWhileNode : public skStatNode {
00764  public:
00765   inline skWhileNode(int linenum,skExprNode * expr,skStatListNode * stat) 
00766     : skStatNode(linenum),m_Expr(expr),m_Stats(stat){
00767   }
00768   inline ~skWhileNode(){
00769     delete m_Expr;
00770     delete m_Stats;
00771   }
00772   inline void clear(){
00773     m_Expr=0;
00774     m_Stats=0;
00775   }
00776   inline int getType(){
00777     return s_While;
00778   }
00779   inline skExprNode * getExpr(){
00780     return m_Expr;
00781   }
00782   inline skStatListNode * getStats(){
00783     return m_Stats;
00784   }
00785 #ifdef _DEBUG_SIZE
00786   virtual USize getSize() const {
00787     return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00788   }
00789 #endif
00790 #ifndef EXECUTE_PARSENODES
00791  public:
00795   void compile(skCompiledCode& compiled_code);
00796 #endif
00797  private:
00798   skExprNode * m_Expr;
00799   skStatListNode * m_Stats;
00800 };
00801 class  skForEachNode : public skStatNode {
00802  public:
00803 #ifdef EXECUTE_PARSENODES
00804   inline skForEachNode(int linenum,skString * id,skExprNode * expr,skStatListNode * stat) 
00805     : skStatNode(linenum),m_Id(*id),m_Expr(expr),m_Stats(stat){
00806   }
00807   inline skForEachNode(int linenum,skString * qualifier,skString * id,skExprNode * expr,skStatListNode * stat) 
00808     : skStatNode(linenum),m_Id(*id),m_Qualifier(*qualifier),m_Expr(expr),m_Stats(stat){
00809   }
00810 #else
00811   inline skForEachNode(int linenum,int id,skExprNode * expr,skStatListNode * stat) 
00812     : skStatNode(linenum),m_Id(id),m_Qualifier(NOT_PRESENT_INDEX),m_Expr(expr),m_Stats(stat){
00813   }
00814   inline skForEachNode(int linenum,int qualifier,int id,skExprNode * expr,skStatListNode * stat) 
00815     : skStatNode(linenum),m_Id(id),m_Qualifier(qualifier),m_Expr(expr),m_Stats(stat){
00816   }
00817 #endif
00818   inline ~skForEachNode(){
00819     delete m_Expr;
00820     delete m_Stats;
00821   }
00822   inline void clear(){
00823     m_Expr=0;
00824     m_Stats=0;
00825   }
00826   inline int getType(){
00827     return s_ForEach;
00828   }
00829   inline skExprNode * getExpr(){
00830     return m_Expr;
00831   }
00832   inline skStatListNode * getStats(){
00833     return m_Stats;
00834   }
00835 #ifdef EXECUTE_PARSENODES
00836   inline skString getId() const{
00837     return m_Id;
00838   }
00839   inline skString getQualifier() const{
00840     return m_Qualifier;
00841   }
00842 #endif
00843 #ifdef _DEBUG_SIZE
00844   virtual USize getSize() const {
00845     USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00846 #ifdef EXECUTE_PARSENODES
00847     size+=m_Id.length()+m_Qualifier.length();
00848 #endif
00849     return size;
00850   }
00851 #endif
00852 #ifndef EXECUTE_PARSENODES
00853  public:
00857   void compile(skCompiledCode& compiled_code);
00858 #endif
00859  private:
00860 #ifdef EXECUTE_PARSENODES
00861   skString m_Id;
00862   skString m_Qualifier;
00863 #else
00864   int m_Id;
00865   int m_Qualifier;
00866 #endif
00867   skExprNode * m_Expr;
00868   skStatListNode * m_Stats;
00869 };
00870 class  skForNode : public skStatNode {
00871  public:
00872 #ifdef EXECUTE_PARSENODES
00873   inline skForNode(int linenum,skString * id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat) 
00874     : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00875     m_Stats=stat;
00876   }
00877   inline skForNode(int linenum,skString *id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat) 
00878     : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00879   }
00880 #else
00881   inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat) 
00882     : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00883     m_Stats=stat;
00884   }
00885   inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat) 
00886     : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00887   }
00888 #endif
00889   inline ~skForNode(){
00890     delete m_StartExpr;
00891     delete m_EndExpr;
00892     delete m_StepExpr;
00893     delete m_Stats;
00894   }
00895   inline void clear(){
00896     m_StartExpr=0;
00897     m_EndExpr=0;
00898     m_StepExpr=0;
00899     m_Stats=0;
00900   }
00901   inline int getType(){
00902     return s_For;
00903   }
00904   inline skExprNode * getStartExpr(){
00905     return m_StartExpr;
00906   }
00907   inline skExprNode * getEndExpr(){
00908     return m_EndExpr;
00909   }
00910   inline skExprNode * getStepExpr(){
00911     return m_StepExpr;
00912   }
00913   inline skStatListNode * getStats(){
00914     return m_Stats;
00915   }
00916 #ifdef EXECUTE_PARSENODES
00917   inline skString getId() const{
00918     return m_Id;
00919   }
00920 #endif
00921 #ifdef _DEBUG_SIZE
00922   virtual USize getSize() const {
00923     USize size=sizeof(this)+sizeof(void *)+m_StartExpr->getSize()+m_EndExpr->getSize()+m_Stats->getSize();
00924 #ifdef EXECUTE_PARSENODES
00925     size+=m_Id.length();
00926 #endif
00927     if (m_StepExpr)
00928       size+=m_StepExpr->getSize();
00929     return size;
00930   }
00931 #endif
00932 #ifndef EXECUTE_PARSENODES
00933  public:
00937   void compile(skCompiledCode& compiled_code);
00938 #endif
00939  private:
00940 #ifdef EXECUTE_PARSENODES
00941   skString m_Id;
00942 #else
00943   int m_Id;
00944 #endif
00945   skExprNode * m_StartExpr;
00946   skExprNode * m_EndExpr;
00947   skExprNode * m_StepExpr;
00948   skStatListNode * m_Stats;
00949 };
00950 class  skAssignNode : public skStatNode {
00951  public:
00952 #ifdef EXECUTE_PARSENODES
00953   inline skAssignNode(int linenum,skIdListNode * idlist, skString * attribute,skExprNode * expr) 
00954     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00955     m_Ids->setAttribute(attribute);
00956   }
00957 #else
00958   inline skAssignNode(int linenum,skIdListNode * idlist, int attribute,skExprNode * expr) 
00959     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00960     m_Ids->setAttribute(attribute);
00961   }
00962 #endif
00963   inline skAssignNode(int linenum,skIdListNode * idlist, skExprNode * expr) 
00964     : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00965   }
00966   inline ~skAssignNode(){
00967     delete m_Ids;
00968     delete m_Expr;
00969   }
00970   inline void clear(){
00971     m_Ids=0;
00972     m_Expr=0;
00973   }
00974   inline int getType(){
00975     return s_Assign;
00976   }
00977   inline skExprNode * getExpr(){
00978     return m_Expr;
00979   }
00980   inline skIdListNode * getIds(){
00981     return m_Ids;
00982   }
00983 #ifdef _DEBUG_SIZE
00984   virtual USize getSize() const {
00985     return sizeof(this)+sizeof(void *)+m_Ids->getSize()+m_Expr->getSize();
00986   }
00987 #endif
00988 #ifndef EXECUTE_PARSENODES
00989  public:
00993   void compile(skCompiledCode& compiled_code);
00994 #endif
00995  private:
00996   skIdListNode * m_Ids;
00997   skExprNode * m_Expr;
00998 };
00999 class  skMethodStatNode : public skStatNode {
01000  public:
01001   inline skMethodStatNode(int linenum,skIdListNode * idlist) 
01002     : skStatNode(linenum),m_Ids(idlist){
01003   }
01004   inline ~skMethodStatNode(){
01005     delete m_Ids;
01006   }
01007   inline void clear(){
01008     m_Ids->clear();
01009     m_Ids=0;
01010   }
01011   inline int getType(){
01012     return s_Method;
01013   }
01014   inline skIdListNode * getIds(){
01015     return m_Ids;
01016   }
01017 #ifdef _DEBUG_SIZE
01018   virtual USize getSize() const {
01019     return sizeof(this)+sizeof(void *)+m_Ids->getSize();
01020   }
01021 #endif
01022 #ifndef EXECUTE_PARSENODES
01023 
01026   void compile(skCompiledCode& compiled_code);
01027 #endif
01028  private:
01029   skIdListNode * m_Ids;
01030 };
01031 class  skLiteralNode : public skExprNode {
01032  public:
01033   inline skLiteralNode(int linenum,skString * s) 
01034     : skExprNode(linenum),m_String(s),m_Type(s_String){
01035   }
01036   inline skLiteralNode(int linenum,int i)
01037     : skExprNode(linenum),m_Int(i),m_Type(s_Integer){
01038   }
01039   inline skLiteralNode(int linenum,Char i)
01040     : skExprNode(linenum),m_Char(i),m_Type(s_Character){
01041   }
01042 #ifdef USE_FLOATING_POINT
01043   inline skLiteralNode(int linenum,float f)
01044     : skExprNode(linenum),m_Float(f),m_Type(s_Float){
01045   }
01046 #endif
01047   inline ~skLiteralNode(){
01048     if (m_Type==s_String)
01049       delete m_String;
01050   }
01051   inline void clear(){
01052     m_String=0;
01053   }
01054   inline int getType(){
01055     return m_Type;
01056   }
01057   inline skString getString() {
01058     return * m_String;
01059   }
01060 #ifdef USE_FLOATING_POINT
01061   inline float getFloat(){
01062     return m_Float;
01063   }
01064 #endif
01065   inline int getInt(){
01066     return m_Int;
01067   }
01068   inline Char getChar(){
01069     return m_Char;
01070   }
01071 #ifdef _DEBUG_SIZE
01072   virtual USize getSize() const {
01073     USize size=sizeof(this)+sizeof(void *);
01074     if (m_Type==s_String)
01075       size+=sizeof(skString)+m_String->length();
01076     return size;
01077   }
01078 #endif
01079 #ifndef EXECUTE_PARSENODES
01080 
01083   void compile(skCompiledCode& compiled_code);
01084 #endif
01085  private:
01086   unsigned char m_Type;
01087   union {
01088     skString * m_String;
01089 #ifdef USE_FLOATING_POINT
01090     float m_Float;
01091 #endif
01092     int m_Int;
01093     Char m_Char;
01094   };
01095 };
01096 class  skOpNode : public skExprNode {
01097  public:
01098   inline skOpNode(int linenum,int type,skExprNode * expr1,skExprNode * expr2)
01099     : skExprNode(linenum),m_Expr1(expr1),m_Expr2(expr2),m_Type(type){
01100   }
01101   virtual ~skOpNode(){
01102     delete m_Expr1;
01103     delete m_Expr2;
01104   }
01105   inline void clear(){
01106     m_Expr1=0;
01107     m_Expr2=0;
01108   }
01109   inline int getType(){
01110     return m_Type;
01111   }
01112   inline skExprNode * getExpr1(){
01113     return m_Expr1;
01114   }
01115   inline skExprNode * getExpr2(){
01116     return m_Expr2;
01117   }
01118 #ifdef _DEBUG_SIZE
01119   virtual USize getSize() const {
01120     USize size=sizeof(this)+sizeof(void *)+m_Expr1->getSize();
01121     if (m_Expr2)
01122       size+=m_Expr2->getSize();
01123     return size;
01124   }
01125 #endif
01126 #ifndef EXECUTE_PARSENODES
01127 
01130   void compile(skCompiledCode& compiled_code);
01131 #endif
01132  private:
01133   skExprNode * m_Expr1;
01134   skExprNode * m_Expr2;
01135   unsigned char m_Type;
01136 };
01141 class  skMethodDefNode : public skParseNode {
01142  public:
01144   inline skMethodDefNode(int linenum,skStatListNode * stats) 
01145     : skParseNode(linenum),m_Stats(stats),m_Params(0){
01146   }
01148   inline skMethodDefNode(int linenum,skIdListNode * params,skStatListNode * stats) 
01149     : skParseNode(linenum),m_Stats(stats),m_Params(params){
01150   }
01152   inline ~skMethodDefNode(){
01153     delete m_Stats;
01154     delete m_Params;
01155   }
01157   inline void clear(){
01158     m_Stats=0;
01159     m_Params=0;
01160   }
01161   inline int getType(){
01162     return s_MethodDef;
01163   }
01164   inline skIdListNode * getParams(){
01165     return m_Params;
01166   }
01167   inline void setParams(skIdListNode * p){
01168     m_Params=p;
01169   }
01170   inline skStatListNode * getStats(){
01171     return m_Stats;
01172   }
01173  private:
01175   skStatListNode * m_Stats;
01177   skIdListNode * m_Params;
01178   skMethodDefNode(const skMethodDefNode& ) 
01179     : skParseNode(0){
01180   }
01181   skMethodDefNode& operator=(const skMethodDefNode&){
01182     return *this;
01183   }
01184 #ifdef _DEBUG_SIZE
01185   virtual USize getSize() const {
01186     return m_Stats->getSize();
01187   }
01188 #endif
01189 #ifndef EXECUTE_PARSENODES
01190  public:
01194   void compile();
01195   skCompiledCode& getCompiledCode(){
01196     return m_Compiled;
01197   }
01198  private:
01199   skCompiledCode m_Compiled;
01200 #endif
01201 };
01202 #include "skParseNode.inl"
01203 #endif
01204 

Generated on Mon Apr 14 16:49:22 2003 for Simkin C++ for Windows CE by doxygen1.3