Compilation device and compilation method

By generating and managing shared variable names and addresses in the compilation device, the data coverage problem caused by variable name conflicts between user programs is solved, and safe sharing and consistent access of data are achieved.

CN112334873BActive Publication Date: 2024-09-06OMRON CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980039733.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-07-03
Filing Date
2019-06-18
Publication Date
2024-09-06
Estimated Expiration
2039-06-18

AI Technical Summary

Technical Problem

When data is shared between multiple user programs, existing technology cannot effectively prevent accidental overwriting of data caused by variable name conflicts.

Method used

By pre-defining shared variables in the compilation device, the identifier of the user program is obtained, a shared variable name containing the identifier is generated, associated with the address, and embedded in the machine language to ensure the uniqueness of the variable name and ensure that the shared variable name is unique when accessing the shared variable. Variables are managed using an application programming interface (API).

Benefits of technology

It effectively prevents variable name conflicts, ensures data security and consistency, and avoids accidental overwriting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112334873B_ABST
    Figure CN112334873B_ABST
Patent Text Reader

Abstract

The present invention relates to a compiling device and a compiling method. When there are multiple programs defining shared variables, the variable names are prevented from conflicting and accidentally overwriting data. The compiling device (12) includes: an identifier acquisition unit (121a) for acquiring an identifier of a first user program; a shared variable name generation unit (121b) for generating a shared variable name including a variable name of a shared variable and the identifier; a conversion unit (121c) for converting the first user program into a machine language; and an address determination unit (122a) for determining the address of the shared variable. The address determination unit (122a) associates the shared variable name with the address of the shared variable and embeds it into the first user program that has been converted into the machine language.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a compiling device and a compiling method for preventing data shared between user programs from being accidentally overwritten. Background Art

[0002] In the past, there is a known control device as described below (see Patent Document 1). That is, when there are multiple user programs, data is exchanged between these user programs via a data storage unit. When data is exchanged between programs, a variable name is given to the data, and each user program uses the variable name as a key to write or read data from the data storage unit.

[0003] Furthermore, conventionally, there is known a platform for providing data services between different application frameworks (see Patent Document 2).

[0004] Moreover, in the past, there is a known identifier management method for a language management system, which manages identifiers in input / output specification descriptions in a language processing system that processes specification descriptions or language descriptions, or identifiers in input source programs / output object programs (see patent document 3).

[0005] Prior art literature

[0006] Patent Literature

[0007] Patent Document 1: Japanese Patent Publication No. 2000-132208

[0008] Patent Document 2: Japanese Patent Publication No. 2006-244488

[0009] Patent Document 3: Japanese Patent Publication No. 4-260134 Summary of the invention

[0010] Problems to be solved by the invention

[0011] However, none of the above techniques is a technique for preventing variable names from conflicting and accidentally overwriting data when multiple programs exist.

[0012] An object of an embodiment of the present invention is to prevent variable names from conflicting and accidentally overwriting data when there are multiple programs defining shared variables.

[0013] Technical means of solving problems

[0014] In order to solve the above-mentioned problem, in a compiling device of one scheme of the present invention, in the source code of a first user program, shared variables that can be referenced from both the first user program and the second user program are pre-defined, and the compiling device includes: an identifier acquisition unit, which acquires the identifier of the first user program; a shared variable name generation unit, which generates a shared variable name, and the shared variable name includes the variable name of the shared variable in the source code of the first user program and the identifier; a conversion unit, which converts the first user program into machine language; and an address determination unit, which determines the address of the shared variable, and the address determination unit embeds the shared variable name and the address of the shared variable into the first user program that has been converted into machine language in association with each other.

[0015] In order to solve the above-mentioned problem, a compilation method of one scheme of the present invention predefines, in the source code of a first user program, shared variables that can be referenced from both the first user program and the second user program. The compilation method is as follows: obtaining an identifier of the first user program, generating a shared variable name, the shared variable name including the variable name of the shared variable in the source code of the first user program and the identifier, converting the first user program into machine language, determining the address of the shared variable, and embedding the shared variable name in association with the address of the shared variable into the first user program that has been converted into machine language.

