Code Transformation via Intermediate Representation for Jump Instruction Handling
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods struggle to transform source code from programming languages like COBOL, Natural, and PL/1 into modern languages like Java or .NET, especially when these languages lack jump instructions, resulting in structural differences that hinder maintainability and recognition of the original code.
Innovation Solution
The method involves creating functionally equivalent code fragments and exception handling mechanisms in the destination language to replicate the behavior of jump instructions, allowing for statement-to-statement transformation and maintaining the original program structure, even when jump instructions are not available in the destination language.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If jump instructions are used in the original source code to control program flow, then program execution flexibility is improved, but the transformed code structure diverges significantly from the original when destination languages like Java or .NET are used which lack jump instructions
Solution Approach 1:
The patent introduces an intermediate code representation that serves as a mediator between the original source code with jump instructions and the destination language code without jump instructions. This intermediate code captures the control flow structure in a language-agnostic way, allowing faithful reproduction of jump behavior in the destination language using its native constructs (loops, exceptions, labels) while maintaining structural correspondence to the original code.
2Ease of repair
If statement-to-statement transformation is applied to maintain original code structure, then maintainability is improved, but transformation becomes impossible when destination language lacks equivalent language constructs
Solution Approach 1:
The patent segments the code transformation process into distinct phases: parsing the original source code into an abstract syntax tree that preserves structural information, translating to intermediate code that represents control flow independently of any specific language, and finally generating destination language code. This segmentation allows each phase to handle language-specific concerns separately while maintaining overall structural fidelity.
3Reliability
If massive restructuring or manual reimplementation is performed to handle jump instructions in destination languages without jump constructs, then correct execution is achieved, but the transformed code becomes unrecognizable compared to the original program structure
Solution Approach 1:
The patent creates a structural copy of the original code's control flow graph in the intermediate representation, preserving the topology and relationships of jump instructions. This copied structure is then systematically mapped to the destination language's equivalent constructs, ensuring that the transformed code remains recognizable and traceable to the original while executing correctly in the target environment.
Data Source
Figure 1a
Figure 1b
Figure 2
AI summary
A computer implemented method and system to generate final code for execution in a 5 runtime environment, the method comprising: - Creation, via a compiler, of intermediate code from destination source code, whereby the destination source code has been compiled from a original source code which includes at least one jump instruction, by omitting the at least one jump instruction, the destination source code existing in a destination 10 programming language and the original source code in a source programming language, - Loading the intermediate code into an intermediate code manipulation unit, and - Creation, via the intermediate code manipulation unit, of the final code from the intermediate code, whereby the creation comprises an insertion of at least one 15 jump statement into the final code, and whereby the inserted at least one jump statement is functionally equivalent to the at least one omitted jump instruction.