1 #ifndef CPPAD_CG_INDEX_ASSIGN_OPERATION_NODE_INCLUDED 2 #define CPPAD_CG_INDEX_ASSIGN_OPERATION_NODE_INCLUDED 30 class IndexAssignOperationNode :
public OperationNode<Base> {
31 friend class CodeHandler<Base>;
33 IndexPattern& indexPattern_;
36 inline OperationNode<Base>& getIndex()
const {
37 const std::vector<Argument<Base> >& args = this->
getArguments();
38 CPPADCG_ASSERT_KNOWN(!args.empty(),
"Invalid number of arguments");
40 OperationNode<Base>* aNode = args[0].getOperation();
41 CPPADCG_ASSERT_KNOWN(aNode !=
nullptr && aNode->getOperationType() == CGOpCode::IndexDeclaration,
"Invalid argument operation type");
43 return static_cast<OperationNode<Base>&
> (*aNode);
46 inline const IndexPattern& getIndexPattern()
const {
50 inline IndexPattern& getIndexPattern() {
54 inline std::vector<const OperationNode<Base>*> getIndexPatternIndexes()
const {
55 std::vector<const OperationNode<Base>*> iargs;
57 const std::vector<Argument<Base> >& args = this->
getArguments();
59 CPPADCG_ASSERT_KNOWN(args[1].getOperation() !=
nullptr &&
60 args[1].getOperation()->
getOperationType() == CGOpCode::Index,
"Invalid argument operation type");
61 iargs.push_back(&
static_cast<IndexOperationNode<Base>*
> (args[1].getOperation())->getIndex());
63 if (args.size() > 2) {
64 CPPADCG_ASSERT_KNOWN(args[2].getOperation() !=
nullptr &&
65 args[2].getOperation()->
getOperationType() == CGOpCode::Index,
"Invalid argument operation type");
66 iargs.push_back(&
static_cast<IndexOperationNode<Base>*
> (args[2].getOperation())->getIndex());
87 OperationNode<Base>(handler, CGOpCode::IndexAssign,{index, index1}),
88 indexPattern_(indexPattern) {
96 OperationNode<Base>(handler, CGOpCode::IndexAssign, std::vector<size_t> (0), createArguments(index, index1, index2)),
97 indexPattern_(indexPattern) {
103 std::vector<Argument<Base> > args(1 + (index1 !=
nullptr)+ (index2 !=
nullptr));
106 if (index1 !=
nullptr)
108 if (index2 !=
nullptr) {
109 args.back() = *index2;
const std::vector< Argument< Base > > & getArguments() const
CGOpCode getOperationType() const
IndexAssignOperationNode(CodeHandler< Base > *handler, OperationNode< Base > &index, IndexPattern &indexPattern, IndexOperationNode< Base > &index1)