[0016] In order to solve the above problem, a compiling device according to one embodiment of the present invention includes: a determination unit for determining whether a variable referenced in a source code of a second user program is a shared variable; a conversion unit for converting the second user program into a machine language; and an address determination unit, wherein if the variable is not a shared variable, the address determination unit replaces a command for accessing the variable with a machine language command for accessing the address of the variable without using an application program interface (API); and if the variable is a shared variable, the conversion unit replaces a command for accessing the variable with a machine language command for accessing the variable via an API provided by a program management unit that knows the address of the shared variable.

[0017] In order to solve the above-mentioned problem, a compilation method of one scheme of the present invention includes: a determination step of determining whether a variable referenced in a source code of a second user program is a shared variable; and a conversion step of converting the second user program into a machine language. In the conversion step, if the variable is not a shared variable, a command for accessing the variable is replaced by a machine language command for accessing the address of the variable without using an application program interface (API); if the variable is a shared variable, a command for accessing the variable is replaced by a machine language command for accessing the variable via an API provided by a program management unit that knows the address of the shared variable.

[0018] Effects of the Invention

[0019] According to an aspect of the present invention, when there are multiple programs defining shared variables, it is possible to prevent conflict in variable names and accidental overwriting of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is a block diagram schematically showing an example of the structure of a first information processing device including a compiling device according to an embodiment.

[0021] Figure 2 This is a block diagram schematically showing an example of the configuration of a second information processing device according to one embodiment.

[0022] Figure 3 This is a diagram illustrating the details of a shared variable symbol table.

[0023] Figure 4 This is a diagram showing an example of a flowchart of a process of compiling and linking a program executed by a compiling device according to an embodiment.

[0024] Figure 5 This is a diagram showing an example of a flowchart of a process of compiling and linking a program executed by a compiling device according to an embodiment.

[0025] [Explanation of Symbols]

[0026] 1: First information processing device

[0027] 2: Second information processing device

[0028] 11: Storage device

[0029] 12: Compile device

[0030] 21: Program Management Department

[0031] 21a: Program A Management Department

[0032] 21b: Program B Management Department

[0033] 121: Compiler

[0034] 121a: Identifier acquisition unit

[0035] 121b: Shared variable name generation section

[0036] 121c: Conversion Department

[0037] 121d: Judgment Department

[0038] 122: Linker

[0039] 122a: Address determination unit DETAILED DESCRIPTION

[0040] §1 Application examples

[0041] use Figure 1 An example of an application scenario of the compiling device of this embodiment is described below. Figure 1 1 is a block diagram schematically showing an example of the structure of the first information processing device 1 including the compiling device 12 of the present embodiment. The compiling device 12 of the present embodiment is a device for preventing the conflict of variable names and accidental overwriting of data when there are multiple user programs defining shared variables.

[0042] The compiling device 12 generates a shared variable name, which includes the variable name and identifier of the shared variable contained in the source code of the first user program. The identifier is an identifier that can distinguish multiple user programs from each other. The compiling device 12 embeds the shared variable name and the address of the shared variable into the first user program that has been converted into the machine language in association with each other. In the source code of multiple user programs, even if the same variable name is accidentally assigned to multiple shared variables, the second user program that accesses the shared variable can use the shared variable name including the identifier to distinguish each shared variable.

[0043] §2 Structure Example

[0044] (Structure of the First Information Processing Device)

[0045] like Figure 1 As shown, the first information processing device 1 includes a storage device 11 and a compiling device 12. The storage device 11 stores a source 11a of a first user program (hereinafter referred to as program A) and a source 11b of a second user program (hereinafter referred to as program B). The compiling device 12 includes a compiler 121 and a linker 122. The compiler 121 includes an identifier acquisition unit 121a, a shared variable name generation unit 121b, a conversion unit 121c and a determination unit 121d. The linker 122 includes an address determination unit 122a.

[0046] The source 11a of program A defines a shared variable. That is, the source 11a of program A contains instructions for generating a shared variable and writing a value to the shared variable. The source 11b of program B refers to the shared variable. That is, the source 11b of program B contains instructions for reading the shared variable.

