Previous | Table of Contents | Next |
There are primarily two patterns of intermediate language conception:
LaTeX and the early C++ compilers are examples of layering a new software system on top of an extant one. Thus, although TeX is a text-processing language in its own right, it is viewed as an intermediate language from the LaTeX perspective. Building systems in this fashion is convenient and economic because an already established languagefor which robust translators have presumably already been writtenis essentially adopted as an intermediate language.
If the source language L is recruited as an intermediate language, then the following problems can arise:
stack[stack[tos]+5] = stack[stack[tos+5]] + stack[stack[tos+13]]
These problems are troublesome, particularly because the very reason for choosing L as an IL may have been to enhance portability. If L is a popular language, then good compilers for L may exist on many platforms. Yet these compilers may appear inconsistent with respect to their ability to handle programs automatically generated in L. In summary, it can be said that nothing stresses a compiler like another compiler.
In the between pattern, an intermediate language is interposed between software components, as shown in Figure 4.3(b). The IL could be created in an extant system by dividing the system into components that create and use the IL. More frequently, a between IL is conceived prior to software construction so that the software development process can take advantage of the IL.
Figure 4.3. An IL can reduce the effort needed to re-source or re-target a compiler.
Suppose the compiler vendor produces a suite of compilers for s source languages (c, FTN, Ada, etc.) and currently supports these compilers for t target architectures (IBM-PC, Sun Sparc, Dec Alpha, etc.). If a different product is needed for each situation, then this company might develop and support s×t compilers, as shown in Figure 4.3(a); however, this work can be reduced to s+t if an IL can be introduced between the source and target specifications, as shown in Figure 4.3(b). Here, the company develops s front ends and t back ends. Each front end translates its source language to the IL; each back end translates the IL into native code for its architecture.
Previous | Table of Contents | Next |