C language compilation method and device based on RINSIM simulation platform

By detecting and replacing polymorphic subfunctions in the RINSIM simulation platform, the problem that the platform cannot link polymorphic functions is solved, the compilation and linking of C language programs is realized, and the functionality and development efficiency of the simulation platform are improved.

CN113946338BActive Publication Date: 2024-10-18CHINA NUCLEAR POWER OPERATION TECH CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111036453.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-06
Publication Date
2024-10-18
Estimated Expiration
2041-09-06

AI Technical Summary

Technical Problem

The RINSIM simulation platform cannot link polymorphic functions, resulting in the inability to achieve DCS simulation effects and limiting its application in nuclear power plants.

Method used

By detecting variables and functions in the source program, it generates variable and module information that complies with RINSIM compilation rules, dynamically replaces polymorphic subfunctions with fuzzy polymorphic functions, and ignores polymorphic subfunctions during the compilation process to generate headers that comply with compilation rules. file, and ultimately generate an executable program.

Benefits of technology

The RINSIM simulation platform is implemented to compile and link C language programs containing polymorphic functions, which enhances the functionality and friendliness of the platform, reduces development workload, improves simulation accuracy, and reduces update complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113946338B_ABST
    Figure CN113946338B_ABST
Patent Text Reader

Abstract

The present disclosure belongs to the field of nuclear power technology, and specifically relates to a C language compilation method and device based on the RINSIM simulation platform. The present disclosure dynamically generates a variable database and a module database for the source program to be compiled, and the RINSIM simulation platform can link the target code generated by the C language simulation program containing polymorphic functions into an executable program. The functionality and friendliness of the RINSIM platform are enhanced. The workload of simulation program development for general engineering projects is effectively reduced, the development cycle is shortened, human errors are reduced, simulation accuracy is improved, and the complexity of subsequent program updates is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of nuclear power technology, and in particular relates to a C language compiling method and device based on a RINSIM simulation platform. Background Art

[0002] The RINSIM simulation platform is an integrated simulation platform for nuclear power plants and a full-life support platform for the development of nuclear power plants and nuclear power simulation systems. The graphical modeling tool of the original RINSIM simulation platform generates FORTRAN code, and the simulation engineering software used, such as NAFET and REALP, is also FORTRAN code, so only the compilation function is implemented for FORTRAN code.

[0003] Polymorphism is a feature of the C++ language that allows methods to have duplicate names and different parameter types. With the application of DCS in nuclear power plants, nuclear power simulators need to implement DCS simulation. The control programs of DCS manufacturers are widely developed in C\C++ language. Polymorphic functions are inevitably used. However, the linking process of the RINSIM simulation platform does not support linking polymorphic functions, resulting in the inability of the RINSIM simulation platform to call the functions with polymorphic requirements, which makes the RINSIM simulation platform unable to achieve the DCS simulation effect. Summary of the invention

[0004] In order to overcome the problems existing in the related art, a C language compiling method and device based on a RINSIM simulation platform are provided.

[0005] According to another aspect of an embodiment of the present disclosure, a C language compiling method based on a RINSIM simulation platform is provided, the method comprising:

[0006] When it is detected that the source program to be compiled includes a variable, variable information that complies with the compilation rules of the RINSIM simulation platform is generated according to the variable, and the variable information is added to the variable database;

[0007] When detecting that the source program includes a function that complies with the compilation rule, adding function information of the function to a module database;

[0008] According to the detected multiple polymorphic sub-functions with the same name features, a fuzzy polymorphic function that complies with the compilation rule is generated, one of the multiple polymorphic sub-functions with the same name features is replaced with the fuzzy polymorphic function, and the function information of the module polymorphic function is added to the module database, and the fuzzy polymorphic function can realize all functions of the multiple polymorphic sub-functions with the same name features;

[0009] In the process of compiling and preprocessing the source program, a header file is generated for the source program according to the variable database and the module database, wherein the header file defines the actual position information of each variable in the source program that complies with the compilation rules, ignores the polymorphic sub-functions in the source program, and defines the format of the function that complies with the compilation rules;

[0010] The source program is compiled according to the header file to generate a target program.