[0047] The storage device 11 is, for example, a nonvolatile memory or a hard disk, but is not limited thereto. By including the storage device 11, data loss can be reliably prevented.

[0048] The compiling device 12 compiles and links the source 11a of the program A (for example, a text file in which the program code is written by the user) in the storage device 11. When the source 11a of the program A is compiled and linked, it becomes an executable program. In addition, in this specification, the processing of compiling and linking is sometimes expressed as "compiling".

[0049] Specifically, in the source code of program A, a shared variable that can be referenced from both program A and program B is defined. The identifier acquisition unit 121a acquires the identifier of program A. The determination unit 121d determines whether the variable described in the source code of program A is a shared variable or a non-shared variable. For example, it is also possible to define whether a variable is a shared variable or a non-shared variable by making a prescribed declaration in the source code. The shared variable name generation unit 121b generates a shared variable name, and the shared variable name includes the variable name of the shared variable in the source code of program A and the identifier. The conversion unit 121c converts the source code of program A into machine language. For example, the compiler 121 generates a plurality of object codes from the source code of program A. The object code includes machine language code and location information, etc. The shared variable name generation unit 121b replaces the variable name of the shared variable with the generated shared variable name. In the object code, the access command to the shared variable is described by a symbolic reference (reference using a shared variable name).

[0050] The linker 122 is also called a linkage editor. The linker 122 combines multiple target codes converted by the compiler 121. The address determination unit 122a determines the address of the shared variable. The address determination unit 122a replaces the access (write / reference) command to the shared variable using the symbol reference in the target code with the access command to the shared variable using the address. That is, the address determination unit 122a replaces the command to access the shared variable in the program A that has been converted into the machine language with the command to access the address of the shared variable. Moreover, the address determination unit 122a embeds the shared variable name and the address of the shared variable into the program A that has been converted into the machine language in association. For example, the shared variable name and the address are embedded in the program A as a symbol table.

[0051] The program A in machine language (which has been converted into an execution format) is stored in the storage device 11. The first information processing device 1 sends the program A in machine language to the second information processing device 2.

[0052] (Structure of Second Information Processing Device)

[0053] Figure 2 1 is a block diagram schematically showing an example of the structure of the second information processing device 2 of the present embodiment. The second information processing device 2 may also be a control device such as a programmable logic controller (PLC) that controls the operation of various devices. The second information processing device 2 includes a program management unit 21, an auxiliary storage device 22, and a memory 23.

[0054] The program management unit 21 includes a program A management unit 21a and a program B management unit 21b. The program A management unit 21a executes the program A in machine language. The program B management unit 21b executes the program B in machine language.

[0055] The auxiliary storage device 22 stores the program A and the program B received from the first information processing device 1. The memory 23 temporarily stores the program A and the program B. The auxiliary storage device 22 is, for example, a nonvolatile memory or a hard disk, but is not limited thereto.

[0056] The memory 23 temporarily stores the program A and the program B. The memory 23 is, for example, a volatile memory, but is not limited thereto. The memory 23 includes a data storage unit 23a and a shared variable symbol table 23b. The data storage unit 23a stores data of shared variables that can be referenced by both the program A and the program B.

[0057] The shared variable referred to here is a variable that can be referenced from a plurality of user programs. The shared variable symbol table 23b stores the storage locations (addresses) of the shared variables stored in the data storage unit 23a.

[0058] (Execution of Program A)

[0059] Figure 3 2 is a detailed diagram illustrating a shared variable symbol table 23b. When the program A management unit 21a receives an instruction from the user to execute program A, it loads program A from the auxiliary storage device 22 and stores program A in the memory 23. Program A stored in the auxiliary storage device 22 is a program that has been converted into machine language (compiled and linked). Program A that has been converted into machine language includes a symbol table, which indicates the correspondence between the shared variable name and the address of the shared variable. Non-shared variables are variables that are only used in program A and can only be referenced by program A. In the compiled program A, the address of the non-shared variable is specified. In the compiled program A, the variable name information of the non-shared variable may not be retained. However, after being compiled, program A still includes the information of the shared variable name and address of the shared variable.

