COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A forward/backward traversal scheme for type inference is described in [ASU85]. In this<br />
scheme, type inference is performed with data-ow analysis on a ow graph of the program.<br />
The in and out set of variables for each block of the program are mapped onto sets of<br />
possible types. The scheme uses an iterative process that propagates information forward<br />
and backward, reducing the set of types associated with each variable until a xed point<br />
is reached. One assumption of this scheme is that variables do not change types during<br />
the execution of the program. In our case, this is not a valid assumption since variables<br />
in <strong>MATLAB</strong> can change types during run-time thereby not always allowing a backward<br />
step. Hence, our inference mechanism concentrates on a forward data-ow analysis and, as<br />
discussed later, performs a backward step only when backward inference is possible.<br />
SETL is a set-theoretically oriented language of very high-level. A SETL program maybe<br />
considered to represent an algorithm before it is codied into a language of lower-level [Sch75].<br />
It treats types in a fully dynamic way, withnotype declarations. However, the types of the<br />
objects that appear in SETL programs can be deduced with the use of an appropriate global<br />
analysis [Sch75]. For this type inference, a type algebra that operates on the structural type<br />
of SETL objects is used. This algebra is implemented using tables whose entries describe<br />
the action, on the symbolic entities of the algebra, of each of the primitives of the language<br />
to be analyzed [Sch75].<br />
2.2 Compilation of APL<br />
APL is similar to <strong>MATLAB</strong> in that it can be executed interactively, is usually interpreted,<br />
and operates on aggregate data structures. A few compilers for APL have beendeveloped<br />
in the past. These compilers are also based on forward/backward dataow analysis.<br />
Budd [Bud88] and Ching [Chi86] have independently developed compilers for APL.<br />
Budd's compiler translates APL programs into C, while Ching's compiler produces IBM<br />
System/370 assembly code directly. The motivation for their work was to investigate the<br />
issues raised by the development of a compiler for a very high-level language, and to exploit<br />
9