Method and apparatus for strategic compilation of source programs into two or more target languages
AssigneeInternational Business Machines Corporation
InventorTrevor Paul Hopkins
Life of this patent
Estimating the term…
Abstract
A method and apparatus which, as part of a compiler, supporting the generation of code in two (or more) target languages. The selection of the target language, and the program structure in that target language, is made depending on the capabilities of each target language, in a separate processing pass. Runtime efficiency is also improved by allowing selection of the most appropriate target language and program structure for a particular source code function.
Claims3
A method for compiling a source program written in a source language into a compiled program comprising a plurality of different target languages, the method comprising:
- generating a parse tree from a source program, the parse tree comprising a plurality of nodes each representative of an operation in the source program;
- determining, for each successive node of the parse tree, a target language selected from a plurality of different target languages into which the node can be compiled based on the operation represented by the node;
- generating, based on the target language determination, a list of start points each corresponding to a different node of the parse tree and each indicating the target language into which the node is to be compiled;
- and
- generating successive sections of the compiled program each based on each node of the parse tree between successive start points in the list and each being generated in the target language specified by the first of the successive start points.
An apparatus for compiling a source program written in a source language into a compiled program comprising a plurality of different target languages, the apparatus comprising:
- means for generating a parse tree from a source program, the parse tree comprising a plurality of nodes each representative of an operation in the source program;
- means for determining, for each successive node of the parse tree, a target language selected from a plurality of different target languages into which the node can be compiled based on the operation represented by the node;
- means for generating, based on the target language determination, a list of start points each corresponding to a different node of the parse tree and each indicating the target language into which the node is to be compiled;
- and
- means for generating successive sections of the compiled program each based on each node of the parse tree between successive start points in the list and each being generated in the target language specified by the first of the successive start points.
A computer program device readable by a machine, tangibly embodying a program of instructions executable by a machine to perform method steps for compiling a source program written in a source language into a compiled program comprising a plurality of different languages, the method comprising steps of:
- generating a parse tree from a source program, the parse tree comprising a plurality of nodes each representative of an operation in the source program;
- determining, for each successive node of the parse tree, a target language selected from a plurality of different target languages into which the node can be compiled based on the operation represented by the node;
- generating, based on the target language determination, a list of start points each corresponding to a different node of the parse tree and each indicating the target language into which the node is to be compiled;
- and
- generating successive sections of the compiled program each based on each node of the parse tree between successive start points in the list and each being generated in the target language specified by the first of the successive start points.
Dependencies are inferred from the claim text.