Multi-language system generation method and system initialization method
By generating and compiling second language source files, the problems of low execution efficiency and large number of files of existing multilingual systems are solved, and efficient multilingual systems are generated and maintained.
Patent Information
- Application Number
- CN202311832739.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2025-06-27
AI Technical Summary
The existing multilingual system is inefficient in execution during generation, and the number of files required for normal operation of the system is not conducive to daily maintenance.
Generate a second language source file based on encoding scripts and compile it with a second language program through a compiler to generate a multilingual system. The method includes initializing the first language interpreter environment and loading the encoded data of the first language source file after success.
It improves the execution efficiency of multilingual systems, reduces the number of files required for normal operation of the system, and has the advantages of facilitating daily maintenance.
Smart Images

Figure CN120215895A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a method for generating a multilingual system and a method for system initialization. Background Art
[0002] With the continuous development of software technology, more and more programming languages have been developed. These programming languages have different advantages and disadvantages. Some programming languages have simple and easy-to-use syntax and efficient code writing, but at the same time, for the sake of security and ease of use, the language sacrifices some performance. Some programming languages have low development efficiency when used and require higher programming experience from programmers, but these programming languages support very fine control of system resources and have high performance. Therefore, as software design becomes more and more complex, to balance development efficiency and program performance, a software development project usually uses a mixture of multiple programming languages for development, and these programming languages are usually selected due to their applicability or other factors.
[0003] In existing multilingual systems developed using multiple programming languages, encryption / decryption or dynamic link libraries are usually adopted to improve the security of the system. Therefore, the execution efficiency of the existing methods for generating multilingual systems is not high, and the number of files required to ensure the normal operation of the system is large, which is not conducive to daily maintenance.
[0004] The foregoing description is to provide general background information and does not necessarily constitute prior art. Summary of the Invention
[0005] To alleviate the above problems, this application provides a method for generating a multilingual system, a method for system initialization, a static timing analysis method, a computer device, and a storage medium, which can improve the execution efficiency and are conducive to daily maintenance.
[0006] In one aspect, this application provides a method for generating a multilingual system. The method for generating a multilingual system includes: generating a second language source file based on an encoding script according to a first language program; compiling the second language source file and a second language program through a compiler to generate a multilingual system.
[0007] In one embodiment, the first language program is generated by performing secondary encapsulation on the basic function interfaces exported by the second language program.
[0008] In one embodiment, the first language program is a scripting language program, and the second language program is a native language program.
[0009] In one embodiment, the step of generating a second - language source file based on an encoding script according to a first - language program includes: sequentially reading multiple first - language source files written in the first language in the first - language program through the encoding script, and encoding the multiple first - language source files in sequence according to the reading order to obtain encoded data; and writing the encoded data into the second - language source file.
[0010] In one embodiment, the second - language source file includes a namespace, a string array is defined in the namespace, and one string in the string array represents the encoded data of one of the first - language source files.
[0011] The present application also provides a system initialization method, including: initializing a first - language interpreter environment; after successfully initializing the first - language interpreter environment, loading the encoded data of the first - language source files in the above - mentioned multi - language system.
[0012] The present application also provides a static timing analysis method, and the static timing analysis method performs static timing analysis through the above - mentioned multi - language system.
[0013] In one embodiment, when the multi - language system receives a first - language design constraint command or a first - language design constraint command file, after executing the first - language design constraint command through the multi - language system, an execution result is output.
[0014] The present application also provides a computer device, including a memory and a processor, and when the processor executes a computer program stored in the memory, the above - mentioned methods can be implemented.
[0015] The present application also provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above - mentioned methods are implemented.
[0016] As described above, the multi - language system generation method, system initialization method, static timing analysis method, computer device, and storage medium of the present application encode a first - language program through an encoding script to generate a second - language source file, and the second - language source file participates in the compilation process of the second - language program to generate a multi - language system. Therefore, the multi - language system generated by the present application has high execution efficiency, and the number of files required to ensure the normal operation of the system is small, which is beneficial to daily maintenance. Brief Description of the Drawings
[0017] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. To more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0018] Figure 1 It is a schematic flowchart of the method for generating a multilingual system according to the first embodiment of the present application.
[0019] Figure 2 It is a schematic structural diagram of a computer device according to the second embodiment of the present application.
[0020] The realization of the purpose of the present application, functional features and advantages will be further described in combination with the embodiments with reference to the accompanying drawings. Through the above-mentioned accompanying drawings, the clear embodiments of the present application have been shown, and there will be more detailed descriptions later. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed implementation manners
[0021] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0022] It should be noted that in this article, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. Without further limitations, the element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including that element. In addition, components, features, and elements with the same name in different embodiments of the present application may have the same meaning or different meanings, and their specific meanings need to be determined by their explanations in the specific embodiments or further in combination with the context in the specific embodiments.
[0023] It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.
[0024] The first embodiment
[0025] Figure 1 is a schematic flowchart of a method for generating a multilingual system according to the first embodiment of the present application. As Figure 1 shown, the method for generating a multilingual system includes:
[0026] Step S10: Generate a second-language source file based on an encoding script according to a first-language program;
[0027] Step S20: Compile the second-language source file and a second-language program through a compiler to generate a multilingual system.
[0028] Among them, the first-language program is a program written in the first language. The second-language program is a program written in the second language. In one embodiment, the first language and the second language are different programming languages. Specifically, in one embodiment, the first-language program is a scripting language program, and the second-language program is a native language program, but the present application is not limited thereto.
[0029] Among them, the scripting language program is a program written in a scripting language. The scripting language is also called an extended language or a dynamic language. It is a programming language used to control software applications. Scripts are usually saved in text (such as ASCII) and are only interpreted or compiled when called. The native language program is developed specifically for a certain type of device and runs only on the specified target device. Specifically, for example, the first-language program can be a scripting language program such as Python, TCL, Lua, etc., and the second-language program can be a native language program such as C, C++, C#.
[0030] In one embodiment, the second-language program can export a basic function interface for the first-language program to call. The first-language program is generated by secondary encapsulation on the basis of the basic function interface exported by the second-language program. Specifically, in one embodiment, taking the first-language program as a Python program and the second-language program as a C++ program as an example, the C++ program can use Pybind11 to export the basic function interface for the Python program to call. In other embodiments, the SWIG (Simplified Wrapper and Interface Generator) tool can be used to automatically encapsulate the C++ program to generate a Python interface for the Python program to call.
[0031] In one embodiment, step S10 of generating a second-language source file based on a first-language program according to an encoding script includes: sequentially reading, through the encoding script, a plurality of first-language source files written in the first language in the first-language program, and sequentially encoding the plurality of first-language source files according to the reading order to obtain encoded data; and writing the encoded data into the second-language source file.
[0032] Among them, the multilingual system includes the data obtained by encoding the first-language source file.
[0033] In one embodiment, the second-language source file includes a namespace, and a string array is defined in the namespace. One string in the string array represents the data obtained by encoding one first-language source file.
[0034] Taking the first language as Python and the second language as C++ as an example, the C++ source file (i.e., the second-language source file) contains a namespace, and a python_inits string array is defined therein. One element in the python_inits string array, that is, one string represents the data obtained by encoding one Python file (i.e., one first-language source file).
[0035] The method for generating a multilingual system of the present application encodes a first-language program through an encoding script to generate a second-language source file, and involves the second-language source file in the compilation process of the second-language program to generate a multilingual system. Therefore, the multilingual system generated by the present application can ensure the security of the system while improving the execution efficiency, and can ensure that the number of files required for the normal operation of the system is small, which is conducive to daily maintenance.
[0036] After generating the multilingual system, when the multilingual system runs, it is necessary to initialize the multilingual system first. The present application also provides a system initialization method, including: initializing the first-language interpreter environment; after successfully initializing the first-language interpreter environment, loading the data obtained by encoding the first-language source file into the above-mentioned multilingual system.
[0037] Among them, loading means that after the multilingual system successfully initializes the first-language interpreter environment, the multilingual system decodes the data obtained by encoding the first-language source file and allows the first-language interpreter to execute the decoded data.
[0038] Among them, the interpreter environment refers to the runtime environment required by the interpreter when interpreting and executing script code. Specifically, in one embodiment, taking the first language as Python and the second language as C++ as an example, the multi-language system generation method includes: initializing the Python interpreter environment; determining whether the initialization of the Python interpreter environment is successful; if the initialization of the Python interpreter environment fails, then end; if the initialization of the Python interpreter environment is successful, then determine whether it is successful to load the data encoded from the first language source file in the multi-language system; if it fails to load the data encoded from the first language source file in the multi-language system, then end; if it is successful to load the data encoded from the first language source file in the multi-language system, then the system initialization is successful, and wait for the user to input a command or a command file.
[0039] Specifically, taking the first language as Python as an example, the interactive multi-language system can receive a Python command input by the user, and after executing the Python command through the Python interpreter, output the execution result to the user in real time. The interactive multi-language system can also receive a Python command file input by the user, and after executing the Python command file through the Python interpreter, output the execution result to the user in real time. Specifically, in one embodiment, the file name of the Python command file ends with ".py" as the file extension. Python commands are written in the Python command file.
[0040] This application also provides a static timing analysis method, and the static timing analysis method includes: generating a multi-language system through the above multi-language system generation method, that is, a static timing analysis tool (Static Timing Analysis, STA); performing static timing analysis through the multi-language system.
[0041] Among them, timing is an important indicator characterizing the function and performance of digital chips, and there are a large number of timing paths in digital circuit design. In order to ensure the correct function of the chip and achieve the expected performance, it is necessary to analyze the timing paths in the circuit. Static timing analysis is a timing verification to ensure that various circuit timings meet various timing requirements.
[0042] The static timing analysis tool first needs to have the ability to process ultra-large-scale data and good human-computer interaction ability. Since Python has a powerful interactive command-line framework and the C++ language supports object-oriented programming mechanisms and has advantages such as high program execution efficiency, in one embodiment, the static timing analysis tool can be implemented by, but not limited to, hybrid programming of Python and C++. There is a design constraint command in the static timing analysis tool, such as a function command for interrupting timing arcs. Taking the implementation of the function command for interrupting timing arcs as an example, the specific implementation process of this solution will be described below.
[0043] In one embodiment, a command with the function of interrupting timing arcs can be used to set timing exceptions and define that the static timing analysis tool ignores certain specific paths (also known as paths). The command with the function of interrupting timing arcs is used to set timing arcs (also known as timing arcs), indicating that this timing arc is interrupted and the delay of this timing arc is not calculated, and all paths passing through this timing arc will be interrupted.
[0044] Among them, when used, it usually interrupts all timing arcs inside a device (also known as a cell), or interrupts the timing arcs from one pin (also known as a pin) of a device to another pin, or interrupts the timing arcs passing through a certain pin. Therefore, in one embodiment, according to the user's usage requirements and based on the design idea of object-oriented programming, the C++ language can be selected to implement the design of the class with the function of the command for interrupting timing arcs.
[0045] In one embodiment, the top-level class of the static timing tool can be the STA class, and the data in the top-level class STA includes an object for interrupting timing.
[0046] In one embodiment, Python can be selected as the interactive language of the static timing analysis tool, and the basic function interfaces of the C++ program are exported for the Python program to call. Specifically, Pybind11 can be used to encapsulate and export the basic function interfaces of the C++ program for the Python program to call.
[0047] In one embodiment, the functions of encapsulating and exporting the basic function interfaces of the C++ program through Pybind11 include the functions of interrupting device interfaces, interrupting pin interfaces, and interrupting timing arc interfaces. Therefore, the Python program of the function interface that meets the user's requirements can be obtained by secondary encapsulation of the basic function interfaces of the C++ program exported by Pybind11.
[0048] In one embodiment, a file encoding script can be used to encode a Python program of a functional interface that meets user requirements and generate a C++ source file. Among them, a string array named python_inits is defined in the C++ source file, and the string array python_inits stores the data after encoding the Python program generated by secondary encapsulation on top of the basic functional interfaces exported by the C / C++ program.
[0049] In one embodiment, after the C++ source file and the C++ program are compiled by a compiler to generate a multi-language system, the multi-language system actively loads the data after encoding the Python program, such as the Python program of the functional interface that meets user requirements, during the initialization phase of operation. In this way, when receiving a command written in the Python language, such as a functional command or a command file with an interrupt timing arc, corresponding operations can be executed to output the execution result.
[0050] In one embodiment, when a static timing analysis tool receives a first-language design constraint command, such as a functional command with an interrupt timing arc or a first-language design constraint command file, after executing the first-language design constraint command through the multi-language system, the execution result is output.
[0051] The static timing analysis method of this application hides the implementation details of the command by means of secondary encapsulation and file encoding participating in compilation, ensuring the security of the software system, and can ensure that the number of files required for the normal operation of the system is small, which is beneficial to daily maintenance.
[0052] Second Embodiment
[0053] On the other hand, this application also provides a computer device, which includes a storage medium and a processor. The processor 210 and the memory 211 storing a computer program; among them, Figure 2 The processor 210 shown does not refer to the number of processors 210 being one, but only refers to the positional relationship of the processor 210 relative to other devices. In actual applications, the number of processors 210 can be one or more; similarly, Figure 2 The memory 211 shown has the same meaning, that is, it only refers to the positional relationship of the memory 211 relative to other devices. In actual applications, the number of memories 211 can be one or more. When the processor 210 runs the computer program, the above method is implemented.
[0054] Each component in the device is coupled together through a bus system 212. It can be understood that the bus system 212 is used to realize the connection and communication between these components. The bus system 212 includes not only a data bus, but also a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, inFigure 2 Label various buses as bus system 212.
[0055] Among them, the memory 211 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM, Read Only Memory), a programmable read-only memory (PROM, Programmable Read-Only Memory), an erasable programmable read-only memory (EPROM, Erasable Programmable Read-Only Memory), an electrically erasable programmable read-only memory (EEPROM, Electrically Erasable Programmable Read-Only Memory), a ferromagnetic random access memory (FRAM, ferromagnetic random access memory), a flash memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM, Compact Disc Read-Only Memory); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM, Random Access Memory), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM, Static Random Access Memory), synchronous static random access memory (SSRAM, Synchronous Static Random Access Memory), dynamic random access memory (DRAM, Dynamic Random Access Memory), synchronous dynamic random access memory (SDRAM, Synchronous Dynamic Random Access Memory), double data rate synchronous dynamic random access memory (DDR SDRAM, Double Data Rate Synchronous Dynamic Random Access Memory), enhanced synchronous dynamic random access memory (ESDRAM, Enhanced Synchronous Dynamic Random Access Memory), sync link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), direct rambus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 211 described in the embodiments of the present invention is intended to include but not limited to these and any other suitable types of memories.
[0056] The memory 211 in the embodiments of the present invention is used to store various types of data to support the operation of the device. Examples of such data include: any computer programs for operating on the device, such as operating systems and application programs; contact data; phone book data; messages; pictures; videos, etc. Among them, the operating system contains various system programs, such as the framework layer, the core library layer, the driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application programs can include various application programs, such as a Media Player, a Browser, etc., for implementing various application services. Here, the program for implementing the method of the embodiments of the present invention can be included in the application programs.
[0057] It should be noted that in this application, step codes such as S10, S20, etc. are adopted. The purpose is to more clearly and briefly express the corresponding content and do not constitute a substantial limitation in terms of sequence. Those skilled in the art may execute S20 first and then S10, etc. during specific implementation, but these should all be within the protection scope of this application.
[0058] In the embodiments of the storage medium provided in this application, it may include all the technical features of any of the above method embodiments. The expanded and explanatory content of the specification is basically the same as that of the respective embodiments of the above method, and will not be elaborated here.
[0059] This application also provides a storage medium. Specifically, a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the multi-language system generation method described above are implemented.
[0060] The embodiments of this application also provide a computer program product. The computer program product includes computer program code, and when the computer program code runs on a computer, it causes the computer to execute the methods in various possible implementation manners described above.
[0061] The embodiments of this application also provide a chip, including a memory and a processor. The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the device equipped with the chip executes the methods in various possible implementation manners described above.
[0062] It can be understood that the above scenarios are only examples and do not constitute a limitation on the application scenarios of the technical solutions provided in the embodiments of this application. The technical solutions of this application can also be applied to other scenarios. For example, as known to those of ordinary skill in the art, with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0063] The serial numbers of the embodiments of the present application are only for description and do not represent the superiority or inferiority of the embodiments.
[0064] The steps in the method of the embodiments of the present application can be adjusted, combined and deleted according to actual needs.
[0065] The units in the devices of the embodiments of the present application can be combined, divided and deleted according to actual needs.
[0066] In the present application, for the description of the same or similar term concepts, technical solutions and / or application scenarios, generally only the first occurrence is described in detail. When they appear repeatedly later, for the sake of brevity, they are generally not described again. When understanding the technical solutions and other contents of the present application, for the same or similar term concepts, technical solutions and / or application scenarios that are not described in detail later, reference can be made to their relevant detailed descriptions before.
[0067] In the present application, the descriptions of the various embodiments have their own emphases. For the parts not described or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0068] The technical features of the technical solutions of the present application can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in the present application.
[0069] The above are only the preferred embodiments of the present application, and do not limit the patent scope of the present application accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be included in the patent protection scope of the present application by the same token.
Claims
1. A method for generating a multilingual system, characterized in that, The multi - language system generation method includes: Generating a second - language source file based on an encoding script according to a first - language program; Compiling the second - language source file and a second - language program through a compiler to generate a multi - language system.
2. The multi-language system generation method according to claim 1, wherein The first - language program is generated by performing secondary encapsulation on the basic function interfaces exported by the second - language program.
3. The multi-language system generation method according to claim 1, characterized in that, The first - language program is a script - language program, and the second - language program is a native - language program.
4. The multi-language system generation method according to claim 1, wherein The step of generating a second - language source file based on an encoding script according to a first - language program includes: Sequentially reading multiple first - language source files written in the first language in the first - language program through the encoding script, and encoding the multiple first - language source files in sequence according to the reading order to obtain encoded data; Writing the encoded data into the second - language source file.
5. The method for generating a multilingual system according to claim 4, wherein The second - language source file includes a namespace, and a string array is defined in the namespace. One string in the string array represents the encoded data of one of the first - language source files.
6. A system initialization method, characterized in that, The system initialization method includes: Initializing a first - language interpreter environment; After successfully initializing the first - language interpreter environment, loading the encoded data of the first - language source files in the multi - language system according to any one of claims 1 to 5.
7. A static timing analysis method, characterized in that, The static timing analysis method performs static timing analysis through the multi - language system according to claims 1 to 5.
8. The static timing analysis method according to claim 7, wherein, When the multi - language system receives a first - language design constraint command or a first - language design constraint command file, after executing the first - language design constraint command through the multi - language system, an execution result is output.
9. A computer device, characterized in that, It includes a memory and a processor. When the processor executes the computer program stored in the memory, it can implement the method according to any one of claims 1 - 8.
10. A storage medium, characterized in that, A computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the method according to any one of claims 1 - 8 are implemented.