1 #ifndef CPPAD_CG_LOOP_END_OPERATION_NODE_INCLUDED
2 #define CPPAD_CG_LOOP_END_OPERATION_NODE_INCLUDED
31 class LoopEndOperationNode :
public OperationNode<Base> {
32 friend class CodeHandler<Base>;
35 inline const LoopStartOperationNode<Base>& getLoopStart()
const {
36 const std::vector<Argument<Base> >& args = this->getArguments();
37 CPPADCG_ASSERT_KNOWN(args.size() > 0,
"There must be at least one argument")
39 OperationNode<Base>* aNode = args[0].getOperation();
40 CPPADCG_ASSERT_KNOWN(aNode !=
nullptr && aNode->getOperationType() == CGOpCode::LoopStart, "The first argument must be the loop start operation")
42 return dynamic_cast<LoopStartOperationNode<Base>&> (*aNode);
45 inline virtual ~LoopEndOperationNode() = default;
49 inline LoopEndOperationNode(CodeHandler<Base>* handler,
50 LoopStartOperationNode<Base>& loopStart,
51 const std::vector<Argument<Base> >& endArgs) :
52 OperationNode<Base>(handler, CGOpCode::LoopEnd, std::vector<
size_t>(0), createArguments(loopStart, endArgs)) {
57 static inline std::vector<Argument<Base> > createArguments(LoopStartOperationNode<Base>& lstart,
58 const std::vector<Argument<Base> >& endArgs) {
59 std::vector<Argument<Base> > args(1 + endArgs.size());
61 std::copy(endArgs.begin(), endArgs.end(), args.begin() + 1);