本文整理汇总了C++中TypeFunction::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeFunction::resize方法的具体用法?C++ TypeFunction::resize怎么用?C++ TypeFunction::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeFunction
的用法示例。
在下文中一共展示了TypeFunction::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildMethod
TypeExpression* TypeFunction::buildMethod(ClassMethodNode* methodNode, Method* methodSymbol, TypeExpression* returnType) {
//let's build the FunctionType:
TypeFunction* typeFunction = new TypeFunction(methodSymbol->functionSignatures, methodSymbol->getName()
, methodSymbol->getUniqueName());
//extract params TypeExpressions and add them to @paramsTE
for (auto ¶mNode : methodNode->paramsList->nodes) {
typeFunction->addToParams(paramNode->getNodeType());
typeFunction->paramsSymbols.push_back(dynamic_cast<ParameterNode*>(paramNode)->parSym);//append symbol as well
}
//extract return type:
//check if a returnType exists in the symbol (might be a constructor)
if (methodSymbol->getReturnType() != nullptr) {
typeFunction->returnType = TypesTable::getInstance()->getType(methodSymbol->getReturnType());
if (strcmp(methodSymbol->getReturnType(), dynamic_cast<TypeClass*>(returnType)->getName().c_str()) == 0) {
typeFunction->returnType = returnType;
}
//if return type not found, return a TypeError
TypeError* errorReturnType = dynamic_cast<TypeError*>(typeFunction->returnType);
if (errorReturnType != nullptr)
return new TypeError("return type: " + string(methodSymbol->getReturnType()) + " is undefied.");
}
//everything is ok
//now let's resize according to the new params
typeFunction->resize();
typeFunction->isConstructorFT = methodSymbol->isConstructor;
typeFunction->isStaticMethod = false;
return typeFunction;
}
示例2: buildConstructor
/* this builds default constructor:
*/
TypeExpression* TypeFunction::buildConstructor(Method* methodSym) {
//let's build the FunctionType:
TypeFunction* typeFunction = new TypeFunction(methodSym->functionSignatures, methodSym->getName()
, methodSym->getUniqueName());
//no params, so not adding any
//return type should be the TypeClass the constructor is for, so setting the returnType is moved
//to caller
//everything is ok
//now let's resize according to the new params
typeFunction->resize();
typeFunction->isConstructorFT = true;
typeFunction->isStaticMethod = false;
return typeFunction;
}
示例3: buildFunction
TypeExpression* TypeFunction::buildFunction(FunctionDefineNode* functionNode, Function* functionSymbol) {
//try to find a TypeFunction from the first signature of the given function symbol.
//the @TypeFunction::isDeclared() returns false if a name of the function already found, not just unmatched signature.
//this behaviour can be changed, so we can obtain the functionality of Function Overloading.
bool isDeclared = TypeFunction::isDeclared(functionNode->functionSym->functionSignatures.at(0));
//if isDeclared, throw a TypeError with already defined
if (isDeclared)
return new TypeError(string(functionSymbol->getName()) + "already defined.");
//let's build the FunctionType:
TypeFunction* typeFunction = new TypeFunction(functionSymbol->functionSignatures, functionSymbol->getName()
,functionSymbol->getUniqueName());
//extract params TypeExpressions and add them to @paramsTE
for (auto ¶mNode : functionNode->paramsList->nodes) {
typeFunction->addToParams(paramNode->getNodeType());
typeFunction->paramsSymbols.push_back(dynamic_cast<ParameterNode*>(paramNode)->parSym);//append symbol as well
}
//extract return type
typeFunction->returnType = TypesTable::getInstance()->getType(functionSymbol->getReturnType());
//if return type not found, return a TypeError
TypeError* errorReturnType = dynamic_cast<TypeError*>(typeFunction->returnType);
if (errorReturnType != nullptr)
return new TypeError("return type: " + string(functionSymbol->getReturnType()) + " is undefied.");
//everything is ok
//now let's resize according to the new params
typeFunction->resize();
typeFunction->isConstructorFT = false; // not a constructor
typeFunction->isStaticMethod = false;
//and finally, add it to the FunctionType's we have:
TypeFunction::functionInstances.push_back(typeFunction);
return typeFunction;
}