Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-08-19 15:06:43 +0300
committerJacques Lucke <jacques@blender.org>2021-08-19 15:06:43 +0300
commitc827b50d407ff6ba113794ae290420213e3e097a (patch)
tree3bd16fc047b14129c56a5a144cdbbb27532dce2f /source/blender
parent3c7e3c8e446a807220483f41e09595bf4f98cf16 (diff)
add dummy instruction type
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/functions/FN_multi_function_procedure.hh30
-rw-r--r--source/blender/functions/intern/multi_function_procedure.cc22
-rw-r--r--source/blender/functions/intern/multi_function_procedure_builder.cc4
-rw-r--r--source/blender/functions/intern/multi_function_procedure_executor.cc6
4 files changed, 59 insertions, 3 deletions
diff --git a/source/blender/functions/FN_multi_function_procedure.hh b/source/blender/functions/FN_multi_function_procedure.hh
index 8b3e28d2b16..b9540540992 100644
--- a/source/blender/functions/FN_multi_function_procedure.hh
+++ b/source/blender/functions/FN_multi_function_procedure.hh
@@ -29,12 +29,14 @@ class MFInstruction;
class MFCallInstruction;
class MFBranchInstruction;
class MFDestructInstruction;
+class MFDummyInstruction;
class MFProcedure;
enum class MFInstructionType {
Call,
Branch,
Destruct,
+ Dummy,
};
class MFVariable : NonCopyable, NonMovable {
@@ -68,6 +70,7 @@ class MFInstruction : NonCopyable, NonMovable {
friend MFCallInstruction;
friend MFBranchInstruction;
friend MFDestructInstruction;
+ friend MFDummyInstruction;
public:
MFInstructionType type() const;
@@ -130,9 +133,14 @@ class MFDestructInstruction : public MFInstruction {
void set_next(MFInstruction *instruction);
};
-struct DestructInstructionChain {
- MFDestructInstruction *first = nullptr;
- MFDestructInstruction *last = nullptr;
+class MFDummyInstruction : public MFInstruction {
+ private:
+ MFInstruction *next_ = nullptr;
+
+ public:
+ MFInstruction *next();
+ const MFInstruction *next() const;
+ void set_next(MFInstruction *instruction);
};
class MFProcedure : NonCopyable, NonMovable {
@@ -141,6 +149,7 @@ class MFProcedure : NonCopyable, NonMovable {
Vector<MFCallInstruction *> call_instructions_;
Vector<MFBranchInstruction *> branch_instructions_;
Vector<MFDestructInstruction *> destruct_instructions_;
+ Vector<MFDummyInstruction *> dummy_instructions_;
Vector<MFVariable *> variables_;
Vector<std::pair<MFParamType::InterfaceType, MFVariable *>> params_;
MFInstruction *entry_ = nullptr;
@@ -153,6 +162,7 @@ class MFProcedure : NonCopyable, NonMovable {
MFCallInstruction &new_call_instruction(const MultiFunction &fn);
MFBranchInstruction &new_branch_instruction();
MFDestructInstruction &new_destruct_instruction();
+ MFDummyInstruction &new_dummy_instruction();
void add_parameter(MFParamType::InterfaceType interface_type, MFVariable &variable);
@@ -305,6 +315,20 @@ inline const MFInstruction *MFDestructInstruction::next() const
}
/* --------------------------------------------------------------------
+ * MFDummyInstruction inline methods.
+ */
+
+inline MFInstruction *MFDummyInstruction::next()
+{
+ return next_;
+}
+
+inline const MFInstruction *MFDummyInstruction::next() const
+{
+ return next_;
+}
+
+/* --------------------------------------------------------------------
* MFProcedure inline methods.
*/
diff --git a/source/blender/functions/intern/multi_function_procedure.cc b/source/blender/functions/intern/multi_function_procedure.cc
index 7c6d24941a2..1b1c826c9ba 100644
--- a/source/blender/functions/intern/multi_function_procedure.cc
+++ b/source/blender/functions/intern/multi_function_procedure.cc
@@ -111,6 +111,17 @@ void MFDestructInstruction::set_next(MFInstruction *instruction)
next_ = instruction;
}
+void MFDummyInstruction::set_next(MFInstruction *instruction)
+{
+ if (next_ != nullptr) {
+ next_->prev_.remove_first_occurrence_and_reorder(this);
+ }
+ if (instruction != nullptr) {
+ instruction->prev_.append(this);
+ }
+ next_ = instruction;
+}
+
MFVariable &MFProcedure::new_variable(MFDataType data_type, std::string name)
{
MFVariable &variable = *allocator_.construct<MFVariable>().release();
@@ -148,6 +159,14 @@ MFDestructInstruction &MFProcedure::new_destruct_instruction()
return instruction;
}
+MFDummyInstruction &MFProcedure::new_dummy_instruction()
+{
+ MFDummyInstruction &instruction = *allocator_.construct<MFDummyInstruction>().release();
+ instruction.type_ = MFInstructionType::Dummy;
+ dummy_instructions_.append(&instruction);
+ return instruction;
+}
+
void MFProcedure::add_parameter(MFParamType::InterfaceType interface_type, MFVariable &variable)
{
params_.append({interface_type, &variable});
@@ -183,6 +202,9 @@ MFProcedure::~MFProcedure()
for (MFDestructInstruction *instruction : destruct_instructions_) {
instruction->~MFDestructInstruction();
}
+ for (MFDummyInstruction *instruction : dummy_instructions_) {
+ instruction->~MFDummyInstruction();
+ }
for (MFVariable *variable : variables_) {
variable->~MFVariable();
}
diff --git a/source/blender/functions/intern/multi_function_procedure_builder.cc b/source/blender/functions/intern/multi_function_procedure_builder.cc
index ac00e0e846d..bd35b7099e2 100644
--- a/source/blender/functions/intern/multi_function_procedure_builder.cc
+++ b/source/blender/functions/intern/multi_function_procedure_builder.cc
@@ -49,6 +49,10 @@ void MFInstructionCursor::insert(MFProcedure &procedure, MFInstruction *new_inst
static_cast<MFDestructInstruction *>(instruction_)->set_next(new_instruction);
break;
}
+ case MFInstructionType::Dummy: {
+ static_cast<MFDummyInstruction *>(instruction_)->set_next(new_instruction);
+ break;
+ }
}
}
}
diff --git a/source/blender/functions/intern/multi_function_procedure_executor.cc b/source/blender/functions/intern/multi_function_procedure_executor.cc
index bce0d48afee..d494409aa0d 100644
--- a/source/blender/functions/intern/multi_function_procedure_executor.cc
+++ b/source/blender/functions/intern/multi_function_procedure_executor.cc
@@ -1094,6 +1094,12 @@ void MFProcedureExecutor::call(IndexMask full_mask, MFParams params, MFContext c
scheduler.add_previous_instruction_indices(destruct_instruction.next(), instr_info);
break;
}
+ case MFInstructionType::Dummy: {
+ const MFDummyInstruction &dummy_instruction = static_cast<const MFDummyInstruction &>(
+ instruction);
+ scheduler.add_previous_instruction_indices(dummy_instruction.next(), instr_info);
+ break;
+ }
}
}