[0060] The program A management unit 21a obtains the information of the shared variable name and the corresponding address. The program A management unit 21a records the shared variable name and the address of the shared variable in the shared variable symbol table 23b in association with each other. Furthermore, the program A management unit 21a writes the data of the shared variable to the address of the data storage unit 23a.

[0061] (Identifier)

[0062] The identifier of a user program is a string or a numerical value inherent to the user program. The identifiers of multiple user programs are set to be non-repeating. For example, the program name of the user program, the path of the configuration target directory of the user program, a string arbitrarily set by the user, a universally unique identifier (UUID) or a domain name can also be used as the identifier of the user program.

[0063] Figure 3In the example, the identifier of program A is "Press". The variable name "status" is the variable name of a shared variable defined in the source code of program A. The shared variable name generation unit 121b generates the shared variable name "Press.status" of the shared variable by combining the identifier "Press" with the original variable name "status". The shared variable name "Press.status" is the variable name used as a keyword when referencing the shared variable from another program B. Here, "." is added between the identifier and the variable name, but any text or character string can be used instead. Furthermore, there may be no text between the identifier and the variable name. The order of the identifier and the variable name is also arbitrary. For example, Figure 3 The illustrated "Cutter.status" is the shared variable name of the shared variable defined in program B. The identifier of program B is "Cutter". The variable name of the shared variable defined in program B is "status". The shared variable name generation unit 121b generates a shared variable name including an identifier and a variable name according to a prescribed rule. Thus, in multiple user programs, even if the variable name "status" defines multiple shared variables with the same name, conflicts in shared variable names can be avoided. For example, the shared variable names include Press.status and Cutter.status, and the addresses corresponding to these shared variable names are 0X00000000 and 0X00000001, respectively, but this does not limit the present embodiment.

[0064] (Compile and link program B)

[0065] Program B refers to (reads) the shared variable defined (generated) by program A. Compiler 12 of first information processing device 1 compiles and links source 11b of program B.

[0066] Specifically, in the source code of program B, there is a command for referring to a shared variable defined in another program A. In addition, it is assumed that the user already knows the shared variable name "Press.status" of the shared variable to be referred to. For example, when creating program B, the user describes the source code using the shared variable name "Press.status" as the variable name of the shared variable.

[0067] The determination unit 121d determines whether the variable described in the source code of the program B is a shared variable or a non-shared variable. Furthermore, the determination unit 121d determines whether the shared variable described in the source code of the program B is a shared variable generated (defined) in the program B or a shared variable generated (defined) in another program. For example, it is also possible to define whether a variable is a shared variable generated in the own program, a shared variable generated in another program, or a non-shared variable by making a prescribed declaration in the source code. Furthermore, for example, the determination unit 121d may also determine whether the variable is a shared variable generated in another program when the variable name of the variable contains a prescribed identifier (an identifier of another program).

[0068] The conversion unit 121c converts the source code of the program B into a machine language. If the variable is a shared variable generated in the own program, the method of compiling and linking is the same as that described for the program A.

[0069] The case where the variable is a shared variable generated in another program (e.g., program A) is described. In the case where the variable is a shared variable generated in another program (e.g., program A), the conversion unit 121c replaces the command for accessing (referencing) the shared variable in the source code of the program B with a machine language command for accessing the shared variable via an application program interface (API). The API is an API provided by the program management unit 21 that already knows the address of the shared variable. The program management unit 21 can obtain the address of the shared variable from the shared variable symbol table 23b using the shared variable name as a keyword.

[0070] For example, the program management unit 21 (the program A management unit 21a and the program B management unit 21b) provides a first API that uses a shared variable name as a keyword to return the value (data) of a shared variable, or a second API that uses a shared variable name as a keyword to return the address of a shared variable, and a third API that uses the address as a keyword to return the value of a variable (shared variable). The conversion unit 121c may also replace the command for accessing (referencing) a shared variable in the source code of the program B with a machine language command for referencing a shared variable via the first API. The conversion unit 121c may also replace the command for accessing (referencing) a shared variable in the source code of the program B with a machine language command for obtaining an address via the second API and a machine language command for referencing a shared variable via the third API.

