COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
for all M-les in the list. Notice that if the same M-le is called multiple times in the whole<br />
program, only one parse tree and corresponding symbol table are generated. As described<br />
below, however, this same parse tree will be inlined in the main program's parse tree multiple<br />
times.<br />
The second step is the actual inlining. In this step, the main program's parse tree is read<br />
in lexicographic order and, for each call to an M-le, a copy of its corresponding parse tree<br />
is inserted in the main program's parse tree, replacing the M-le call. At this point, nodes<br />
are inserted in the parse tree to copy the actual parameters of the M-le call into the formal<br />
parameters of the M-le denition, and to copy the output parameters of the M-le into<br />
their corresponding variables in the program.<br />
In contrast to regular Fortran or C functions, <strong>MATLAB</strong> functions can return more than<br />
one output variable and, although the number of output parameters in the function denition<br />
is xed, the actual number of parameters returned by the function is dependent onthe<br />
function call. Thus, the copy of the output parameters is performed only for the actual<br />
variables used by the M-le caller.<br />
Finally, the M-le's symbol table is integrated into the program's symbol table, with all<br />
the M-le's local variables renamed to receive unique names. The reason for these unique<br />
variable names, as well as the multiple instances of the same M-le and copies of the M-le's<br />
input and output parameters, is that M-les are polymorphic, and their variables have local<br />
scope. Therefore, the same variable in an M-le may have dierent properties in dierent<br />
activations of the M-le, depending on the properties of the actual input parameters.<br />
3.2.4 The Intermediate Representation<br />
After the inline of the M-les, the parse tree is transformed into an abstract syntax tree<br />
(AST) [McK76], which hasanintermediate representation more suitable for the generation<br />
of the output code.<br />
Our inference algorithms are applied to a Static Single Assignment (SSA) [CFR + 91]<br />
17