[0011] In a possible implementation, for the source program, generating a header file according to the variable database and the module database includes:

[0012] When it is detected that a statement in the source program contains a global variable area and a variable, a first type identifier is marked before the statement;

[0013] Scanning the source program line by line, if it is detected that a statement of the source program contains a first type of identifier, intercepting a variable name corresponding to the statement, and determining variable information of the variable according to the variable database;

[0014] Determine the actual position information of the variable according to the variable information of the variable;

[0015] According to the actual location information of each variable, the actual location of each variable is defined in the header file.

[0016] In a possible implementation, determining the actual position information of the variable according to the variable information of the variable includes:

[0017] When the intercepted variable is an array variable, the actual position information of the variable is determined according to the subscript and starting position of the variable;

[0018] When the intercepted variable is a complex variable, the actual position information of the variable is determined according to the field offset and parent node position information of the variable.

[0019] In a possible implementation, the actual position of each variable is defined in a header file according to the actual position information of each variable, including:

[0020] Generate a memory list and a first symbol chain list according to the actual location information of each variable, wherein the memory list includes the actual location information corresponding to each variable of the source program, and the first symbol chain list includes the name of each variable of the source program;

[0021] Traversing the memory list, generating a definition of each referenced memory modified with externchar in the header file in C language format, and defining a static pointer variable to point to the referenced memory area;

[0022] The first symbol linked list is traversed, and when a global variable is detected, a C language macro definition modified with #define is generated in the header file to bind the global variable to the actual location information of the global variable.

[0023] In a possible implementation, for the source program, generating a header file according to the variable database and the module database further includes:

[0024] When it is detected that the statements in the source program include a main function, a second type of identifier is marked before the statement; when it is detected that the statements in the source program include a polymorphic function, a third type of identifier is marked before the statement;

[0025] Scan the source program line by line and perform the following operations:

[0026] If it is detected that the statement of the source program contains the second type of identification, the main function name of the statement is intercepted, and when the intercepted main function name is included in the module database, the main function name is added to the second symbol chain list;

[0027] If it is detected that the statement of the source program contains the third type of identifier, the polymorphic sub-function name of the statement is intercepted, and when the intercepted polymorphic sub-function name is included in the module database, the polymorphic sub-function name is added to the second symbol chain list and the polymorphic list;

[0028] End the line-by-line scanning of the source program, generate a second symbol chain list and a polymorphic list, the second symbol chain list includes each function of the source program, and the polymorphic list includes each polymorphic sub-function of the source program;

[0029] The second symbol linked list is traversed, and when a sub-function is detected, it is determined whether the sub-function exists in the polymorphic list. If the sub-function exists in the polymorphic list, the sub-function is ignored by definition in the header file; if the sub-function does not exist in the polymorphic list, the sub-function name is modified in the macro definition of the header file to a format that complies with the compilation rules.

[0030] In a possible implementation, the method further includes:

[0031] Generate an executable program name, a reference memory list, a module list and a scheduling list according to the configuration file of the source program, wherein the module list includes information of a main calling function in the configuration file and information of a sub-calling function called by the main calling function, and the scheduling list includes a scheduling relationship between the main calling function in the configuration file and the sub-calling function called by the main calling function;

[0032] Generate a first intermediate list according to the reference memory list, generate a second intermediate list according to the module list, and generate a third intermediate list according to the scheduling list;

[0033] Generate a C file according to the configuration file, the first intermediate list, the second intermediate list, and the third intermediate list, wherein the C file includes a GLOBTAB array corresponding to the first intermediate list, a MODTAB array corresponding to the second intermediate list, and a CNTRTAB array corresponding to the third intermediate list;

[0034] The C file is compiled to generate an executable file, and the executable file is periodically scheduled for execution by the RINSIM simulation platform. When the RINSIM simulation platform first schedules the execution of the executable file, it associates the real-time database according to the GLOBTAB array, then traverses the CNTRTAB array, and executes each main calling function contained in the CNTRTAB array. If it is detected that the main calling function contains one or more sub-calling functions, the symbol information of the one or more sub-calling functions is determined according to the sub-calling function and the MODTAB array, and the one or more sub-calling functions are called according to the determined symbol information of the one or more sub-calling functions.