[0071] The linker 122 combines the multiple object codes converted by the compiler 121. For the shared variables generated in other programs, the address is not determined. If the variable is a non-shared variable (not a shared variable), the address determination unit 122a replaces the command for accessing the variable in the program B converted into machine language (using symbol reference) with a machine language command for accessing the address of the variable without using the API.

[0072] Program B in machine language (converted into an executable format) is stored in storage device 11. First information processing device 1 sends program B in machine language to second information processing device 2. Program A and program B may be compiled and linked in different information processing devices.

[0073] (Execution of Program B)

[0074] In the second information processing device 2, program A is executed first, and the shared variable names and addresses of the shared variables defined in program A are recorded in the shared variable symbol table 23b. When the program B management unit 21b receives an instruction from the user to execute program B, it loads program B from the auxiliary storage device 22 and stores program B in the memory 23. Program B stored in the auxiliary storage device 22 is a program that has been converted into machine language (compiled and linked). Program B that has been converted into machine language contains a command to call an API (first API, second API, or third API) that uses the shared variable name as a keyword to refer to the shared variable. In the compiled program B, the address of the non-shared variable is specified. In the compiled program B, the variable name information of the non-shared variable may not be retained. However, after being compiled, program B still contains the shared variable name information of the shared variable.

[0075] Program B uses the shared variable name "Press.status" of the shared variable as a keyword and provides it to the program B management unit 21b via the API function. The program B management unit 21b obtains the address corresponding to the shared variable name from the shared variable symbol table 23b. The program B management unit 21b uses the address as a keyword to obtain the data of the shared variable from the data storage unit 23a. The program B management unit 21b returns the data of the shared variable to program B. In this way, the program B management unit 21b can refer to the shared variable symbol table 23b to know the address of the shared variable.

[0076] Generally, a compiler-type user program is converted into a machine language. Therefore, the variable name specified in the source file is converted into an address and is not retained. According to the embodiment, by using an API that references a shared variable, the shared variable name in the compiled and linked program B is retained as a keyword.

[0077] The program A and the program B may also include different programming languages. According to the embodiment, variables can be shared between the program A and the program B that include different programming languages. For example, the program A and the program B may also include the same programming language.

[0078] Here, as program A or program B, a program using ladder language or C language, etc. can be listed, but this does not limit the present embodiment. Ladder language is a programming language suitable for the case where the second information processing device 2 performs motion control of a machine tool or a production device, etc. For example, in the case of C language, the source is a text file. For example, in the case of ladder language, the source can be a text file or a binary file expressing a ladder diagram.

[0079] According to the compiling device 12 of this embodiment, when there are a plurality of programs defining shared variables, it is possible to prevent the conflict of variable names and the unintentional overwriting of data.

[0080] In addition, the compiling device 12 may replace the command for accessing the shared variable with the machine language command for accessing the shared variable via the API not only in the program B but also in the program A that defines the shared variable. At this time, if the shared variable name is not recorded in the shared variable symbol table 23b, the program A management unit 21a that executes the program A determines the address assigned to the shared variable. The program A management unit 21a records the determined address in the shared variable symbol table 23b in association with the shared variable name.

[0081] (Structure example 1 of identifier)

[0082] Hereinafter, the configuration example 1 of the identifier according to the present embodiment 1 will be described. The configuration example 1 of the identifier may be, for example, an independent variable specified by the user when compiling and executing. Then, the identifier acquisition unit 121a uses the independent variable as the identifier.

[0083] (Structure example 2 of identifier)

[0084] Another structural example of the identifier of the present embodiment 1 is described below. The identifier is not limited to the independent variable. For example, the identifier may also include a predetermined path for configuring the program A. When the user creates program A, the path of the directory where program A is to be configured is predefined in program A. Alternatively, the path of program A may be obtained by program A itself. The first information processing device 1 and the second information processing device 2 may be the same information processing device without being separated.

[0085] (Structure example 3 of identifier)

[0086] Hereinafter, another structural example of the identifier of the present embodiment 1 will be described. The identifier is not limited to the independent variable and the path. For example, the identifier may also include the file name of the program A. Similar to the path, the file name may be specified in the program A or may be obtained by the program A itself.

[0087] (Example 1 of obtaining an identifier)

