retdec
|
A builder providing a simple way of creating functions. More...
#include <function_builder.h>
Public Member Functions | |
FunctionBuilder (const std::string &funcName="") | |
Constructs a builder providing the default function named funcName. More... | |
ShPtr< Function > | build () |
Returns the built function. More... | |
Specifiers | |
FunctionBuilder & | definitionWithEmptyBody () |
Makes the function a definition with an empty body. More... | |
FunctionBuilder & | definitionWithBody (ShPtr< Statement > body) |
Makes the function a definition with the given body. More... | |
FunctionBuilder & | withRetType (ShPtr< Type > retType) |
Makes the function to have the given return type. More... | |
FunctionBuilder & | withParam (ShPtr< Variable > param) |
Adds the given parameter to the function. More... | |
FunctionBuilder & | withLocalVar (ShPtr< Variable > var) |
Adds the given local variable to the function. More... | |
FunctionBuilder & | withVarArg () |
Makes the function taking a variable number of arguments. More... | |
Private Member Functions | |
ShPtr< Function > | releaseFuncAndInvalidateBuilder () |
Releases the built function and invalidates the builder. More... | |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable ()=default | |
~NonCopyable ()=default | |
Private Attributes | |
ShPtr< Function > | func |
A function that is being built. More... | |
A builder providing a simple way of creating functions.
It implements a simplified version of the Builder design pattern with a fluent interface.
"myFunc"
with an empty body and the single given parameter: retdec::llvmir2hll::FunctionBuilder::FunctionBuilder | ( | const std::string & | funcName = "" | ) |
Constructs a builder providing the default function named funcName.
If you call build() right after the builder is created, it will return a function declaration named funcName with the void return type and without any parameters.
Returns the built function.
This function can be called at most once. It is an error to call it once again after it has already been called.
FunctionBuilder & retdec::llvmir2hll::FunctionBuilder::definitionWithBody | ( | ShPtr< Statement > | body | ) |
Makes the function a definition with the given body.
FunctionBuilder & retdec::llvmir2hll::FunctionBuilder::definitionWithEmptyBody | ( | ) |
Makes the function a definition with an empty body.
Releases the built function and invalidates the builder.
FunctionBuilder & retdec::llvmir2hll::FunctionBuilder::withLocalVar | ( | ShPtr< Variable > | var | ) |
Adds the given local variable to the function.
FunctionBuilder & retdec::llvmir2hll::FunctionBuilder::withParam | ( | ShPtr< Variable > | param | ) |
Adds the given parameter to the function.
FunctionBuilder & retdec::llvmir2hll::FunctionBuilder::withRetType | ( | ShPtr< Type > | retType | ) |
Makes the function to have the given return type.
FunctionBuilder & retdec::llvmir2hll::FunctionBuilder::withVarArg | ( | ) |
Makes the function taking a variable number of arguments.