MCPcopy Create free account
hub / github.com/avast/retdec / create

Method create

src/ctypes/function.cpp:154–179  ·  view source on GitHub ↗

* @brief Creates function. * * @param context Storage for already created functions, types. * @param name Name of new function. * @param returnType Function return type. * @param parameters Function parameters. * @param callConvention Function call convention. * @param varArgness Info that function takes variable number of arguments or not. * * @par Preconditions * - @a context is not null * - @

Source from the content-addressed store, hash-verified

152* has already been created and stored in @c context.
153*/
154std::shared_ptr<Function> Function::create(
155 const std::shared_ptr<Context> &context,
156 const std::string &name,
157 const std::shared_ptr<Type> &returnType,
158 const Parameters &parameters,
159 const CallConvention &callConvention,
160 VarArgness varArgness)
161{
162 assert(context && "violated precondition - context cannot be null");
163 assert(returnType && "violated precondition - returnType cannot be null");
164
165 auto function = context->getFunctionWithName(name);
166 if (function)
167 {
168 return function;
169 }
170
171 auto funcType = createFunctionType(
172 context, returnType, parameters, callConvention, varArgness
173 );
174 std::shared_ptr<Function> newFunc(
175 new Function(name, funcType, parameters)
176 );
177 context->addFunction(newFunc);
178 return newFunc;
179}
180
181/**
182* @brief Creates function type.

Callers 1

Calls 2

getFunctionWithNameMethod · 0.45
addFunctionMethod · 0.45

Tested by

no test coverage detected