[0088] The following describes an example of obtaining an identifier according to Embodiment 1. As described above, the identifier obtaining unit 121a obtains the identifier of the program A. Specifically, the identifier obtaining unit 121a obtains the identifier from a setting file. The setting file that defines the identifier of the program A is stored in a predetermined directory.

[0089] (Example 2 of obtaining an identifier)

[0090] Hereinafter, another example of obtaining the identifier of the first embodiment will be described. The target of obtaining the identifier is not limited to the setting file. For example, the identifier obtaining unit 121a may also obtain the identifier from the source code of the program A. In this case, a shared variable that can be referenced by both the program A and the program B is defined in the source code.

[0091] (Structure of the shared variable name generation unit)

[0092] As described above, the shared variable name generating unit 121b generates a shared variable name including the variable name of the shared variable and the identifier in the source code of the program A. Examples of the shared variable name include Press.status, Cutter.status, and the like.

[0093] (Conversion Unit Structure)

[0094] As described above, the conversion unit 121c converts the programs A and B into machine languages. Specifically, the conversion unit 121c replaces the command for accessing the shared variable in the source code of the program A with a machine language command for accessing the address of the shared variable.

[0095] The conversion unit 121 c replaces the command for accessing the shared variable with a machine language command for accessing the shared variable via an API provided by the program management unit that knows the address of the shared variable.

[0096] (Compile method)

[0097] Figure 4It is a flowchart of the process of compiling and linking the program A executed by the compiling device 12 of the present embodiment. In step S1, the identifier acquisition unit 121a acquires the identifier of the program A (first user program). Then, in step S2, the shared variable name generation unit 121b generates a shared variable name, and the shared variable name includes the variable name of the shared variable in the source code of the program A and the identifier. Then, in step S3, the conversion unit 121c converts the program A into machine language. Then, in step S4, the address determination unit 122a determines the address of the shared variable. Finally, in step S5, the address determination unit 122a embeds the shared variable name and the address of the shared variable into the program A that has been converted into the machine language in association with each other.

[0098] Figure 5 This is a flowchart of the process of compiling and linking program B executed by the compiler 12 of this embodiment. In step S6, the determination unit 121d determines whether the variable referenced in the source code of program B is a shared variable. The conversion unit 121c converts program B into machine language. At this time, if the variable is a shared variable (yes in S6), the command to access the variable is replaced by a machine language command to access the variable via an API provided by the program management unit that knows the address of the shared variable (S8). If the variable is not a shared variable (no in S6), then at the linking stage, the address determination unit 122a replaces the command to access the variable with a machine language command to access the address of the variable without using the API (S7). Here, the compilation and linking processes are collectively referred to as the conversion process.

[0099] According to the embodiment, even if program B and the first information processing device 1 do not know the address of the shared variable generated by other program A, the compiling device 12 can compile and link program B in a way that program B can access the shared variable.

[0100] In this way, the conversion unit 121c replaces the access (write / reference) command to the shared variable in the source 11b of the program B with a command using the API. In the program B converted into the machine language, the address of the shared variable is not determined.

[0101] In addition, the address of the non-shared variable is determined by the address determination unit 122a, and the variable name of the non-shared variable in the machine language program B is replaced by the address.

[0102] 〔Example of implementation using software〕

[0103] The control blocks of the compilation device 12 and the program management unit 21 (especially the identifier acquisition unit 121a, the shared variable name generation unit 121b, the conversion unit 121c, the judgment unit 121d, the address determination unit 122a, the program A management unit 21a and the program B management unit 21b) can be implemented by a logic circuit (hardware) formed on an integrated circuit (IC) chip or the like, or by software.

[0104] In the latter case, the compiling device 12 and the program management unit 21 include a computer that executes the commands of the software, i.e., the program, that realizes each function. The computer includes, for example, one or more processors and a computer-readable recording medium storing the program. In addition, in the computer, the program is read and executed from the recording medium by the processor, thereby achieving the purpose of the present invention. As the processor, for example, a central processing unit (CPU) can be used. As the recording medium, a "non-temporary tangible medium" can be used, for example, in addition to a read-only memory (ROM), a tape, a disk, a card, a semiconductor memory, a programmable logic circuit, etc. can also be used. Moreover, a random access memory (RAM) for expanding the program can also be included. Moreover, the program can also be provided to the computer via any transmission medium (communication network or broadcast wave, etc.) that can transmit the program. In addition, an embodiment of the present invention can also be implemented in the form of a data signal embedded in a carrier wave that materializes the program through electronic transmission.

