00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 static const int s_Break=37;
00062
00063
00064
00065
00066 #ifndef EXECUTE_PARSENODES
00067 const int NOT_PRESENT_INDEX=0xfff;
00068
00085
00086 const int INLINE_INT=((1<<24)/2);
00087 const int PARAM_MASK=0xffffff;
00088 const int PARAM1_MASK=0xfff000;
00089 const int PARAM2_MASK=0x000fff;
00094 class skCompiledCode
00095 #ifdef __SYMBIAN32__
00096 : public CBase
00097 #endif
00098 {
00099 public:
00103 enum skInstruction{
00104 b_NullStat,
00105 b_StatList,
00106 b_Switch,
00107 b_If,
00108 b_Return,
00109 b_While,
00110 b_ForEach,
00111 b_QualifierIndex,
00112 b_For,
00113 b_Assign,
00114 b_Method,
00115 b_IdList,
00116 b_IdWithMethod,
00117 b_Id,
00118 b_ExprList,
00119 b_String,
00120 b_Int,
00121 b_IntInline,
00122 b_Char,
00123 #ifdef USE_FLOATING_POINT
00124 b_Float,
00125 #endif
00126 b_Op,
00127 b_CaseList,
00128 b_StatsSize,
00129 b_Break,
00130 b_NUMCODES
00131 };
00132
00134 void addInstruction(skInstruction instruction,int parameter1,int parameter2);
00138 int addId(const skString& id);
00142 int addString(const skString& id);
00146 int addInt(int i);
00147 #ifdef USE_FLOATING_POINT
00148
00151 int addFloat(float f);
00152 #endif
00153
00156 void setInstruction(USize pc,skInstruction instruction,int parameter1,int parameter2);
00160 void getInstruction(USize pc,skInstruction& instruction,int& parameter1,int& parameter2);
00164 void getInstruction(USize pc,skInstruction& instruction,int& parameter1,bool& parameter2);
00168 skString getId(int id);
00172 int getInt(int id);
00176 skString getString(int id);
00177 #ifdef USE_FLOATING_POINT
00178
00181 float getFloat(int id);
00182 #endif
00183
00186 USize getPC() const;
00187 #ifdef _DEBUG_SIZE
00188
00191 USize getSize() const;
00192 #endif
00193
00196 void moveIdentifiers(skStringList& identifiers);
00197 private:
00201 skTVAList<USize> m_Instructions;
00205 skStringList m_LiteralStrings;
00209 skStringList m_Identifiers;
00213 skTVAList<int> m_LiteralInts;
00214 #ifdef USE_FLOATING_POINT
00215
00218 skTVAList<float> m_LiteralFloats;
00219 #endif
00220 };
00221 #endif
00222
00226 class skParseNode
00227 #ifdef __SYMBIAN32__
00228 : public CBase
00229 #endif
00230 {
00231 public:
00234 skParseNode(int linenum){
00235 m_LineNum=linenum;
00236 }
00238 virtual ~skParseNode(){
00239 }
00241 virtual int getType(){
00242 return 0;
00243 }
00245 virtual void clear(){
00246 }
00247 int getLineNum() const{
00248 return m_LineNum;
00249 }
00250 #ifdef _DEBUG_SIZE
00251 virtual USize getSize() const=0;
00252 #endif
00253 protected:
00255 int m_LineNum;
00256 private:
00257 skParseNode(const skParseNode& ){
00258 }
00259 skParseNode& operator=(const skParseNode&){
00260 return *this;
00261 }
00262 };
00263 class skParseNodeList : public skTAList<skParseNode>{
00264 };
00265 typedef skTAListIterator<skParseNode> skParseNodeListIterator;
00266 class skStatNode : public skParseNode {
00267 public:
00268 skStatNode(int linenum)
00269 : skParseNode(linenum){
00270 }
00271 virtual ~skStatNode(){
00272 }
00273 #ifdef _DEBUG_SIZE
00274 virtual USize getSize() const {
00275 return sizeof(this)+sizeof(void *);
00276 }
00277 #endif
00278 #ifndef EXECUTE_PARSENODES
00279 public:
00283 virtual void compile(skCompiledCode& compiled_code);
00284 #endif
00285 };
00286 class skExprNode : public skParseNode {
00287 public:
00288 skExprNode(int linenum)
00289 : skParseNode(linenum){
00290 }
00291 virtual ~skExprNode(){
00292 }
00293 #ifndef EXECUTE_PARSENODES
00294
00297 virtual void compile(skCompiledCode& compiled_code)=0;
00298 #endif
00299 };
00300 #ifndef EXECUTE_PARSENODES
00301 class skCompiledExprNode : public skParseNode{
00302 public:
00303 skCompiledExprNode(skExprNode * node)
00304 : skParseNode(0),m_Node(node)
00305 {
00306 }
00307 skCompiledCode& getCompiledCode(){
00308 return m_Compiled;
00309 }
00310 void compile();
00311 #ifdef _DEBUG_SIZE
00312 USize getSize() const{
00313 USize size=m_Compiled.getSize();
00314 if (m_Node)
00315 size+=m_Node->getSize();
00316 return size;
00317 }
00318 #endif
00319 private:
00320 skExprNode * m_Node;
00321 skCompiledCode m_Compiled;
00322 };
00323 #endif
00324 typedef skTAList<skStatNode> skStatList;
00325 typedef skTAListIterator<skStatNode> skStatListIterator;
00326
00327 class skStatListNode : public skParseNode {
00328 public:
00329 skStatListNode(int linenum)
00330 : skParseNode(linenum){
00331 }
00332 inline ~skStatListNode(){
00333 m_Stats.clearAndDestroy();
00334 }
00338 inline void addStat(skStatNode * stat){
00339 m_Stats.append(stat);
00340 }
00341 inline void clear(){
00342 m_Stats.clear();
00343 }
00344 inline USize numStats(){
00345 return m_Stats.entries();
00346 }
00347 inline skStatNode * getStat(USize i){
00348 return m_Stats[i];
00349 }
00350 #ifdef _DEBUG_SIZE
00351 virtual USize getSize() const {
00352 USize size=sizeof(this)+sizeof(void *);
00353 for (USize i=0;i<m_Stats.entries();i++)
00354 size+=+m_Stats[i]->getSize();
00355 size+=m_Stats.getArraySize()*sizeof(skStatNode *);
00356 return size;
00357 }
00358 #endif
00359 #ifndef EXECUTE_PARSENODES
00360 public:
00364 void compile(skCompiledCode& compiled_code);
00365 #endif
00366 private:
00367 skStatList m_Stats;
00368 };
00369 typedef skTAList<skExprNode> skExprList;
00370 typedef skTAListIterator<skExprNode> skExprListIterator;
00371 class skExprListNode : public skParseNode {
00372 public:
00373 skExprListNode(int linenum)
00374 : skParseNode(linenum){
00375 }
00376 inline ~skExprListNode(){
00377 m_Exprs.clearAndDestroy();
00378 }
00382 inline void addExpr(skExprNode * expr){
00383 m_Exprs.append(expr);
00384 }
00385 inline int numExprs(){
00386 return m_Exprs.entries();
00387 }
00388 inline void clear(){
00389 m_Exprs.clear();
00390 }
00391 skExprList& getExprs(){
00392 return m_Exprs;
00393 }
00394 #ifdef _DEBUG_SIZE
00395 virtual USize getSize() const {
00396 USize size=sizeof(this)+sizeof(void *);
00397 for (USize i=0;i<m_Exprs.entries();i++)
00398 size+=+m_Exprs[i]->getSize();
00399 size+=m_Exprs.getArraySize()*sizeof(skExprNode *);
00400 return size;
00401 }
00402 #endif
00403 #ifndef EXECUTE_PARSENODES
00404
00407 void compile(skCompiledCode& compiled_code);
00408 #endif
00409 private:
00410 skExprList m_Exprs;
00411 };
00412 class skIdNode : public skExprNode {
00413 public:
00414 #ifdef EXECUTE_PARSENODES
00415 inline skIdNode(int linenum,skString * id,skExprNode * arrayIndex,skExprListNode * exprs)
00416 : skExprNode(linenum),m_Id(*id),m_Exprs(exprs),m_ArrayIndex(arrayIndex)
00417 {
00418 }
00419 #else
00420 inline skIdNode(int linenum,int id,skExprNode * arrayIndex,skExprListNode * exprs)
00421 : skExprNode(linenum),m_Id(id),m_Exprs(exprs),m_ArrayIndex(arrayIndex)
00422 {
00423 }
00424 #endif
00425 inline ~skIdNode(){
00426 delete m_Exprs;
00427 delete m_ArrayIndex;
00428 }
00429 inline void clear(){
00430 m_Exprs=0;
00431 m_ArrayIndex=0;
00432 }
00433 inline int getType(){
00434 return s_Id;
00435 }
00436 #ifdef EXECUTE_PARSENODES
00437 inline skString getId() const{
00438 return m_Id;
00439 }
00440 #else
00441 inline int getId() const{
00442 return m_Id;
00443 }
00444 #endif
00445 inline skExprListNode * getExprs(){
00446 return m_Exprs;
00447 }
00448 inline skExprNode * getArrayIndex(){
00449 return m_ArrayIndex;
00450 }
00451 #ifdef _DEBUG_SIZE
00452 virtual USize getSize() const {
00453 USize size=sizeof(this)+sizeof(void *);
00454 #ifdef EXECUTE_PARSENODES
00455 size+=m_Id.length();
00456 #endif
00457 if (m_Exprs)
00458 size+=m_Exprs->getSize();
00459 if (m_ArrayIndex)
00460 size+=m_ArrayIndex->getSize();
00461 return size;
00462 }
00463 #endif
00464 #ifndef EXECUTE_PARSENODES
00465
00468 virtual void compile(skCompiledCode& compiled_code);
00469 #endif
00470 private:
00471 #ifdef EXECUTE_PARSENODES
00472 skString m_Id;
00473 #else
00474 int m_Id;
00475 #endif
00476 skExprListNode * m_Exprs;
00477 skExprNode * m_ArrayIndex;
00478 };
00479 class skIdNodeList : public skTAList<skIdNode>{
00480 };
00481 typedef skTAListIterator<skIdNode> skIdNodeListIterator;
00482 class skIdListNode : public skExprNode {
00483 public:
00484 inline skIdListNode(int linenum)
00485 : skExprNode(linenum)
00486 #ifndef EXECUTE_PARSENODES
00487 ,m_Attribute(NOT_PRESENT_INDEX)
00488 #endif
00489 {
00490 }
00491 inline ~skIdListNode(){
00492 m_Ids.clearAndDestroy();
00493 }
00497 inline void addId(skIdNode * node){
00498 m_Ids.append(node);
00499 }
00503 inline void prependId(skIdNode * node){
00504 m_Ids.prepend(node);
00505 }
00506 inline USize numIds(){
00507 return m_Ids.entries();
00508 }
00509 inline void clear(){
00510 m_Ids.clear();
00511 }
00512 inline skIdNode * getLastId(){
00513 return m_Ids[m_Ids.entries()-1];
00514 }
00515 inline skIdNode * getId(USize i){
00516 return m_Ids[i];
00517 }
00518 inline int getType(){
00519 return s_IdList;
00520 }
00521 #ifdef EXECUTE_PARSENODES
00522 inline void setAttribute(skString * attr){
00523 m_Attribute=*attr;
00524 }
00525 inline skString getAttribute() const {
00526 return m_Attribute;
00527 }
00528 #else
00529 inline void setAttribute(int attr){
00530 m_Attribute=attr;
00531 }
00532 #endif
00533 #ifdef _DEBUG_SIZE
00534 virtual USize getSize() const {
00535 USize size=sizeof(this)+sizeof(void *);
00536 #ifdef EXECUTE_PARSENODES
00537 size+=m_Attribute.length();
00538 #endif
00539 for (USize i=0;i<m_Ids.entries();i++)
00540 size+=m_Ids[i]->getSize();
00541 size+=m_Ids.getArraySize()*sizeof(skIdNode *);
00542 return size;
00543 }
00544 #endif
00545 #ifndef EXECUTE_PARSENODES
00546
00549 void compile(skCompiledCode& compiled_code);
00550 #endif
00551 private:
00552 #ifdef EXECUTE_PARSENODES
00553 skString m_Attribute;
00554 #else
00555 int m_Attribute;
00556 #endif
00557 skIdNodeList m_Ids;
00558 };
00559 class skCaseNode : public skParseNode {
00560 public:
00561 inline skCaseNode(int linenum,skExprNode * expr,skStatListNode * stat)
00562 : skParseNode(linenum), m_Expr(expr),m_Stats(stat){
00563 }
00564 inline ~skCaseNode(){
00565 delete m_Expr;
00566 delete m_Stats;
00567 }
00568 inline void clear(){
00569 m_Expr=0;
00570 m_Stats=0;
00571 }
00572 inline int getType(){
00573 return s_Case;
00574 }
00575 inline skExprNode * getExpr(){
00576 return m_Expr;
00577 }
00578 inline skStatListNode * getStats(){
00579 return m_Stats;
00580 }
00581 #ifdef _DEBUG_SIZE
00582 virtual USize getSize() const {
00583 return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00584 }
00585 #endif
00586 #ifndef EXECUTE_PARSENODES
00587
00590 void compile(skCompiledCode& compiled_code);
00591 #endif
00592 private:
00593 skExprNode * m_Expr;
00594 skStatListNode * m_Stats;
00595 };
00596 typedef skTAList<skCaseNode> skCaseList;
00597 typedef skTAListIterator<skCaseNode> skCaseListIterator;
00598 class skCaseListNode : public skParseNode {
00599 public:
00600 inline skCaseListNode(int linenum)
00601 : skParseNode(linenum){
00602 }
00603 inline ~skCaseListNode(){
00604 m_Cases.clearAndDestroy();
00605 }
00609 inline void addCase(skCaseNode * expr){
00610 m_Cases.append(expr);
00611 }
00612 inline int numCases(){
00613 return m_Cases.entries();;
00614 }
00615 inline void clear(){
00616 m_Cases.clear();
00617 }
00618 inline skCaseList& getCases(){
00619 return m_Cases;
00620 }
00621 #ifdef _DEBUG_SIZE
00622 virtual USize getSize() const {
00623 USize size=sizeof(this)+sizeof(void *);
00624 for (USize i=0;i<m_Cases.entries();i++)
00625 size+=m_Cases[i]->getSize();
00626 size+=m_Cases.getArraySize()*sizeof(skCaseNode*);
00627 return size;
00628 }
00629 #endif
00630 #ifndef EXECUTE_PARSENODES
00631 public:
00635 void compile(skCompiledCode& compiled_code);
00636 #endif
00637 private:
00638 skCaseList m_Cases;
00639 };
00640 class skSwitchNode : public skStatNode {
00641 public:
00642 inline skSwitchNode(int linenum,skExprNode * expr,skCaseListNode * cases,skStatListNode * defaultStat)
00643 : skStatNode(linenum),m_Expr(expr),m_Cases(cases),m_Default(defaultStat){
00644 }
00645 inline ~skSwitchNode(){
00646 delete m_Expr;
00647 delete m_Cases;
00648 delete m_Default;
00649 }
00650 inline void clear(){
00651 m_Expr=0;
00652 m_Cases=0;
00653 m_Default=0;
00654 }
00655 inline int getType(){
00656 return s_Switch;
00657 }
00658 inline skExprNode * getExpr(){
00659 return m_Expr;
00660 }
00661 inline skCaseListNode * getCases(){
00662 return m_Cases;
00663 }
00664 inline skStatListNode * getDefault(){
00665 return m_Default;
00666 }
00667 #ifdef _DEBUG_SIZE
00668 virtual USize getSize() const {
00669 USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Cases->getSize();
00670 if (m_Default)
00671 size+=m_Default->getSize();
00672 return size;
00673 }
00674 #endif
00675 #ifndef EXECUTE_PARSENODES
00676 public:
00680 void compile(skCompiledCode& compiled_code);
00681 #endif
00682 private:
00683 skExprNode * m_Expr;
00684 skCaseListNode * m_Cases;
00685 skStatListNode * m_Default;
00686 };
00687 class skIfNode : public skStatNode {
00688 public:
00689 inline skIfNode(int linenum,skExprNode * expr,skStatListNode * stat,skStatListNode * elseStat)
00690 : skStatNode(linenum),m_Expr(expr),m_Stats(stat),m_Else(elseStat){
00691 }
00692 inline ~skIfNode(){
00693 delete m_Expr;
00694 delete m_Stats;
00695 delete m_Else;
00696 }
00697 inline void clear(){
00698 m_Expr=0;
00699 m_Stats=0;
00700 m_Else=0;
00701 }
00702 inline int getType(){
00703 return s_If;
00704 }
00705 inline skExprNode * getExpr(){
00706 return m_Expr;
00707 }
00708 inline skStatListNode * getStats(){
00709 return m_Stats;
00710 }
00711 inline skStatListNode * getElse(){
00712 return m_Else;
00713 }
00714 #ifdef _DEBUG_SIZE
00715 virtual USize getSize() const {
00716 USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00717 if (m_Else)
00718 size+=m_Else->getSize();
00719 return size;
00720 }
00721 #endif
00722 #ifndef EXECUTE_PARSENODES
00723 public:
00727 void compile(skCompiledCode& compiled_code);
00728 #endif
00729 private:
00730 skExprNode * m_Expr;
00731 skStatListNode * m_Stats;
00732 skStatListNode * m_Else;
00733 };
00734 class skReturnNode : public skStatNode {
00735 public:
00736 inline skReturnNode(int linenum,skExprNode * expr)
00737 : skStatNode(linenum),m_Expr(expr){
00738 }
00739 inline skReturnNode(int linenum)
00740 : skStatNode(linenum),m_Expr(0){
00741 }
00742 inline ~skReturnNode(){
00743 delete m_Expr;
00744 }
00745 inline void clear(){
00746 m_Expr=0;
00747 }
00748 inline int getType(){
00749 return s_Return;
00750 }
00751 inline skExprNode * getExpr(){
00752 return m_Expr;
00753 }
00754 #ifdef _DEBUG_SIZE
00755 virtual USize getSize() const {
00756 USize size=sizeof(this);
00757 if (m_Expr)
00758 size+=m_Expr->getSize();
00759 return size;
00760 }
00761 #endif
00762 #ifndef EXECUTE_PARSENODES
00763 public:
00767 void compile(skCompiledCode& compiled_code);
00768 #endif
00769 private:
00770 skExprNode * m_Expr;
00771 };
00772 class skBreakNode : public skStatNode {
00773 public:
00774 inline skBreakNode(int linenum)
00775 : skStatNode(linenum){
00776 }
00777 inline ~skBreakNode(){
00778 }
00779 inline void clear(){
00780 }
00781 inline int getType(){
00782 return s_Break;
00783 }
00784 #ifdef _DEBUG_SIZE
00785 virtual USize getSize() const {
00786 return sizeof(this);
00787 }
00788 #endif
00789 #ifndef EXECUTE_PARSENODES
00790 public:
00794 void compile(skCompiledCode& compiled_code);
00795 #endif
00796 private:
00797 };
00798 class skWhileNode : public skStatNode {
00799 public:
00800 inline skWhileNode(int linenum,skExprNode * expr,skStatListNode * stat)
00801 : skStatNode(linenum),m_Expr(expr),m_Stats(stat){
00802 }
00803 inline ~skWhileNode(){
00804 delete m_Expr;
00805 delete m_Stats;
00806 }
00807 inline void clear(){
00808 m_Expr=0;
00809 m_Stats=0;
00810 }
00811 inline int getType(){
00812 return s_While;
00813 }
00814 inline skExprNode * getExpr(){
00815 return m_Expr;
00816 }
00817 inline skStatListNode * getStats(){
00818 return m_Stats;
00819 }
00820 #ifdef _DEBUG_SIZE
00821 virtual USize getSize() const {
00822 return sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00823 }
00824 #endif
00825 #ifndef EXECUTE_PARSENODES
00826 public:
00830 void compile(skCompiledCode& compiled_code);
00831 #endif
00832 private:
00833 skExprNode * m_Expr;
00834 skStatListNode * m_Stats;
00835 };
00836 class skForEachNode : public skStatNode {
00837 public:
00838 #ifdef EXECUTE_PARSENODES
00839 inline skForEachNode(int linenum,skString * id,skExprNode * expr,skStatListNode * stat)
00840 : skStatNode(linenum),m_Id(*id),m_Expr(expr),m_Stats(stat){
00841 }
00842 inline skForEachNode(int linenum,skString * qualifier,skString * id,skExprNode * expr,skStatListNode * stat)
00843 : skStatNode(linenum),m_Id(*id),m_Qualifier(*qualifier),m_Expr(expr),m_Stats(stat){
00844 }
00845 #else
00846 inline skForEachNode(int linenum,int id,skExprNode * expr,skStatListNode * stat)
00847 : skStatNode(linenum),m_Id(id),m_Qualifier(NOT_PRESENT_INDEX),m_Expr(expr),m_Stats(stat){
00848 }
00849 inline skForEachNode(int linenum,int qualifier,int id,skExprNode * expr,skStatListNode * stat)
00850 : skStatNode(linenum),m_Id(id),m_Qualifier(qualifier),m_Expr(expr),m_Stats(stat){
00851 }
00852 #endif
00853 inline ~skForEachNode(){
00854 delete m_Expr;
00855 delete m_Stats;
00856 }
00857 inline void clear(){
00858 m_Expr=0;
00859 m_Stats=0;
00860 }
00861 inline int getType(){
00862 return s_ForEach;
00863 }
00864 inline skExprNode * getExpr(){
00865 return m_Expr;
00866 }
00867 inline skStatListNode * getStats(){
00868 return m_Stats;
00869 }
00870 #ifdef EXECUTE_PARSENODES
00871 inline skString getId() const{
00872 return m_Id;
00873 }
00874 inline skString getQualifier() const{
00875 return m_Qualifier;
00876 }
00877 #endif
00878 #ifdef _DEBUG_SIZE
00879 virtual USize getSize() const {
00880 USize size=sizeof(this)+sizeof(void *)+m_Expr->getSize()+m_Stats->getSize();
00881 #ifdef EXECUTE_PARSENODES
00882 size+=m_Id.length()+m_Qualifier.length();
00883 #endif
00884 return size;
00885 }
00886 #endif
00887 #ifndef EXECUTE_PARSENODES
00888 public:
00892 void compile(skCompiledCode& compiled_code);
00893 #endif
00894 private:
00895 #ifdef EXECUTE_PARSENODES
00896 skString m_Id;
00897 skString m_Qualifier;
00898 #else
00899 int m_Id;
00900 int m_Qualifier;
00901 #endif
00902 skExprNode * m_Expr;
00903 skStatListNode * m_Stats;
00904 };
00905 class skForNode : public skStatNode {
00906 public:
00907 #ifdef EXECUTE_PARSENODES
00908 inline skForNode(int linenum,skString * id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat)
00909 : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00910 m_Stats=stat;
00911 }
00912 inline skForNode(int linenum,skString *id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat)
00913 : skStatNode(linenum),m_Id(*id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00914 }
00915 #else
00916 inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skStatListNode * stat)
00917 : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(0){
00918 m_Stats=stat;
00919 }
00920 inline skForNode(int linenum,int id,skExprNode * start_expr,skExprNode * end_expr,skExprNode * step_expr,skStatListNode * stat)
00921 : skStatNode(linenum),m_Id(id),m_StartExpr(start_expr),m_EndExpr(end_expr),m_StepExpr(step_expr),m_Stats(stat){
00922 }
00923 #endif
00924 inline ~skForNode(){
00925 delete m_StartExpr;
00926 delete m_EndExpr;
00927 delete m_StepExpr;
00928 delete m_Stats;
00929 }
00930 inline void clear(){
00931 m_StartExpr=0;
00932 m_EndExpr=0;
00933 m_StepExpr=0;
00934 m_Stats=0;
00935 }
00936 inline int getType(){
00937 return s_For;
00938 }
00939 inline skExprNode * getStartExpr(){
00940 return m_StartExpr;
00941 }
00942 inline skExprNode * getEndExpr(){
00943 return m_EndExpr;
00944 }
00945 inline skExprNode * getStepExpr(){
00946 return m_StepExpr;
00947 }
00948 inline skStatListNode * getStats(){
00949 return m_Stats;
00950 }
00951 #ifdef EXECUTE_PARSENODES
00952 inline skString getId() const{
00953 return m_Id;
00954 }
00955 #endif
00956 #ifdef _DEBUG_SIZE
00957 virtual USize getSize() const {
00958 USize size=sizeof(this)+sizeof(void *)+m_StartExpr->getSize()+m_EndExpr->getSize()+m_Stats->getSize();
00959 #ifdef EXECUTE_PARSENODES
00960 size+=m_Id.length();
00961 #endif
00962 if (m_StepExpr)
00963 size+=m_StepExpr->getSize();
00964 return size;
00965 }
00966 #endif
00967 #ifndef EXECUTE_PARSENODES
00968 public:
00972 void compile(skCompiledCode& compiled_code);
00973 #endif
00974 private:
00975 #ifdef EXECUTE_PARSENODES
00976 skString m_Id;
00977 #else
00978 int m_Id;
00979 #endif
00980 skExprNode * m_StartExpr;
00981 skExprNode * m_EndExpr;
00982 skExprNode * m_StepExpr;
00983 skStatListNode * m_Stats;
00984 };
00985 class skAssignNode : public skStatNode {
00986 public:
00987 #ifdef EXECUTE_PARSENODES
00988 inline skAssignNode(int linenum,skIdListNode * idlist, skString * attribute,skExprNode * expr)
00989 : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00990 m_Ids->setAttribute(attribute);
00991 }
00992 #else
00993 inline skAssignNode(int linenum,skIdListNode * idlist, int attribute,skExprNode * expr)
00994 : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
00995 m_Ids->setAttribute(attribute);
00996 }
00997 #endif
00998 inline skAssignNode(int linenum,skIdListNode * idlist, skExprNode * expr)
00999 : skStatNode(linenum),m_Ids(idlist),m_Expr(expr){
01000 }
01001 inline ~skAssignNode(){
01002 delete m_Ids;
01003 delete m_Expr;
01004 }
01005 inline void clear(){
01006 m_Ids=0;
01007 m_Expr=0;
01008 }
01009 inline int getType(){
01010 return s_Assign;
01011 }
01012 inline skExprNode * getExpr(){
01013 return m_Expr;
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()+m_Expr->getSize();
01021 }
01022 #endif
01023 #ifndef EXECUTE_PARSENODES
01024 public:
01028 void compile(skCompiledCode& compiled_code);
01029 #endif
01030 private:
01031 skIdListNode * m_Ids;
01032 skExprNode * m_Expr;
01033 };
01034 class skMethodStatNode : public skStatNode {
01035 public:
01036 inline skMethodStatNode(int linenum,skIdListNode * idlist)
01037 : skStatNode(linenum),m_Ids(idlist){
01038 }
01039 inline ~skMethodStatNode(){
01040 delete m_Ids;
01041 }
01042 inline void clear(){
01043 m_Ids->clear();
01044 m_Ids=0;
01045 }
01046 inline int getType(){
01047 return s_Method;
01048 }
01049 inline skIdListNode * getIds(){
01050 return m_Ids;
01051 }
01052 #ifdef _DEBUG_SIZE
01053 virtual USize getSize() const {
01054 return sizeof(this)+sizeof(void *)+m_Ids->getSize();
01055 }
01056 #endif
01057 #ifndef EXECUTE_PARSENODES
01058
01061 void compile(skCompiledCode& compiled_code);
01062 #endif
01063 private:
01064 skIdListNode * m_Ids;
01065 };
01066 class skLiteralNode : public skExprNode {
01067 public:
01068 inline skLiteralNode(int linenum,skString * s)
01069 : skExprNode(linenum),m_String(s),m_Type(s_String){
01070 }
01071 inline skLiteralNode(int linenum,int i)
01072 : skExprNode(linenum),m_Int(i),m_Type(s_Integer){
01073 }
01074 inline skLiteralNode(int linenum,Char i)
01075 : skExprNode(linenum),m_Char(i),m_Type(s_Character){
01076 }
01077 #ifdef USE_FLOATING_POINT
01078 inline skLiteralNode(int linenum,float f)
01079 : skExprNode(linenum),m_Float(f),m_Type(s_Float){
01080 }
01081 #endif
01082 inline ~skLiteralNode(){
01083 if (m_Type==s_String)
01084 delete m_String;
01085 }
01086 inline void clear(){
01087 m_String=0;
01088 }
01089 inline int getType(){
01090 return m_Type;
01091 }
01092 inline skString getString() {
01093 return * m_String;
01094 }
01095 #ifdef USE_FLOATING_POINT
01096 inline float getFloat(){
01097 return m_Float;
01098 }
01099 #endif
01100 inline int getInt(){
01101 return m_Int;
01102 }
01103 inline Char getChar(){
01104 return m_Char;
01105 }
01106 #ifdef _DEBUG_SIZE
01107 virtual USize getSize() const {
01108 USize size=sizeof(this)+sizeof(void *);
01109 if (m_Type==s_String)
01110 size+=sizeof(skString)+m_String->length();
01111 return size;
01112 }
01113 #endif
01114 #ifndef EXECUTE_PARSENODES
01115
01118 void compile(skCompiledCode& compiled_code);
01119 #endif
01120 private:
01121 unsigned char m_Type;
01122 union {
01123 skString * m_String;
01124 #ifdef USE_FLOATING_POINT
01125 float m_Float;
01126 #endif
01127 int m_Int;
01128 Char m_Char;
01129 };
01130 };
01131 class skOpNode : public skExprNode {
01132 public:
01133 inline skOpNode(int linenum,int type,skExprNode * expr1,skExprNode * expr2)
01134 : skExprNode(linenum),m_Expr1(expr1),m_Expr2(expr2),m_Type(type){
01135 }
01136 virtual ~skOpNode(){
01137 delete m_Expr1;
01138 delete m_Expr2;
01139 }
01140 inline void clear(){
01141 m_Expr1=0;
01142 m_Expr2=0;
01143 }
01144 inline int getType(){
01145 return m_Type;
01146 }
01147 inline skExprNode * getExpr1(){
01148 return m_Expr1;
01149 }
01150 inline skExprNode * getExpr2(){
01151 return m_Expr2;
01152 }
01153 #ifdef _DEBUG_SIZE
01154 virtual USize getSize() const {
01155 USize size=sizeof(this)+sizeof(void *)+m_Expr1->getSize();
01156 if (m_Expr2)
01157 size+=m_Expr2->getSize();
01158 return size;
01159 }
01160 #endif
01161 #ifndef EXECUTE_PARSENODES
01162
01165 void compile(skCompiledCode& compiled_code);
01166 #endif
01167 private:
01168 skExprNode * m_Expr1;
01169 skExprNode * m_Expr2;
01170 unsigned char m_Type;
01171 };
01176 class skMethodDefNode : public skParseNode {
01177 public:
01179 inline skMethodDefNode(int linenum,skStatListNode * stats)
01180 : skParseNode(linenum),m_Stats(stats),m_Params(0){
01181 }
01183 inline skMethodDefNode(int linenum,skIdListNode * params,skStatListNode * stats)
01184 : skParseNode(linenum),m_Stats(stats),m_Params(params){
01185 }
01187 inline ~skMethodDefNode(){
01188 delete m_Stats;
01189 delete m_Params;
01190 }
01192 inline void clear(){
01193 m_Stats=0;
01194 m_Params=0;
01195 }
01196 inline int getType(){
01197 return s_MethodDef;
01198 }
01199 inline skIdListNode * getParams(){
01200 return m_Params;
01201 }
01202 inline void setParams(skIdListNode * p){
01203 m_Params=p;
01204 }
01205 inline skStatListNode * getStats(){
01206 return m_Stats;
01207 }
01208 private:
01210 skStatListNode * m_Stats;
01212 skIdListNode * m_Params;
01213 skMethodDefNode(const skMethodDefNode& )
01214 : skParseNode(0){
01215 }
01216 skMethodDefNode& operator=(const skMethodDefNode&){
01217 return *this;
01218 }
01219 #ifdef _DEBUG_SIZE
01220 virtual USize getSize() const {
01221 return m_Stats->getSize();
01222 }
01223 #endif
01224 #ifndef EXECUTE_PARSENODES
01225 public:
01229 void compile();
01230 skCompiledCode& getCompiledCode(){
01231 return m_Compiled;
01232 }
01233 private:
01234 skCompiledCode m_Compiled;
01235 #endif
01236 };
01237 #include "skParseNode.inl"
01238 #endif
01239