# US 2022/0291938 A1 · Compiling a specified instruction from a first virtual application to a second virtual application

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0291938 A1
- Document ID: US20220291938A1
- Status: Published application
- Kind: A1
- Application number: 17/196,053
- Filed: 2021-03-09
- Published: 2022-09-15
- Earliest claimed: 2021-03-09
- Assignees: Red Hat, Inc.
- Applicants: Red Hat, Inc.
- Inventors: Ryan Goulding; Andrew Toth; Aneesh Puttur
- Web page: https://patentgrep.com/patent/US20220291938A1

## CPC

- G06F 8/76: Adapting program code to run in a different environment; Porting
- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 8/51: Source to source
- G06F 9/30145: {Instruction analysis, e.g. decoding, instruction word fields}
- G06F 9/3836: {Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution}
- G06F 2009/4557: {Distribution of virtual machine instances; Migration and load balancing}
- G06F 2009/45579: {I/O management, e.g. providing access to device drivers or storage}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods are described for compiling a specified instruction from a first virtual application to a second virtual application. Each virtual application may be associated with different programming languages. In an example method, a computing device receives a request to execute the specified instruction in the second virtual application. A target data structure may be created, using a library of the second virtual application, where a template directory may be stored. First syntax features, each defining a respective variable may be identified. An abstract syntax tree may be used to derive, for each first syntax feature, a modified definition for the respective variable. Second syntax features may be generated that define the respective variables more precisely than the first syntax features. The specified instruction may be rendered the second virtual application and may be expressed via the second syntax features and their respective variables.

## Claims

### Claim 1

A method comprising:
receiving, by a processor and from a first virtual application, a request to execute a specified instruction in a second virtual application, wherein the first virtual application is associated with a first programming language and a second virtual application is associate with a second programming language;
creating, using a library of a second virtual application, a target data structure within the second virtual application;
storing, to a template directory in the target data structure, one or more templates identified from the specified instruction;
identifying, from the specified instruction, first syntax features, wherein each first syntax feature defines a respective variable;
generating, using the specified instruction, an abstract syntax tree to derive, for each first syntax feature, a modified definition for the respective variable;
generating, based on the modified definitions, and using the library of the second virtual application, second syntax features that define the respective variables more precisely than the first syntax features; and
rendering, using the second virtual application, the specified instruction into the one or more templates, the specified instruction expressed via the second syntax features and their respective variables.

### Claim 2 (depends on 1)

The method of claim 1, wherein the generating the second syntax features comprises:
translating a template function of the first virtual application to a filter replacement.

### Claim 3 (depends on 1)

The method of claim 1, wherein the generating the second syntax features results in a smaller allocation of dynamic memory when executing the specified instruction in the second virtual application.

### Claim 4 (depends on 1)

The method of claim 1, further comprising, before the rendering,
storing, in the template directory of the target data structure, one or more template properties of the first virtual application.

### Claim 5 (depends on 4)

The method of claim 4, further comprising:
removing, from the template directory, one or more self-references for the one or more template properties that are incompatible in the second virtual application.

### Claim 6 (depends on 4)

The method of claim 4, further comprising:
determining a new template property for a self-reference for the one or more template properties; and
converting the self-reference to the new template property.

### Claim 7 (depends on 1)

The method of claim 1, wherein the first syntax features comprises a first conditional statement, a first branch instruction, and a first function statement for the first virtual application, and wherein the second syntax features comprises a second conditional statement, a second branch instruction, and a second function statement for the second virtual application.

### Claim 8 (depends on 7)

The method of claim 7, wherein the generating the second syntax features comprises:
deriving, after analyzing the specified instruction, a modified definition of an ending of the first branch instruction; and
generating, based on the modified definition of the ending of the first branch instruction, the second branch instruction, wherein the second branch instruction is more precise than the first branch instruction.

### Claim 9 (depends on 1)

The method of claim 1, wherein the generating the second syntax features comprises translating a “range” function to a “for” loop.

### Claim 10 (depends on 1)