[0035] In a possible implementation, generating an executable program name, a reference memory list, a module list, and a scheduling list according to a configuration file of the source program includes:

[0036] When it is detected that the configuration file of the source program contains exec, identifying the executable program name generated by the final link of the configuration file;

[0037] When it is detected that the configuration file contains a share, a shared memory name corresponding to the share is identified, and the identified shared memory name is added to a reference memory list;

[0038] When it is detected that the configuration file contains load, a scheduling module corresponding to the load is identified, and if it is determined that the target program of the identified scheduling module already exists, the scheduling module is added to the module list and the scheduling list, and if it is determined that the scheduling module references a submodule, the submodule referenced by the scheduling module is also added to the module list and the scheduling list;

[0039] When it is detected that the configuration file contains exit, the configuration file is processed and the final reference memory list, module list and scheduling list are generated.

[0040] In a possible implementation, generating a first intermediate list according to the reference memory list, generating a second intermediate list according to the module list, and generating a third intermediate list according to the scheduling list includes:

[0041] Traversing the module list, generating an ar command script, executing the ar command script through a system call, and merging the target files of the modules in the module list to generate a library file;

[0042] Execute the nm command through system call for the library file to export the symbol table of the library file, wherein the symbol table includes the correspondence between function names and parameters;

[0043] For each module in the module list, if the function name of the module exists in the symbol table, and the function name corresponds to multiple parameters, the module is a polymorphic implementation function, and the module is added to the polymorphic implementation list, and the polymorphic implementation list includes symbol information of multiple functions corresponding to the module;

[0044] Traversing the module list, when a module in the module list does not belong to the polymorphic implementation list, determining symbol information corresponding to the module, when a module in the module list belongs to the polymorphic implementation list, determining symbol information of each function corresponding to the module, and generating a final first intermediate list according to the determined symbol information of the module;

[0045] Traversing the scheduling list, determining the main calling function included in the scheduling list, and generating a second intermediate list according to the determined main calling function;

[0046] The reference memory list is traversed to determine the shared memory included in the reference memory list, and a third intermediate list is generated according to the determined shared memory.

[0047] According to another aspect of the embodiment of the present disclosure, a C language compiling device based on the RINSIM simulation platform is provided, the device comprising:

[0048] A first adding module is used to generate variable information that complies with the compilation rules of the RINSIM simulation platform according to the variable when it is detected that the source program to be compiled includes a variable, and add the variable information to the variable database;

[0049] A second adding module is used to add function information of the function to the module database when detecting that the source program includes a function that complies with the compilation rule;

[0050] A third adding module is used to generate a fuzzy polymorphic function that complies with the compilation rule according to the detected multiple polymorphic sub-functions with the same name characteristics, replace one polymorphic sub-function among the multiple polymorphic sub-functions with the same name characteristics with the fuzzy polymorphic function, and add the function information of the module polymorphic function to the module database, and the fuzzy polymorphic function can realize all the functions of the multiple polymorphic sub-functions with the same name characteristics;

[0051] A first generating module is used for generating a header file for the source program according to the variable database and the module database during the process of compiling and preprocessing the source program, wherein the header file defines the actual position information of each variable in the source program that complies with the compilation rules, ignores the polymorphic sub-functions in the source program, and defines the format of the function that complies with the compilation rules;

[0052] The second generating module is used to compile the source program according to the header file to generate a target program.

[0053] According to another aspect of the embodiment of the present disclosure, a C language compiling device based on the RINSIM simulation platform is provided, the device comprising:

[0054] processor;

[0055] a memory for storing processor-executable instructions;

[0056] Wherein, the processor is configured to execute the above method.

[0057] According to another aspect of an embodiment of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor.

[0058] The beneficial effects of the present disclosure are as follows: by dynamically generating a variable database and a module database for a source program to be compiled, the RINSIM simulation platform can link the target code generated by a C language simulation program containing polymorphic functions into an executable program. This enhances the functionality and friendliness of the RINSIM platform. This effectively reduces the workload of developing simulation programs for general engineering projects, shortens the development cycle, reduces human errors, improves simulation accuracy, and reduces the complexity of subsequent program updates. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a flowchart of a C language compiling method based on the RINSIM simulation platform according to an exemplary embodiment.