[0105] 〔Summarize〕

[0106] A compiling device according to one embodiment of the present invention predefines, in the source code of a first user program, shared variables that can be referenced from both the first user program and a second user program, the compiling device comprising: an identifier acquisition unit that acquires the identifier of the first user program; a shared variable name generation unit that generates a shared variable name, the shared variable name including the variable name of the shared variable in the source code of the first user program and the identifier; a conversion unit that converts the first user program into machine language; and an address determination unit that determines the address of the shared variable, the address determination unit embeds the shared variable name and the address of the shared variable into the first user program that has been converted into machine language in association with each other.

[0107] According to the embodiment, when there are multiple programs defining shared variables, it is possible to prevent conflict in variable names and prevent accidental overwriting of data.

[0108] In one embodiment of the present invention, the address determination unit may replace a command for accessing the shared variable in the first user program converted into a machine language with a command for accessing the address of the shared variable.

[0109] According to the embodiment, the conversion unit can replace the command for accessing the shared variable with a machine language command for accessing the address of the shared variable. In a program that defines a shared variable, the shared variable can be accessed by using the address, thereby enabling high-speed access.

[0110] According to an embodiment of the present invention, the identifier acquisition unit acquires the identifier from a setting file.

[0111] According to the embodiment, the identifier acquisition unit can acquire the identifier from a setting file.

[0112] According to an embodiment of the present invention, the identifier acquisition unit acquires the identifier from the source code of the first user program.

[0113] According to the embodiment, the identifier acquisition section can acquire the identifier from the source code of the first user program.

[0114] According to an embodiment of the present invention, the identifier acquisition unit uses an independent variable specified by a user during compilation and execution as the identifier.

[0115] According to the embodiment, the identifier acquisition unit can use the argument as the identifier.

[0116] According to an embodiment of the present invention, the identifier includes a predetermined path for configuring the first user program.

[0117] According to the embodiment, the identifier can contain a predetermined path for configuring the first user program.

[0118] According to an embodiment of the present invention, the identifier includes a file name of the first user program.

[0119] According to the exemplary embodiment, the identifier can contain the file name of the first user program.

[0120] In a compilation method of one embodiment of the present invention, in the source code of a first user program, shared variables that can be referenced from both the first user program and the second user program are pre-defined. The compilation method is: obtaining an identifier of the first user program, generating a shared variable name, the shared variable name including the variable name of the shared variable in the source code of the first user program and the identifier, converting the first user program into machine language, determining the address of the shared variable, and embedding the shared variable name in association with the address of the shared variable into the first user program that has been converted into machine language.

[0121] A compiling device according to one embodiment of the present invention includes: a determination unit for determining whether a variable referenced in a source code of a second user program is a shared variable; a conversion unit for converting the second user program into a machine language; and an address determination unit for replacing a command for accessing the variable with a machine language command for accessing the address of the variable without using an application program interface (API) if the variable is not a shared variable, and replacing a command for accessing the variable with a machine language command for accessing the variable via an API provided by a program management unit that knows the address of the shared variable if the variable is a shared variable.

[0122] According to the embodiment, the second user program can be compiled and linked in such a way that the second user program can access the shared variables defined by other first user programs.

[0123] A compiling method according to one embodiment of the present invention comprises: a determination step of determining whether a variable referenced in a source code of a second user program is a shared variable; and a conversion step of converting the second user program into a machine language, wherein in the conversion step, if the variable is not a shared variable, a command for accessing the variable is replaced with a machine language command for accessing the address of the variable without using an application program interface (API); and if the variable is a shared variable, a command for accessing the variable is replaced with a machine language command for accessing the variable via an API provided by a program management unit that knows the address of the shared variable.

