Technical data
2
Working with the Target Language
2-24
Extending the former example to a loop that rolls:
%language "C"
%assign ablock = BLOCK { Name "Hi" }
%roll Idx = [ 1:20, 21, 22, 23:25, 26:46], lcv = 10, ablock
Block[%< lcv == "" ? Idx : lcv>] *= 3.0;
%endroll
This TLC code produces the output:
{
int i;
for (i = 1; i < 21; i++)
{
Block[i] *= 3.0;
}
Block[21] *= 3.0;
Block[22] *= 3.0;
Block[23] *= 3.0;
Block[24] *= 3.0;
Block[25] *= 3.0;
for (i = 26; i < 47; i++)
{
Block[i] *= 3.0;
}
}
Object-Oriented Facility for Generating Target Code
The Target Language Compiler provides a simple object-oriented facility. The
language directives are:
%language string
%generatefile
%implements
This facility was designed specifically for customizing the code for Simulink
blocks, but can be used for other purposes as well.
The
%language directive specifies the target language being generated. It is
required as a consistency check to ensure that the correct implementation files
are found for the language being generated. The
%language directive must