[0060] Figure 2 It is a block diagram of a C language compiling device based on the RINSIM simulation platform according to an exemplary embodiment.

[0061] Figure 3 It is a block diagram of a C language compiling device based on the RINSIM simulation platform according to an exemplary embodiment. DETAILED DESCRIPTION

[0062] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0063] Figure 1 The flowchart of a C language compilation method based on the RINSIM simulation platform is shown according to an exemplary embodiment. The method can be executed by a terminal device, wherein the terminal device can be a computer, for example, a server, a desktop computer, a laptop computer, a tablet computer, etc. The terminal device can also be, for example, a user device, a vehicle-mounted device or a wearable device, etc. The embodiment of the present disclosure does not limit the type of the terminal device. Figure 1 As shown, the method may include:

[0064] Step 100, when it is detected that the source program to be compiled includes variables, variable information that complies with the compilation rules of the RINSIM simulation platform is generated according to the variables, and the variable information is added to the variable database.

[0065] For example, the variable information may include attribute information such as variable name, variable type, shared memory area, occupied space length, etc. that conform to the compilation rules of the RINSIM simulation platform. The variable database may include the corresponding relationship between each variable of the source program and the variable information.

[0066] Step 101: when it is detected that the source program includes a function that complies with the compilation rule, function information of the function is added to a module database.

[0067] Step 102, based on the detected multiple polymorphic sub-functions with the same name features, generate a fuzzy polymorphic function that complies with the compilation rules, replace one of the multiple polymorphic sub-functions with the same name features with the fuzzy polymorphic function, and add the function information of the module polymorphic function to the module database. The fuzzy polymorphic function can realize all the functions of the multiple polymorphic sub-functions with the same name features.

[0068] For example, you can obtain each polymorphic subfunction in the source program, determine the polymorphic subfunctions with the same name features, and place the C program source code of the polymorphic subfunctions with the same name features in the C program source code of one of the multiple polymorphic subfunctions with the same name features to form a fuzzy polymorphic function. The fuzzy polymorphic function can implement all the functions of the multiple polymorphic subfunctions with the same name features.

[0069] Step 103, during the process of compiling and preprocessing the source program, a header file is generated for the source program based on the variable database and the module database, wherein the header file defines the actual location information of each variable in the source program that complies with the compilation rules, ignores polymorphic sub-functions in the source program, and defines the format of the function that complies with the compilation rules.

[0070] As an example of this embodiment, step 103 may include:

[0071] Step 1031, when it is detected that the statements in the source program contain global variable areas and variables, a first type of identifier is marked before the statement; for example, the first type of identifier may be / *global……* / , because the part modified by / ** / in the C language is a comment part in the C syntax during preprocessing and will be ignored. Therefore, this type of identifier can effectively identify variables without affecting preprocessing.

[0072] Step 1032, scanning the source program line by line, if it is detected that a statement of the source program contains a first type of identifier, intercepting the variable name corresponding to the statement, and determining the variable information of the variable according to the variable database;

[0073] Step 1033, determining the actual position information of the variable according to the variable information of the variable;

[0074] For example, when the intercepted variable is an array variable, the actual position information of the variable can be determined based on the subscript and starting position of the variable; when the intercepted variable is a complex variable, the actual position information of the variable can be determined based on the field offset and parent node position information of the variable.

[0075] Step 1034, defining the actual position of each variable in the header file according to the actual position information of each variable.

[0076] As an example of this embodiment, step 1034 may include: generating a memory list and a first symbol linked list based on the actual location information of each variable, the memory list including the actual location information corresponding to each variable of the source program, and the first symbol linked list including the variable names of the source program; traversing the memory list, generating a definition modified with extern char for each referenced memory in the header file in C language format, and defining a static pointer variable to point to the referenced memory area; traversing the first symbol linked list, and when a global variable is detected, generating a C language macro definition modified with #define in the header file, and binding the global variable to the actual location information of the global variable.

[0077] As an example of this embodiment, step 103 may also include:

