本文整理汇总了C++中TypeFunction::setStatic方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeFunction::setStatic方法的具体用法?C++ TypeFunction::setStatic怎么用?C++ TypeFunction::setStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeFunction
的用法示例。
在下文中一共展示了TypeFunction::setStatic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMethod
void Class::addMethod(std::string name, Type* t, std::vector<Argument*>* args, Stm* body, int method_state) {
// Add this argument at the beginning of arg list
if (!args)
args = new std::vector<Argument*>();
// TODO Do not do this for static methods
if (!(method_state == 1))
{
args->insert(args->begin(), new Argument(new TypeClass(this), "this"));
}
TypeFunction* tf = new TypeFunction(t);
tf->setVirtual(method_state == 2);
tf->setClass(this);
cy::Function* f = new cy::Function(tf, args, body);
f->setOriginalName(name);
this->methods->push_back(f);
// Do specific operation
tf->setStatic(false);
f->setStatic(false);
switch (method_state)
{
case 1: // Method is static
tf->setStatic(true);
f->setStatic(true);
break;
case 2: // Virtual method
f->setVirtual(true);
tf->setVirtual(true);
this->setVTable(); // Set pointer to vtable attribute
this->virtual_methods->push_back(f);
break;
case 3: // Overriden method
tf->setOverridden(true);
if (!this->getParent())
{
throw __FILE__ "(" QUOTE(__LINE__) "): Method " + name + " is overridden, but no super class.";
}
std::vector<Type*>* types = new std::vector<Type*>();
std::vector<Argument*>::iterator itarg;
for (itarg = args->begin(); itarg != args->end(); itarg++)
{
types->push_back((*itarg)->getType());
}
// Verify method with same name and same types exists in
if (!this->getParent()->getMethod(name, types))
{
throw __FILE__ "(" QUOTE(__LINE__) "): Method " + name + " is overridden, but not in super class.";
}
delete types;
break;
}
}
示例2: visit
void VisitorNodeTyper::visit(ExprSymbol *n){
// TODO Set flag if global or local
if (this->cur_class)
{
Type* t = this->cur_class->getAttrType(n->getName()); // Get type from class
if (!t) // If no type returned, it might be an unmangled method name
{
if (this->look_for_mangled)
{
TypeFunction* tf = new TypeFunction();
tf->setClass(this->cur_class);
tf->setName(n->getName());
t = tf;
}
else
{
throw __FILE__ "(" QUOTE(__LINE__) "): Attribute " + n->getName() + " not found in class" + this->cur_class->getName() + ".";
}
}
n->setType(t);
}
else
{
Variable* v = this->symt->get(n->getName());
if (!v) // Symbol not found
{
if (this->look_for_mangled) // Look for an unmangled name
{
TypeFunction* tf = new TypeFunction();
tf->setName(n->getName());
tf->setStatic(true);
tf->setVirtual(false);
n->setType(tf);
}
else
{
throw __FILE__ "(" QUOTE(__LINE__) "): Variable " + n->getName() + " not found.";
}
}
else
{
n->setType(v->getType());
}
}
}