本文整理汇总了C++中AttributeList::add_attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeList::add_attribute方法的具体用法?C++ AttributeList::add_attribute怎么用?C++ AttributeList::add_attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeList
的用法示例。
在下文中一共展示了AttributeList::add_attribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void DotFunc::execute() {
ComValue before_part(stack_arg(0, true));
ComValue after_part(stack_arg(1, true));
reset_stack();
if (!before_part.is_symbol() &&
!(before_part.is_attribute() &&
(((Attribute*)before_part.obj_val())->Value()->is_unknown() ||
((Attribute*)before_part.obj_val())->Value()->is_attributelist())) &&
!before_part.is_attributelist()) {
cerr << "expression before \".\" needs to evaluate to a symbol or <AttributeList>\n";
return;
}
if (nargs()>1 && !after_part.is_symbol()) {
cerr << "expression after \".\" needs to be a symbol or evaluate to a symbol\n";
return;
}
/* lookup value of before variable */
void* vptr = nil;
AttributeList* al = nil;
if (!before_part.is_attribute() && !before_part.is_attributelist()) {
int before_symid = before_part.symbol_val();
boolean global = before_part.global_flag();
if (!global) {
comterp()->localtable()->find(vptr, before_symid);
if (!vptr) comterp()->globaltable()->find(vptr, before_symid);
} else {
comterp()->globaltable()->find(vptr, before_symid);
}
if (vptr &&((ComValue*) vptr)->class_symid() == AttributeList::class_symid()) {
al = (AttributeList*) ((ComValue*) vptr)->obj_val();
} else {
al = new AttributeList();
Resource::ref(al);
ComValue* comval = new ComValue(AttributeList::class_symid(), (void*)al);
if (!global)
comterp()->localtable()->insert(before_symid, comval);
else
comterp()->globaltable()->insert(before_symid, comval);
}
} else if (!before_part.is_attributelist()) {
if (((Attribute*)before_part.obj_val())->Value()->is_attributelist())
al = (AttributeList*) ((Attribute*) before_part.obj_val())->Value()->obj_val();
else {
al = new AttributeList();
AttributeValue newval(AttributeList::class_symid(), (void*) al);
*((Attribute*)before_part.obj_val())->Value() = newval;
}
} else
al = (AttributeList*) before_part.obj_val();
if (nargs()>1) {
int after_symid = after_part.symbol_val();
Attribute* attr = al ? al->GetAttr(after_symid) : nil;
if (!attr) {
attr = new Attribute(after_symid, new AttributeValue());
al->add_attribute(attr);
}
ComValue retval(Attribute::class_symid(), attr);
push_stack(retval);
} else {
ComValue retval(AttributeList::class_symid(), al);
push_stack(retval);
}
}