[0078] Step 1031, when it is detected that the statements in the source program include a main function, a second type identifier is marked before the statement, for example, the second type identifier may be / *program...* / ; when it is detected that the statements in the source program include a polymorphic function, a third type identifier / *module...* / is marked before the statement;

[0079] Step 1032, scan the source program line by line, and perform the following operations:

[0080] If it is detected that the statement of the source program contains the second type of identification, the main function name of the statement is intercepted, and when the intercepted main function name is included in the module database, the main function name is added to the second symbol chain list;

[0081] If it is detected that the statement of the source program contains the third type of identifier, the polymorphic sub-function name of the statement is intercepted, and when the intercepted polymorphic sub-function name is included in the module database, the polymorphic sub-function name is added to the second symbol chain list and the polymorphic list;

[0082] End the line-by-line scanning of the source program, generate a second symbol chain list and a polymorphic list, the second symbol chain list includes the names of each function of the source program, and the polymorphic list includes each polymorphic sub-function of the source program;

[0083] The second symbol chain is traversed, and when a sub-function is detected, it is determined whether the sub-function exists in the polymorphic list. If the sub-function exists in the polymorphic list, the sub-function is ignored by definition in the header file, so that the compiler can avoid the phenomenon that the polymorphic sub-function cannot be compiled and linked. If the sub-function does not exist in the polymorphic list, the sub-function name is modified in the macro definition of the header file to a format that complies with the compilation rules. In this way, it can be ensured that other sub-functions can be effectively compiled and linked.

[0084] Step 104, compile the source program according to the header file to generate a target program.

[0085] In a possible implementation, the method may further include:

[0086] Step 200, generates an executable program name, a reference memory list, a module list and a scheduling list according to the configuration file of the source program, wherein the module list includes information of the main calling function in the configuration file and information of the sub-calling function called by the main calling function, and the scheduling list includes the scheduling relationship between the main calling function in the configuration file and the sub-calling function called by the main calling function.

[0087] For example, when it is detected that the configuration file of the source program contains exec, the name of the executable program generated by the final link of the configuration file is identified;

[0088] When it is detected that the configuration file contains a share, a shared memory name corresponding to the share is identified, and the identified shared memory name is added to a reference memory list;

[0089] When it is detected that the configuration file contains load, a scheduling module corresponding to the load is identified, and if it is determined that the target program of the identified scheduling module already exists, the scheduling module is added to the module list and the scheduling list, and if it is determined that the scheduling module references a submodule, the submodule referenced by the scheduling module is also added to the module list and the scheduling list;

[0090] When it is detected that the configuration file contains exit, the configuration file is processed and the final reference memory list, module list and scheduling list are generated.

[0091] Step 201, generating a first intermediate list according to the reference memory list, generating a second intermediate list according to the module list, and generating a third intermediate list according to the scheduling list;

[0092] For example, the module list may be traversed to generate an ar command script, the ar command script may be executed through a system call, and the target files of the modules in the module list may be merged to generate a library file;

[0093] Execute the nm command through system call for the library file to export the symbol table of the library file, wherein the symbol table includes the correspondence between function names and parameters;

[0094] For each module in the module list, if the function name of the module exists in the symbol table, and the function name corresponds to multiple parameters, the module is a polymorphic implementation function, and the module is added to the polymorphic implementation list, and the polymorphic implementation list includes symbol information of multiple functions corresponding to the module;

[0095] Traversing the module list, when a module in the module list does not belong to the polymorphic implementation list, determining symbol information corresponding to the module, when a module in the module list belongs to the polymorphic implementation list, determining symbol information of each function corresponding to the module, and generating a final first intermediate list according to the determined symbol information of the module;

[0096] Traversing the scheduling list, determining the main calling function included in the scheduling list, and generating a second intermediate list according to the determined main calling function;

[0097] The reference memory list is traversed to determine the shared memory included in the reference memory list, and a third intermediate list is generated according to the determined shared memory.

[0098] Step 202, generating a C file according to the configuration file, the first intermediate list, the second intermediate list and the third intermediate list, the C file including a GLOBTAB array corresponding to the first intermediate list, a MODTAB array corresponding to the second intermediate list, and a CNTRTAB array corresponding to the third intermediate list.

