%implements Roller "C"
%function (block, rollVars) Output
%assign ::CompiledModel.LoopControlIdx = ::CompiledModel.LoopControlIdx + 1
%assign loopVariable = "i%<LoopControlIdx>"
{
int_T %<loopVariable>;
%return loopVariable
%endfunction
%function (block, sigOffset, numIterations, rolledCount, rollVars) Output
%assign loopVariable = "i%<LoopControlIdx>"
%if 1 == block.HasSymbolicDims
%assign numIterations = ...
"(" + LibCGTypeSymbolicWidth(RollRegionTypes[rolledCount]) + ")"
%assign symLoopOffset = ""
%foreach rollIdx = rolledCount
%if 0 == rollIdx
%assign symLoopOffset = ...
"(" + LibCGTypeSymbolicWidth(RollRegionTypes[rollIdx]) + ")"
%else
%assign symLoopOffset = symLoopOffset + ...
"+(" + LibCGTypeSymbolicWidth(RollRegionTypes[rollIdx]) + ")"
%endif
%endforeach
%assign ::CompiledModel.CurrentSymbolicLoopOffset = symLoopOffset
%else
%assign ::CompiledModel.CurrentSymbolicLoopOffset = ""
%endif
%assign ::CompiledModel.CurrentLoopOffset = sigOffset
%<LibDeclareRollVariables(block, sigOffset, numIterations, rolledCount, rollVars)>
for (%<loopVariable>=0; %<loopVariable> < %<numIterations>; %<loopVariable>++) {
%endfunction
%function LoopTrailer(block, sigOffset, numIterations, rolledCount, rollVars) Output
}
%endfunction
%function RollTrailer(block, rollVars) Output
}
%assign ::CompiledModel.LoopControlIdx = ::CompiledModel.LoopControlIdx - 1
%if LoopControlIdx < 0
%assign errTxt = "Something is wrong with loop rolling. " ...
"LoopControlIdx = %<LoopControlIdx>"
%<LibReportFatalError(errTxt)>
%endif
%endfunction