The method of claim 1, further comprising:
executing, by the processor, the specified instruction using the second syntax features, wherein executing the specified instruction using the second syntax features results in less CPU cycles than executing the specified instruction using the first syntax features.

### Claim 11

A system comprising:
a first server hosting a first virtual application;
a second server hosting a second virtual application; and
a computing device comprising:
a processor; and
memory storing instructions that, when executed by the processor, cause the processor to:
receive, from the first server, a request to compile a specified instruction for the second virtual application, wherein the request includes an identifier of the second server;
cause, using the identifier, the second server to create a target data structure within the second virtual application;
store one or more templates identified from the specified instruction to a template directory in the target data structure;
identify, from the specified instruction, a plurality of first syntax features, each first syntax feature defining a respective variable;
determine, using the specified instruction and for each first syntax feature, a modified definition for the respective variable;
generate, based on the modified definitions, and using a library of the second virtual application, second syntax features defining the respective variables more precisely; and
render, using the second virtual application, the specified instruction into the one or more templates, the specified instruction expressed via the second syntax features and their respective variables.

### Claim 12 (depends on 11)

The system of claim 11, wherein the instructions, when executed, cause the processor to generate the second syntax features by:
translating a template function of the first virtual application to a filter replacement.

### Claim 13 (depends on 11)

The system of claim 11, wherein the system further comprises:
a library associated with the first virtual application; and
the library associated with the second virtual application.

### Claim 14 (depends on 11)

The system of claim 11, wherein the first syntax features comprises a first conditional statement, a first branch instruction, and a first function statement for the first virtual application, and wherein the second syntax features comprises a second conditional statement, a second branch instruction, and a second function statement for the second virtual application.

### Claim 15 (depends on 14)

The system of claim 14, wherein the instructions, when executed, further cause the processor to generate the second syntax features by:
determining, based on the first conditional statement defining a variable in the specified instruction, a modified definition of the variable defined by the first conditional statement in the specified instruction; and
generating, in the target data structure and based on the modified definition of the variable defined by the first conditional statement, a second conditional statement defining the variable more precisely than the first conditional statement.

### Claim 16 (depends on 11)

The system of claim 11, wherein the instructions, when executed, further cause the processor to:
store, in the template directory in the target data structure, one or more template properties of the first virtual application; and
identify, within the one or more template properties, one or more self-references that are incompatible with the second virtual application.

### Claim 17

A non-transitory computer readable medium for use on a computer system containing computer-executable programming instructions for cross-compiling specified instruction between two virtual applications, the instructions comprising:
receiving, from a first virtual application, a request to compile a source code for the specified instruction for a second virtual application;
creating, using a library associated with the second virtual application, a target data structure within the second virtual application;
storing one or more templates identified from the specified instructions to a template directory in the target data structure;
identifying, from the source code, a plurality of first syntax features, each first syntax feature defining a respective variable;
determining, using the specified instruction and for each first syntax feature, a modified definition for the respective variable;
generating, based on the modified definitions, and using the library of the second virtual application, second syntax features defining the respective variables more precisely; and
rendering, using the second virtual application, the specified instruction into the one or more templates, the specified instruction comprising the second syntax features and their respective variables.

### Claim 18 (depends on 17)

The non-transitory computer readable medium of claim 17, wherein the first syntax features comprises a first conditional statement, a first branch instruction, and a first function statement for the first virtual application, and wherein the second syntax features comprises a second conditional statement, a second branch instruction, and a second function statement for the second virtual application.

### Claim 19 (depends on 18)

The non-transitory computer readable medium of claim 18, wherein the generating the second syntax features comprises:
determining, based on the first conditional statement defining a variable in the specified instruction, a modified definition of the variable defined by the first conditional statement in the specified instruction; and
generating, in the target data structure and based on the modified definition of the variable defined by the first conditional statement, a second conditional statement defining the variable more precisely than the first conditional statement.

### Claim 20 (depends on 17)

The non-transitory computer readable medium of claim 17, wherein the determining the modified definition, for each variable, further comprises:
generating an Abstract Syntax Tree (AST) to derive the modified definitions for the respective variables defined by the first syntax features.