[0124] The present invention is not limited to the above-described embodiments, and various modifications can be made within the scope of the claims. Embodiments obtained by appropriately combining technical components disclosed in different embodiments are also included in the technical scope of the present invention.

Claims

1. A compiling device, characterized in that: In the source code of the first user program, a shared variable that can be referenced by both the first user program and the second user program is predefined. The compiling device comprises: An identifier acquisition unit, which acquires an identifier of the first user program; A shared variable name generating unit, generating a shared variable name, wherein the shared variable name includes the variable name of the shared variable in the source code of the first user program and the identifier; a conversion unit, converting the first user program and the second user program into a machine language; and An address determination unit determines an address where the shared variable is stored in a memory, The address determination unit embeds the shared variable name and the address of the shared variable into the first user program converted into a machine language in association with each other, In the source code of the second user program, the shared variable is referenced using the shared variable name, The conversion unit replaces a command in the source code of the second user program that refers to the shared variable with a machine language command that accesses the shared variable via an application program interface, and the application program interface obtains the address of the shared variable from a shared variable symbol table that stores the address of the shared variable.

2. The compiling device according to claim 1, characterized in that: The address determination unit replaces a command for accessing the shared variable in the first user program converted into a machine language with a command for accessing the address of the shared variable.

3. The compiling device according to claim 1 or 2, characterized in that: The identifier acquisition unit acquires the identifier from a setting file.

4. The compiling device according to claim 1 or 2, characterized in that: The identifier acquisition unit acquires the identifier from the source code of the first user program.

5. The compiling device according to claim 1 or 2, characterized in that: The identifier acquisition unit uses an argument specified by a user when compiling and executing as the identifier.

6. The compiling device according to claim 1 or 2, characterized in that: The identifier includes a predetermined path for configuring the first user program.

7. The compiling device according to claim 1 or 2, characterized in that: The identifier includes the file name of the first user program.

8. A compiling method, characterized in that: In the source code of the first user program, a shared variable that can be referenced by both the first user program and the second user program is predefined, and the compiling method is: obtaining an identifier of the first user program, generating a shared variable name, wherein the shared variable name includes the variable name of the shared variable in the source code of the first user program and the identifier, converting the first user program and the second user program into machine language, Determine the address in memory where the shared variable is stored, embedding the shared variable name and the address of the shared variable into the first user program converted into machine language in association with each other, In the source code of the second user program, the shared variable is referenced using the shared variable name, A command in the source code of the second user program that refers to the shared variable is replaced with a machine language command that accesses the shared variable via an application program interface, and the application program interface obtains the address of the shared variable from a shared variable symbol table that stores the address of the shared variable.

9. A compiling device, characterized in that: include: a determination unit that determines whether a variable referenced in a source code of a second user program is a shared variable; a conversion unit, converting the second user program into a machine language; and Address Determination Department, If the variable is not a shared variable, the address determination unit replaces the command for accessing the variable with a machine language command for accessing the address of the variable without using an application program interface. If the variable is a shared variable predefined in the source code of another program, the conversion unit replaces the command for accessing the variable with a machine language command for accessing the variable via an application program interface provided by a program management unit that knows the address of the shared variable. The program management unit uses the shared variable name as a keyword to obtain the address of the shared variable from the shared variable symbol table, wherein the shared variable name includes an identifier of the program defining the shared variable and a variable name of the shared variable. In the source code of the second user program, the shared variable is referenced using the shared variable name.

10. A compiling method, characterized in that: include: A determination step of determining whether the variable referenced in the source code of the second user program is a shared variable; as well as a conversion step, converting the second user program into machine language, In the conversion process, If the variable is not a shared variable, the command for accessing the variable is replaced by a machine language command for accessing the address of the variable without using an application program interface. If the variable is a shared variable predefined in the source code of another program, the command for accessing the variable is replaced by a machine language command for accessing the variable via an application program interface provided by a program management unit that knows the address of the shared variable. The program management unit uses the shared variable name as a keyword to obtain the address of the shared variable from the shared variable symbol table, wherein the shared variable name includes an identifier of the program defining the shared variable and a variable name of the shared variable. In the source code of the second user program, the shared variable is referenced using the shared variable name.