[0099] Step 203, compile the C file to generate an executable file, and the executable file is periodically scheduled for execution by the RINSIM simulation platform, wherein, when the RINSIM simulation platform first schedules the execution of the executable file, it associates the real-time database according to the GLOBTAB array, then traverses the CNTRTAB array, and executes each main calling function contained in the CNTRTAB array. If it is detected that the main calling function contains one or more sub-calling functions, the symbol information of the one or more sub-calling functions is determined according to the sub-calling function and the MODTAB array, and the one or more sub-calling functions are called according to the determined symbol information of the one or more sub-calling functions.

[0100] Figure 2 FIG. 1 is a block diagram of a C language compiling device based on a RINSIM simulation platform according to an exemplary embodiment. Figure 2 As shown, the device may include:

[0101] A first adding module 20 is used to generate variable information that complies with the compilation rules of the RINSIM simulation platform according to the variable when it is detected that the source program to be compiled includes a variable, and add the variable information to the variable database;

[0102] A second adding module 21 is used for adding function information of the function to the module database when detecting that the source program includes a function that complies with the compilation rule;

[0103] A third adding module 22 is used to generate a fuzzy polymorphic function that complies with the compilation rule according to the detected multiple polymorphic sub-functions with the same name characteristics, replace one polymorphic sub-function among the multiple polymorphic sub-functions with the same name characteristics with the fuzzy polymorphic function, and add the function information of the module polymorphic function to the module database, and the fuzzy polymorphic function can realize all functions of the multiple polymorphic sub-functions with the same name characteristics;

[0104] A first generating module 23 is used for generating a header file for the source program according to the variable database and the module database during the process of compiling and preprocessing the source program, wherein the header file defines the actual position information of each variable in the source program that complies with the compilation rules, ignores the polymorphic sub-functions in the source program, and defines the format of the function that complies with the compilation rules;

[0105] The second generating module 24 is used to compile the source program according to the header file to generate a target program.

[0106] For the description of the C language compiling device based on the RINSIM simulation platform, please refer to the description of the C language compiling method based on the RINSIM simulation platform in the above text, which will not be repeated here.

[0107] Figure 3 1900 is a block diagram of a C language compiling device based on a RINSIM simulation platform according to an exemplary embodiment. For example, the device 1900 may be provided as a server. Figure 3 , the apparatus 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions, such as an application, that can be executed by the processing component 1922. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

[0108] The device 1900 may also include a power supply component 1926 configured to perform power management of the device 1900, a wired or wireless network interface 1950 configured to connect the device 1900 to a network, and an input / output (I / O) interface 1958. The device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or the like.

[0109] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the device 1900 to perform the above method.

[0110] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0111] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0112] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0113] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0114] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0115] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0116] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0117] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0118] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A C language compilation method based on the RINSIM simulation platform, characterized in that: The method comprises: When it is detected that the source program to be compiled includes a variable, variable information that complies with the compilation rules of the RINSIM simulation platform is generated according to the variable, and the variable information is added to the variable database; When detecting that the source program includes a function that complies with the compilation rule, adding function information of the function to a module database; According to the detected multiple polymorphic sub-functions with the same name features, a fuzzy polymorphic function that complies with the compilation rule is generated, one of the multiple polymorphic sub-functions with the same name features is replaced with the fuzzy polymorphic function, and function information of the fuzzy polymorphic function is added to the module database, and the fuzzy polymorphic function can realize all functions of the multiple polymorphic sub-functions with the same name features; In the process of compiling and preprocessing the source program, a header file is generated for the source program according to the variable database and the module database, wherein the header file defines the actual position information of each variable in the source program that complies with the compilation rules, ignores the polymorphic sub-functions in the source program, and defines the format of the function that complies with the compilation rules; Compiling the source program according to the header file to generate a target program; For the source program, a header file is generated according to the variable database and the module database, including: When it is detected that a statement in the source program contains a global variable area and a variable, a first type identifier is marked before the statement; Scanning the source program line by line, if it is detected that a statement of the source program contains a first type of identifier, intercepting a variable name corresponding to the statement, and determining variable information of the variable according to the variable database; Determine the actual position information of the variable according to the variable information of the variable; According to the actual location information of each variable, define the actual location of each variable in the header file; For the source program, generating a header file according to the variable database and the module database, further comprising: When it is detected that the statements in the source program include a main function, a second type of identifier is marked before the statement; when it is detected that the statements in the source program include a polymorphic function, a third type of identifier is marked before the statement; Scan the source program line by line and perform the following operations: If it is detected that the statement of the source program contains the second type of identification, the main function name of the statement is intercepted, and when the intercepted main function name is included in the module database, the main function name is added to the second symbol chain list; If it is detected that the statement of the source program contains the third type of identifier, the polymorphic sub-function name of the statement is intercepted, and when the intercepted polymorphic sub-function name is included in the module database, the polymorphic sub-function name is added to the second symbol chain list and the polymorphic list; End the line-by-line scanning of the source program, generate a second symbol chain list and a polymorphic list, the second symbol chain list includes each function of the source program, and the polymorphic list includes each polymorphic sub-function of the source program; The second symbol linked list is traversed, and when a sub-function is detected, it is determined whether the sub-function exists in the polymorphic list. If the sub-function exists in the polymorphic list, the sub-function is ignored by definition in the header file; if the sub-function does not exist in the polymorphic list, the sub-function name is modified in the macro definition of the header file to a format that complies with the compilation rules.

