📄 jlabelnode_h.h
字号:
//---------------------------------------------------------------------------
//-------- JLabelNode_H.h -------------------------------------------------
//---------------------------------------------------------------------------
#ifndef JLabelNode_H.h // 防止被重复引用
#define JLabelNode_H.h
//---------------------------------------------------------------------------
#include "Jstring_H.h"
#include "Tokenfield_H.h"
#include "OBJrecord_H.h"
#include "ASM_Segment_H.h"
//---------------------------------------------------------------------------
/*
//---------------------------------------------------------------------------
// 一个专门搞交叉参考表的结构
//---------------------------------------------------------------------------
struct Int16uNode
{ int16u word;
Int16uNode* next;
// ----- Functions ------
Int16uNode() {} // constructor
Int16uNode(int16u w, Int16uNode* nt); // constructor
}; // end Int16uLink
//---------------------------------------------------------------------------
//------ 构造器 -------------------------------------------------------------
inline Int16uNode::Int16uNode(int16u w, Int16uNode* nt = NULL)
{ word = w; next = nt;
} // end constructor
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 循环链表
//---------------------------------------------------------------------------
class RotateInt16uLink
{ private:
Int16uNode* LinkTail;
public:
RotateInt16uLink(int16u w); // constructor
~RotateInt16uLink();
// ----- Functions ------
Int16uNode* LinkHead(); // 得到链头
}; // end RotateInt16uLink
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 得到链头(头结点指针)。
//---------------------------------------------------------------------------
inline Int16uNode* RotateInt16uLink::LinkHead()
{ return LinkTail->next;
} // end LinkHead
//---------------------------------------------------------------------------
//------ 构造器 -------------------------------------------------------------
inline RotateInt16uLink::RotateInt16uLink(int16u w) // 产生一个空的循环链表。
{ LinkTail = new Int16uNode;
LinkTail->word = w;
LinkTail->next = LinkTail;
} // end constructor
//---------------------------------------------------------------------------
//------ 析构器 -------------------------------------------------------------
RotateInt16uLink::~RotateInt16uLink() // 释放所占用的内存空间。
{ register Int16uNode* temp;
for( temp = LinkTail,
LinkTail = LinkTail->next, // 现在链尾所指实质上是链头。
temp->next = NULL;
LinkTail; // condition
temp = LinkTail,
LinkTail = LinkTail->next,
delete temp ); // end for
} // end destructor
//---------------------------------------------------------------------------
*/
//---------------------------------------------------------------------------
//
// 一个标号结点的结构
//
//---------------------------------------------------------------------------
class JLabelNode
{ private:
union
{ struct // (6,7) SEG, REG.
{ int8u LBLTyp :4; // ( 0 ~ 5 ) CODE, XDATA, DATA, IDATA, BIT, NUM.
int8u Variable :1; // 如果是变量,它为true。
int8u Indirect :1; // 是否需要间接访问。(通过LnPt->Addr)
int8u Publicable :1; // 是否设为PUBLIC属性.
int8u ValOk :1; // Value值是否有效. 无效的要重新计算。
} vv;
struct
{ int8u typ :4; // ( 0 ~ 5 ) CODE, XDATA, DATA, IDATA, BIT, NUM.
int8u Info :4; // 4-bit
} fo;
int8u TpInfo; // :8; // 8-bit
}; // end union
bool evenUse; // 曾经使用过。
int16u ExtID; // 外部变量的ID号
AsmLine* LnPt; // 指向创建该标号的汇编行的指针。预定义的标号,该值为空。
// RotateInt16uLink* XRef; // 交叉引用循环链表
public:
Tokenfield* ExpPt; // 表达式指针。
ASM_Segment* RefSeg; // 如果是相对值,指向参照段。
JLabelNode* next; // 指向下一个JLabelNode的指针。
int32 Value; // 一个32位有符号的数值。
Jstring LName; // 标号名。
int8u Attrb; // 'A'= 绝对值常量 'R'= 相对值常量 'E'=Extern常量
// -------- constructor ----------------
JLabelNode( const Jstring& name, //
Tokenfield* pt, //
int8u labelTp, // NUM, CODE, DATA, BIT
int8u atrb, // A, R, E
bool var = false, //
AsmLine* crln = NULL, //
ASM_Segment* refSeg = NULL, //
bool Ind = false ); //
// -------- destructor ----------------
~JLabelNode();
// --------- public functions ------------
// 设置数值, 并令OK。
void SetValue(int32 val) { Value = val; vv.ValOk = true; } // end SetValue
void SetNode(const Jstring& name, int8u labelTp)
{ LName = name; vv.LBLTyp = labelTp; } // end SetNode
void SetPublic() { vv.Publicable = true; } // end SetPublic
bool IsValOK()const { return vv.ValOk; } // end IsValOK
bool IsVariable()const { return vv.Variable; } // end IsVariable
bool IsPublic()const { return vv.Publicable; } // end IsPublic
bool IsLocal()const { return( !vv.Publicable
&& Attrb != 'E'
&& vv.LBLTyp != LB_SEG); } // end IsLocal
// 从另外一个标号节点复制过来给自身。
void CopyFrom(const JLabelNode& src);
// ----------------------------
int8u getTyp() { return vv.LBLTyp; } // end getTyp
int16u GetExtID() { return ExtID; } // end GetExtID
void SetExtID(int16u id) { ExtID = id; } // end SetExtID
const char* LabelTypeStr();
// ----------------------------
void Show()const; // 把自己在屏幕上显示出来。
// ----------------------------
friend class LabelManager;
friend class MacroAsmber;
friend class LISTFile;
}; // end JLabelNode
//---------------------------------------------------------------------------
//------ 构造器 -------------------------------------------------------------
inline JLabelNode::JLabelNode( const Jstring& name,
Tokenfield* pt,
int8u labelTp, int8u atrb,
bool var,
AsmLine* crln,
ASM_Segment* refSeg,
bool Ind )
: Value(0), ExtID(0), evenUse(false),next(NULL)
{ SetNode(name, labelTp);
ExpPt = pt;
Attrb = atrb;
vv.Variable = var;
LnPt = crln;
RefSeg = refSeg;
vv.Indirect = Ind;
vv.ValOk = false;
vv.Publicable = false;
// register int16u ww = LnPt ? LnPt->GetLineNo() : 0; // 置循环链表的头结点元素的值。
// The first node is the LineNo of the Crln.
// If LineNo==NULL, default to zero.
// XRef = new RotateInt16uLink(ww);
} // end constructor
//---------------------------------------------------------------------------
//------ 析构器 -------------------------------------------------------------
inline JLabelNode::~JLabelNode()
{ //delete XRef;
} // end destructor
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
// Written by JamesyFront. ZLGmcu Dev.Co.Ltd. 2002.
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -