diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-11 12:43:59 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-11 12:43:59 +0300 |
commit | aeeffb935e9406fa2cdcb84828aa0e498b2df664 (patch) | |
tree | 338e0e5e153415b7f93846ac024ecea9bb925781 /source/blender/functions/FN_multi_function_procedure_builder.hh | |
parent | 6ae8de474299ec4c7c5bf2439e97998779ed4221 (diff) |
Functions: store cursors to previous instructions
Now an instruction knows the cursors where it is inserted instead
of just the instruction that references it. This has two benefits:
* An instruction knows when it is the entry instruction.
* The cursor can contain more information, e.g. if it is linked to the
true or false branch of a branch instruction.
This also simplifies updating the procedure in future optimization
passes.
Diffstat (limited to 'source/blender/functions/FN_multi_function_procedure_builder.hh')
-rw-r--r-- | source/blender/functions/FN_multi_function_procedure_builder.hh | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/source/blender/functions/FN_multi_function_procedure_builder.hh b/source/blender/functions/FN_multi_function_procedure_builder.hh index d5e45470a0e..e416f7e500d 100644 --- a/source/blender/functions/FN_multi_function_procedure_builder.hh +++ b/source/blender/functions/FN_multi_function_procedure_builder.hh @@ -25,31 +25,6 @@ namespace blender::fn { /** - * An #MFInstructionCursor points to a position in a multi-function procedure, where an instruction - * can be inserted. - */ -class MFInstructionCursor { - private: - MFInstruction *instruction_ = nullptr; - /* Only used when it is a branch instruction. */ - bool branch_output_ = false; - /* Only used when instruction is null. */ - bool is_entry_ = false; - - public: - MFInstructionCursor() = default; - - MFInstructionCursor(MFCallInstruction &instruction); - MFInstructionCursor(MFDestructInstruction &instruction); - MFInstructionCursor(MFBranchInstruction &instruction, bool branch_output); - MFInstructionCursor(MFDummyInstruction &instruction); - - static MFInstructionCursor Entry(); - - void insert(MFProcedure &procedure, MFInstruction *new_instruction); -}; - -/** * Utility class to build a #MFProcedure. */ class MFProcedureBuilder { @@ -64,7 +39,7 @@ class MFProcedureBuilder { struct Loop; MFProcedureBuilder(MFProcedure &procedure, - MFInstructionCursor initial_cursor = MFInstructionCursor::Entry()); + MFInstructionCursor initial_cursor = MFInstructionCursor::ForEntry()); MFProcedureBuilder(Span<MFProcedureBuilder *> builders); @@ -122,38 +97,6 @@ struct MFProcedureBuilder::Loop { }; /* -------------------------------------------------------------------- - * MFInstructionCursor inline methods. - */ - -inline MFInstructionCursor::MFInstructionCursor(MFCallInstruction &instruction) - : instruction_(&instruction) -{ -} - -inline MFInstructionCursor::MFInstructionCursor(MFDestructInstruction &instruction) - : instruction_(&instruction) -{ -} - -inline MFInstructionCursor::MFInstructionCursor(MFBranchInstruction &instruction, - bool branch_output) - : instruction_(&instruction), branch_output_(branch_output) -{ -} - -inline MFInstructionCursor::MFInstructionCursor(MFDummyInstruction &instruction) - : instruction_(&instruction) -{ -} - -inline MFInstructionCursor MFInstructionCursor::Entry() -{ - MFInstructionCursor cursor; - cursor.is_entry_ = true; - return cursor; -} - -/* -------------------------------------------------------------------- * MFProcedureBuilder inline methods. */ @@ -253,7 +196,7 @@ inline void MFProcedureBuilder::add_output_parameter(MFVariable &variable) inline void MFProcedureBuilder::link_to_cursors(MFInstruction *instruction) { for (MFInstructionCursor &cursor : cursors_) { - cursor.insert(*procedure_, instruction); + cursor.set_next(*procedure_, instruction); } } |