2. The method according to claim 1, characterized in that According to the variable information of the variable, the actual position information of the variable is determined, including: When the intercepted variable is an array variable, the actual position information of the variable is determined according to the subscript and starting position of the variable; When the intercepted variable is a complex variable, the actual position information of the variable is determined according to the field offset and parent node position information of the variable.

3. The method according to claim 1, characterized in that According to the actual location information of each variable, define the actual location of each variable in the header file, including: Generate a memory list and a first symbol chain list according to the actual location information of each variable, wherein the memory list includes the actual location information corresponding to each variable of the source program, and the first symbol chain list includes the name of each variable of the source program; Traversing the memory list, generating a definition of each referenced memory modified with extern char in the header file in C language format, and defining a static pointer variable to point to the referenced memory area; The first symbol linked list is traversed, and when a global variable is detected, a C language macro definition modified with #define is generated in the header file to bind the global variable to the actual location information of the global variable.

4. The method according to claim 1, characterized in that: The method further comprises: Generate an executable program name, a reference memory list, a module list and a scheduling list according to the configuration file of the source program, wherein the module list includes information of a main calling function in the configuration file and information of a sub-calling function called by the main calling function, and the scheduling list includes a scheduling relationship between the main calling function in the configuration file and the sub-calling function called by the main calling function; Generate a first intermediate list according to the reference memory list, generate a second intermediate list according to the module list, and generate a third intermediate list according to the scheduling list; Generate a C file according to the configuration file, the first intermediate list, the second intermediate list, and the third intermediate list, wherein the C file includes a GLOBTAB array corresponding to the first intermediate list, a MODTAB array corresponding to the second intermediate list, and a CNTRTAB array corresponding to the third intermediate list; The C file is compiled to generate an executable file, and the executable file is periodically scheduled for execution by the RINSIM simulation platform. When the RINSIM simulation platform first schedules the execution of the executable file, it associates the real-time database according to the GLOBTAB array, then traverses the CNTRTAB array, and executes each main calling function contained in the CNTRTAB array. If it is detected that the main calling function contains one or more sub-calling functions, the symbol information of the one or more sub-calling functions is determined according to the sub-calling function and the MODTAB array, and the one or more sub-calling functions are called according to the determined symbol information of the one or more sub-calling functions.

5. The method according to claim 4, characterized in that Generate an executable program name, a reference memory list, a module list and a scheduling list according to the configuration file of the source program, including: When it is detected that the configuration file of the source program contains exec, identifying the executable program name generated by the final link of the configuration file; When it is detected that the configuration file contains a share, a shared memory name corresponding to the share is identified, and the identified shared memory name is added to a reference memory list; When it is detected that the configuration file contains load, a scheduling module corresponding to the load is identified, and if it is determined that the target program of the identified scheduling module already exists, the scheduling module is added to the module list and the scheduling list, and if it is determined that the scheduling module references a submodule, the submodule referenced by the scheduling module is also added to the module list and the scheduling list; When it is detected that the configuration file contains exit, the configuration file is processed and the final reference memory list, module list and scheduling list are generated.

