1 #ifndef CPPAD_CG_INDEX_OPERATION_NODE_INCLUDED 2 #define CPPAD_CG_INDEX_OPERATION_NODE_INCLUDED 30 class IndexOperationNode :
public OperationNode<Base> {
31 friend class CodeHandler<Base>;
34 inline bool isDefinedLocally()
const {
38 inline OperationNode<Base>& getIndexCreationNode()
const {
39 const std::vector<Argument<Base> >& args = this->
getArguments();
40 CPPADCG_ASSERT_KNOWN(!args.empty(),
"Invalid number of arguments");
41 CPPADCG_ASSERT_KNOWN(args.back().getOperation() !=
nullptr,
"Invalid argument type");
42 return *args.back().getOperation();
45 inline const OperationNode<Base>& getIndex()
const {
46 const std::vector<Argument<Base> >& args = this->
getArguments();
47 CPPADCG_ASSERT_KNOWN(!args.empty(),
"Invalid number of arguments");
49 OperationNode<Base>* aNode = args[0].getOperation();
50 CPPADCG_ASSERT_KNOWN(aNode !=
nullptr && aNode->getOperationType() == CGOpCode::IndexDeclaration,
"Invalid argument operation type");
52 return static_cast<const OperationNode<Base>&
> (*aNode);
55 inline void makeAssigmentDependent(IndexAssignOperationNode<Base>& indexAssign) {
56 std::vector<Argument<Base> >& args = this->
getArguments();
59 args[0] = indexAssign.getIndex();
60 args[1] = indexAssign;
63 inline virtual ~IndexOperationNode() {
68 inline IndexOperationNode(CodeHandler<Base>* handler,
69 OperationNode<Base>& indexDcl) :
70 OperationNode<Base>(handler, CGOpCode::Index, indexDcl) {
73 inline IndexOperationNode(CodeHandler<Base>* handler,
74 LoopStartOperationNode<Base>& loopStart) :
75 OperationNode<Base>(handler, CGOpCode::Index,{loopStart.getIndex(), loopStart}) {
78 inline IndexOperationNode(CodeHandler<Base>* handler,
79 IndexAssignOperationNode<Base>& indexAssign) :
80 OperationNode<Base>(handler, CGOpCode::Index,{indexAssign.getIndex(), indexAssign}) {
const std::vector< Argument< Base > > & getArguments() const