[Bf-blender-cvs] [d6eb9668a0a] functions: move more signature logic into function
Jacques Lucke
noreply at git.blender.org
Fri May 17 12:04:58 CEST 2019
Commit: d6eb9668a0aec6131786a27921f1609e6505c206
Author: Jacques Lucke
Date: Fri May 17 11:18:30 2019 +0200
Branches: functions
https://developer.blender.org/rBd6eb9668a0aec6131786a27921f1609e6505c206
move more signature logic into function
===================================================================
M source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
M source/blender/functions/backends/llvm/llvm_types.cpp
M source/blender/functions/backends/llvm/llvm_types.hpp
M source/blender/functions/core/function.hpp
M source/blender/functions/core/signature.hpp
===================================================================
diff --git a/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp b/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
index 11b31c9dc1b..c21b88834c0 100644
--- a/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
@@ -58,8 +58,8 @@ class TupleCallLLVM : public LLVMBuildIRBody {
Function *fn = m_tuple_call->owner();
/* Find relevant type information. */
- auto input_type_infos = fn->signature().input_extensions<LLVMTypeInfo>();
- auto output_type_infos = fn->signature().output_extensions<LLVMTypeInfo>();
+ auto input_type_infos = fn->input_extensions<LLVMTypeInfo>();
+ auto output_type_infos = fn->output_extensions<LLVMTypeInfo>();
/* Build wrapper function. */
llvm::Function *wrapper_function = this->get_wrapper_function(
diff --git a/source/blender/functions/backends/llvm/llvm_types.cpp b/source/blender/functions/backends/llvm/llvm_types.cpp
index c2e6826e0f9..b125ffe651b 100644
--- a/source/blender/functions/backends/llvm/llvm_types.cpp
+++ b/source/blender/functions/backends/llvm/llvm_types.cpp
@@ -146,12 +146,4 @@ LLVMTypes types_of_type_infos(const SmallVector<LLVMTypeInfo *> &type_infos,
return types;
}
-llvm::FunctionType *function_type_from_signature(const Signature &signature,
- llvm::LLVMContext &context)
-{
- auto input_types = types_of_type_infos(signature.input_extensions<LLVMTypeInfo>(), context);
- auto output_types = types_of_type_infos(signature.output_extensions<LLVMTypeInfo>(), context);
- llvm::Type *output_type = llvm::StructType::get(context, to_llvm_array_ref(output_types));
- return llvm::FunctionType::get(output_type, to_llvm_array_ref(input_types), false);
-}
}; // namespace FN
diff --git a/source/blender/functions/backends/llvm/llvm_types.hpp b/source/blender/functions/backends/llvm/llvm_types.hpp
index a0dc2b00c55..afbda11bdc9 100644
--- a/source/blender/functions/backends/llvm/llvm_types.hpp
+++ b/source/blender/functions/backends/llvm/llvm_types.hpp
@@ -112,7 +112,4 @@ inline llvm::Type *get_llvm_type(SharedType &type, llvm::LLVMContext &context)
LLVMTypes types_of_type_infos(const SmallVector<LLVMTypeInfo *> &type_infos,
llvm::LLVMContext &context);
-llvm::FunctionType *function_type_from_signature(const Signature &signature,
- llvm::LLVMContext &context);
-
} /* namespace FN */
diff --git a/source/blender/functions/core/function.hpp b/source/blender/functions/core/function.hpp
index 7a1fafd6ae6..8119dee1028 100644
--- a/source/blender/functions/core/function.hpp
+++ b/source/blender/functions/core/function.hpp
@@ -117,6 +117,28 @@ class Function final : public RefCountedBase {
return m_signature.outputs()[index].type();
}
+ template<typename T> SmallVector<T *> input_extensions() const
+ {
+ SmallVector<T *> extensions;
+ for (InputParameter ¶m : m_signature.inputs()) {
+ T *ext = param.type()->extension<T>();
+ BLI_assert(ext);
+ extensions.append(ext);
+ }
+ return extensions;
+ }
+
+ template<typename T> SmallVector<T *> output_extensions() const
+ {
+ SmallVector<T *> extensions;
+ for (InputParameter ¶m : m_signature.outputs()) {
+ T *ext = param.type()->extension<T>();
+ BLI_assert(ext);
+ extensions.append(ext);
+ }
+ return extensions;
+ }
+
private:
const std::string m_name;
Signature m_signature;
diff --git a/source/blender/functions/core/signature.hpp b/source/blender/functions/core/signature.hpp
index 549c4fde9a3..b7b62baef30 100644
--- a/source/blender/functions/core/signature.hpp
+++ b/source/blender/functions/core/signature.hpp
@@ -27,28 +27,6 @@ class Signature {
TypeVector input_types() const;
TypeVector output_types() const;
- template<typename T> SmallVector<T *> input_extensions() const
- {
- SmallVector<T *> extensions;
- for (InputParameter ¶m : m_inputs) {
- T *ext = param.type()->extension<T>();
- BLI_assert(ext);
- extensions.append(ext);
- }
- return extensions;
- }
-
- template<typename T> SmallVector<T *> output_extensions() const
- {
- SmallVector<T *> extensions;
- for (OutputParameter ¶m : m_outputs) {
- T *ext = param.type()->extension<T>();
- BLI_assert(ext);
- extensions.append(ext);
- }
- return extensions;
- }
-
bool has_interface(const TypeVector &inputs, const TypeVector &outputs) const;
bool has_interface(const Signature &other) const;
More information about the Bf-blender-cvs
mailing list