00001 #ifndef UNRESOPSEQ_H_
00002 #define UNRESOPSEQ_H_
00003
00004 #include "engine/Variable.h"
00005 #include "engine/VariableTableTemplate.h"
00006 #include "OpSeq.h"
00007
00008
00009
00010 namespace green
00011 {
00012 class MessageTemplateTable;
00013 class EntityTemplateTable;
00014
00015 typedef boost::shared_ptr<MessageTemplateTable> MessageTemplateTablePtr;
00016 typedef boost::shared_ptr<EntityTemplateTable> EntityTemplateTablePtr;
00017
00018
00019 class UnresOpSeq
00020 {
00021
00022
00023 private:
00024 class OpNode
00025 {
00026 public:
00027 enum NodeType { OPCODE, OPERATOR, VAR, LITERAL, LABEL, LABELREF, ENTRY, DECL,
00028 MESSAGE, ENTITY };
00029 union Data
00030 {
00031 OpSeq::BinEnum binNo;
00032 OpSeq::OpCodeEnum opCode;
00033 OpSeq::OperatorEnum operCode;
00034 int integer;
00035 float real;
00036 };
00037
00038 NodeType type;
00039 Data data;
00040 std::string varName;
00041 Variable::Type varType;
00042
00043 int curNum;
00044 };
00045
00046
00047 std::vector<OpNode*> seq;
00048 int curNum;
00049
00050 VariableTableTemplatePtr whoBelongs;
00051 int isInit;
00052
00053
00054 void addNode(OpNode::NodeType typeIn,OpNode::Data dataIn,std::string& strIn,
00055 int curNumInc,Variable::Type varTypeIn);
00056 void addNode(OpNode::NodeType typeIn,OpNode::Data dataIn,int curNumInc,
00057 Variable::Type varTypeIn);
00058 int findLabel(std::string& inStr);
00059
00060 void resolveVar(OpNode* node,OpSeqPtr opSeq,
00061 VariableTableTemplatePtr inTable,
00062 std::vector<Variable::Type>& localTypes,
00063 std::map<std::string,int>& localMap);
00064
00065
00066 public:
00067 UnresOpSeq(VariableTableTemplatePtr whoBelongIn,int isInitIn);
00068 ~UnresOpSeq();
00069
00070 void addInt(int entryIn);
00071 void addVarDec(Variable::Type typeIn,std::string& varName,std::string& initValStr);
00072 void addOpCode(OpSeq::OpCodeEnum opCodeIn);
00073 void addOperator(OpSeq::OperatorEnum operatorIn);
00074 void addVarRef(std::string& varNameIn,std::string& binNameIn);
00075 void addIntLiteral(int litIn);
00076 void addFloatLiteral(float litIn);
00077 void addLabel(std::string& labelName);
00078 void addLabelRef(std::string& labelName);
00079
00080 void addEntityTag(std::string& entityName);
00081 void addMessageTag(std::string& messageName);
00082
00083
00084 OpSeqPtr resolveOpSeq(VariableTableTemplatePtr inTable,
00085 EntityTemplateTablePtr entityLookup,
00086 MessageTemplateTablePtr messageLookup);
00087
00088 void dumpScreen();
00089 };
00090
00091 typedef boost::shared_ptr<UnresOpSeq> UnresOpSeqPtr;
00092
00093 };
00094
00095 #endif