当前位置: 首页>>代码示例>>C++>>正文


C++ TypeFunction::resize方法代码示例

本文整理汇总了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 &paramNode : 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;
}
开发者ID:yaapc,项目名称:php_comp,代码行数:35,代码来源:TypeFunction.cpp

示例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;
}
开发者ID:yaapc,项目名称:php_comp,代码行数:20,代码来源:TypeFunction.cpp

示例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 &paramNode : 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;
}
开发者ID:yaapc,项目名称:php_comp,代码行数:43,代码来源:TypeFunction.cpp


注:本文中的TypeFunction::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。