本文整理汇总了C++中TABLE::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ TABLE::Find方法的具体用法?C++ TABLE::Find怎么用?C++ TABLE::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TABLE
的用法示例。
在下文中一共展示了TABLE::Find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
void TABLE::insert(SYM *sp)
{
int nn;
TypeArray *ta = sp->GetProtoTypes();
TABLE *tab = this;
SYM *p;
int s1,s2,s3;
std::string nm;
// std::string sig;
if (sp == nullptr || this == nullptr ) {
dfs.printf("Null pointer at insert\n");
throw new C64PException(ERR_NULLPOINTER,1);
}
if (this==&tagtable) {
dfs.printf("Insert into tagtable:%s|\n",(char *)sp->name->c_str());
}
else
dfs.printf("Insert %s into %p", (char *)sp->name->c_str(), (char *)this);
dfs.printf("(%s)\n",owner ? (char *)SYM::GetPtr(owner)->name->c_str(): (char *)"");
// sig = sp->BuildSignature();
if (tab==&gsyms[0]) {
dfs.printf("Insert into global table\n");
s1 = hashadd((char *)sp->name->c_str());
s2 = hashadd((char *)sp->name2->c_str());
s3 = hashadd((char *)sp->name3->c_str());
// tab = &gsyms[(s1&s2)|(s1&s3)|(s2&s3)];
tab = &gsyms[s1];
}
nm = *sp->name;
// The symbol may not have a type if it's just a label. Find doens't
// look at the return type parameter anyway, so we just set it to bt_long
// if tp isn't set.
nn = tab->Find(nm,sp->tp ? sp->tp->typeno : bt_long,ta,true);
if(nn == 0) {
if( tab->head == 0) {
tab->SetHead(sp->GetIndex());
tab->SetTail(sp->GetIndex());
}
else {
sp->GetPtr(tab->tail)->next = sp->GetIndex();
tab->SetTail(sp->GetIndex());
}
sp->SetNext(0);
dfs.printf("At insert:\n");
sp->GetProtoTypes()->Print();
}
else
error(ERR_DUPSYM);
if (ta)
delete ta;
// p = tab->GetHead();
// while(p) {
// printf("Xele:%p|%s|\r\n", p, p->name.c_str());
// p = p->GetNext();
// }
}
示例2: Parse
int StructDeclaration::Parse(int ztype)
{
SYM *sp;
TYP *tp;
int ret;
int psd;
ENODE nd;
ENODE *pnd = &nd;
sp = nullptr;
psd = isStructDecl;
isStructDecl++;
ret = 0;
bit_offset = 0;
bit_next = 0;
bit_width = -1;
if(lastst == id) {
if((sp = tagtable.Find(lastid,false)) == NULL) {
sp = allocSYM();
sp->SetName(*(new std::string(lastid)));
sp->tp = allocTYP();
sp->tp->type = (e_bt)ztype;
sp->tp->typeno = typeno++;
sp->tp->lst.Clear();
sp->storage_class = sc_type;
sp->tp->sname = new std::string(*sp->name);
sp->tp->alignment = 0;
NextToken();
if (lastst == kw_align) {
NextToken();
sp->tp->alignment = GetIntegerExpression(&pnd);
}
// Could be a forward structure declaration like:
// struct buf;
if (lastst==semicolon) {
ret = 1;
tagtable.insert(sp);
NextToken();
}
// Defining a pointer to an unknown struct ?
else if (lastst == star) {
tagtable.insert(sp);
}
else if(lastst != begin)
error(ERR_INCOMPLETE);
else {
tagtable.insert(sp);
NextToken();
ParseMembers(sp, sp->tp,ztype);
}
}
// Else it is a known structure
else {
NextToken();
if (lastst==kw_align) {
NextToken();
sp->tp->alignment = GetIntegerExpression(&pnd);
}
if (lastst==begin) {
NextToken();
ParseMembers(sp,sp->tp,ztype);
}
}
head = sp->tp;
}
// Else there was no tag identifier
else {
tp = allocTYP();
tp->type = (e_bt)ztype;
tp->typeno = typeno++;
tp->sname = new std::string("");
if (lastst==kw_align) {
NextToken();
tp->alignment = GetIntegerExpression(&pnd);
}
if( lastst != begin)
error(ERR_INCOMPLETE);
else {
NextToken();
ParseMembers(sp,tp,ztype);
}
head = tp;
}
isStructDecl = psd;
return ret;
}
示例3: Parse
// Class declarations have the form:
//
// class identifier [: base class]
// {
// class members
// }
//
// We could also have a forward reference:
//
// class identifier;
//
// Or a pointer to a class:
//
// class *identifier;
//
int ClassDeclaration::Parse(int ztype)
{
SYM *sp, *bcsp;
int ret;
int psd;
ENODE nd;
ENODE *pnd = &nd;
char *idsave;
int alignment;
SYM *cls;
cls = currentClass;
dfs.puts("<ParseClassDeclaration>\n");
alignment = 0;
isTypedef = TRUE;
NextToken();
if (lastst != id) {
error(ERR_SYNTAX);
goto lxit;
}
// ws = allocSYM();
idsave = my_strdup(lastid);
// ws->name = idsave;
// ws->storage_class = sc_typedef;
// Passes lastid onto struct parsing
psd = isStructDecl;
isStructDecl++;
ret = 0;
bit_offset = 0;
bit_next = 0;
bit_width = -1;
dfs.printf("---------------------------------");
dfs.printf("Class decl:%s\n", lastid);
dfs.printf("---------------------------------");
if((sp = tagtable.Find(std::string(lastid),false)) == NULL) {
sp = allocSYM();
sp->SetName(*(new std::string(lastid)));
sp->tp = nullptr;
NextToken();
dfs.printf("A");
if (lastst == kw_align) {
NextToken();
alignment = GetIntegerExpression(&pnd);
}
else
alignment = AL_STRUCT;
// Could be a forward structure declaration like:
// struct buf;
if (lastst==semicolon) {
dfs.printf("B");
ret = 1;
printf("classdecl insert1\r\n");
tagtable.insert(sp);
NextToken();
}
// Defining a pointer to an unknown struct ?
else if (lastst == star) {
dfs.printf("C");
printf("classdecl insert2\r\n");
tagtable.insert(sp);
}
else if (lastst==colon) {
dfs.printf("D");
NextToken();
// Absorb and ignore public/private keywords
if (lastst == kw_public || lastst==kw_private)
NextToken();
if (lastst != id) {
error(ERR_SYNTAX);
goto lxit;
}
bcsp = tagtable.Find(std::string(lastid),false);
if (bcsp==nullptr) {
error(ERR_UNDEFINED);
goto lxit;
}
dfs.printf("E");
// Copy the type chain of base class
//sp->tp = TYP::Copy(bcsp->tp);
// Start off at the size of the base.
sp->tp = allocTYP();
sp->tp->lst.SetBase(bcsp->GetIndex());
//.........这里部分代码省略.........