6. The method according to claim 4, characterized in that Generating a first intermediate list according to the reference memory list, generating a second intermediate list according to the module list, and generating a third intermediate list according to the scheduling list, including: Traversing the module list, generating an ar command script, executing the ar command script through a system call, and merging the target files of the modules in the module list to generate a library file; Executing the nm command through a system call for the library file to export a symbol table of the library file, wherein the symbol table includes a correspondence between a function name and a parameter; For each module in the module list, if the function name of the module exists in the symbol table, and the function name corresponds to multiple parameters, the module is a polymorphic implementation function, and the module is added to the polymorphic implementation list, and the polymorphic implementation list includes symbol information of multiple functions corresponding to the module; Traversing the module list, when a module in the module list does not belong to the polymorphic implementation list, determining symbol information corresponding to the module, when a module in the module list belongs to the polymorphic implementation list, determining symbol information of each function corresponding to the module, and generating a final first intermediate list according to the determined symbol information of the module; Traversing the scheduling list, determining the main calling function included in the scheduling list, and generating a second intermediate list according to the determined main calling function; The reference memory list is traversed to determine the shared memory included in the reference memory list, and a third intermediate list is generated according to the determined shared memory.

7. A C language compiling device based on the RINSIM simulation platform, characterized in that: The device comprises: A first adding module is used to generate variable information that complies with the compilation rules of the RINSIM simulation platform according to the variable when it is detected that the source program to be compiled includes a variable, and add the variable information to the variable database; A second adding module is used to add function information of the function to the module database when detecting that the source program includes a function that complies with the compilation rule; A third adding module is used to generate a fuzzy polymorphic function that complies with the compilation rule according to the detected multiple polymorphic sub-functions with the same name characteristics, replace one polymorphic sub-function among the multiple polymorphic sub-functions with the same name characteristics with the fuzzy polymorphic function, and add the function information of the fuzzy polymorphic function to the module database, and the fuzzy polymorphic function can realize all functions of the multiple polymorphic sub-functions with the same name characteristics; A first generating module is used for generating a header file for the source program according to the variable database and the module database during the process of compiling and preprocessing the source program, wherein the header file defines the actual position information of each variable in the source program that complies with the compilation rules, ignores the polymorphic sub-functions in the source program, and defines the format of the function that complies with the compilation rules; A second generating module, used for compiling the source program according to the header file to generate a target program; The first generation module also includes: A marking submodule, for marking a second type of identification before a section of the statement when it is detected that the statement in the source program contains a main function, and marking a third type of identification before the section of the statement when it is detected that the statement in the source program contains a polymorphic function; The scanning submodule is used to scan the source program line by line and perform the following operations: If it is detected that the statement of the source program contains the second type of identification, the main function name of the statement is intercepted, and when the intercepted main function name is included in the module database, the main function name is added to the second symbol chain list; If it is detected that the statement of the source program contains the third type of identifier, the polymorphic sub-function name of the statement is intercepted, and when the intercepted polymorphic sub-function name is included in the module database, the polymorphic sub-function name is added to the second symbol chain list and the polymorphic list; A generating submodule, used to end the line-by-line scanning of the source program, generate a second symbol chain list and a polymorphic list, wherein the second symbol chain list includes each function of the source program, and the polymorphic list includes each polymorphic sub-function of the source program; A traversal submodule is used to traverse the second symbol linked list. When a subfunction is detected, it is determined whether the subfunction exists in the polymorphic list. If the subfunction exists in the polymorphic list, the subfunction is ignored by definition in the header file. If the subfunction does not exist in the polymorphic list, the subfunction name is modified in the macro definition of the header file to a format that complies with the compilation rules.

8. A C language compiling device based on the RINSIM simulation platform, characterized in that: The device comprises: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 6.

9. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Programming language conversion method and system

    CN112328258A

  • Method of executing, by a microprocessor, a polymorphic binary code of a predetermined function

    US20150095659A1