A method, device and equipment for executing a parameter-expandable program organization unit

By implementing the execution method of parameter scalable program organization units in the compiler, the POU function block cannot be expanded in existing technologies, and achieves simpler user programming and more efficient compiler execution efficiency.

CN114356337BActive Publication Date: 2025-01-28KYLAND TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111564175.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2025-01-28
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

In the software of existing industrial automation control systems, functions or functional blocks in program organization units (POUs) are usually unable to perform parameter expansion, resulting in increased user programming complexity and reduced compiler execution efficiency.

Method used

By implementing the execution method of the parameter expansion program organization unit in the compiler, including compiling a statement of the parameter scalability program organization unit to get the first target file, analyze the compile language to obtain the second target file, and link the two to link the two To obtain the execution file, the execution of the execution parameter can expand the program organization unit.

Benefits of technology

The scalable characteristics of the program organization unit are realized, the complexity of user programming is reduced and the execution efficiency of the compiler is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114356337B_ABST
    Figure CN114356337B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an execution method, device and equipment of a parameter extensible program organization unit. The method includes: compiling and declaring the parameter extensible program organization unit to obtain a first target file, wherein the first target file contains the formal parameters of the extensible program organization unit; when parsing the compiled language to be executed to determine that the parameter extensible program organization unit needs to be called, obtaining a second target file according to the compiled language to be executed, wherein the second target file contains actual parameters matching the formal parameters; linking the first target file and the second target file to obtain an execution file, and executing the parameter extensible program organization unit based on the execution file. By compiling and declaring the parameter extensible program organization unit in advance, and calling the parameter extensible program organization unit when executing the compiled language, the compiler realizes the extensible characteristics of the program organization unit, thereby simplifying the compilation complexity of the compiler and improving the compilation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of compiler technology, and in particular to an execution method, device and equipment of a parameter extensible unit. Background Art

[0002] IEC61131-3 is the first international standard that provides standardized programming languages ​​for software design of industrial automation control systems, and defines five programming languages. Programming Organisation Unit (POU) is a common model of the five languages ​​defined in the standard, and is a general term for programs, functions and function blocks. When users use any of the five languages ​​to program, they are all carried out and developed for POU.

[0003] However, currently the functions or function blocks in the POU usually cannot be expanded in parameters. The programmable logic controller (PLC) in the domestic market does not yet support PLC programming software that supports functions or function blocks with expandable parameters. This will significantly increase the complexity of user programming and reduce the execution efficiency of the compiler. Summary of the invention

[0004] The present invention provides an execution method, apparatus and device for a parameter-expandable program organization unit to realize the extensible characteristics of the program organization unit, reduce programming complexity and improve compilation efficiency.

[0005] In a first aspect, an embodiment of the present invention provides a method for executing a parameter-expandable program organization unit, comprising:

[0006] Compile and declare the parameter extensible program organization unit to obtain a first target file, wherein the first target file contains the formal parameters of the extensible program organization unit;

[0007] When the compiled language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, a second target file is obtained according to the compiled language to be executed, wherein the second target file contains actual parameters that match the formal parameters;

[0008] The first target file and the second target file are linked to obtain an execution file, and the program organization unit can be expanded based on execution parameters of the execution file.

[0009] In a second aspect, an embodiment of the present invention provides an execution device of a parameter-scalable program organization unit, including:

[0010] A first target file acquisition module, used for compiling and declaring the parameter extensible program organization unit to acquire a first target file, wherein the first target file contains the formal parameters of the extensible program organization unit;

[0011] A second target file acquisition module is used to parse the compiled language to be executed to determine that the parameter extensible program organization unit needs to be called, and then acquire a second target file according to the compiled language to be executed, wherein the second target file contains actual parameters that match the formal parameters;

[0012] The execution file acquisition module is used to link the first target file and the second target file to acquire the execution file, and can expand the program organization unit based on the execution parameters of the execution file.

[0013] In a third aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:

[0014] one or more processors;

[0015] a storage device for storing one or more programs,

[0016] When one or more programs are executed by one or more processors, the one or more processors implement the method described above.

[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program implements the method described above when executed by a processor.

[0018] The technical solution of the embodiment of the present invention is to compile and declare the parameter-extensible program organization unit in advance, and call the parameter-extensible program organization unit when executing the compiled language, so that the compiler can realize the extensible characteristics of the program organization unit, thereby reducing programming complexity and improving compilation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0020] Figure 1A is a flow chart of an execution method of a parameter-expandable program organization unit provided in Embodiment 1 of the present invention;

[0021] Figure 1B This is an application example diagram of the parameter extensible program organization unit provided in the first embodiment of the present invention;

[0022] Figure 2 is a flow chart of an execution method of a parameter-expandable program organization unit provided in Embodiment 2 of the present invention;

[0023] Figure 3 It is a schematic diagram of the structure of an execution device of a parameter-expandable program organization unit provided in Embodiment 3 of the present invention;

[0024] Figure 4 It is a structural schematic diagram of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0026] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the operations (or steps) as sequential processes, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to methods, software implementations, hardware implementations, etc.

[0027] Embodiment 1

[0028] Figure 1A This is a flow chart of the execution method of the parameter extensible program organization unit provided by the embodiment of the present invention. This embodiment is applicable to the case where the compiler implements the extensible characteristics of the program organization unit based on the IEC61131-3 programming language. The method can be executed by the execution device of the parameter extensible tenant organization unit in the embodiment of the present invention, and the device can be implemented in software and / or hardware. Figure 1A As shown, the method specifically includes the following operations:

[0029] Step S101, compile and declare the parameter extensible program organization unit to obtain a first target file.

[0030] Among them, the first target file includes the formal parameters of the expandable program organization unit, and the program organization unit may include functions or function blocks. Therefore, the parameter-expandable program organization unit in this embodiment may specifically include: parameter-expandable functions or parameter-expandable function blocks. For example, the parameter-expandable functions may include: ADD-addition function module, MUL-multiplication function module, AND-logic AND function module, OR-logic OR function module, XOR-logic exclusive OR function module, MAX-logic maximum function module, MIN-logic minimum function module.

[0031] Specifically, in this implementation, the compiler mainly compiles based on the programming language of IEC61131-3, and there are five programming languages ​​in the IEC61131-3 programming language standard: Sequential Function Chart (SFC), Ladder Diagram (LD), Function Block Diagram (FBD), Instruction List (IL) and Structured Text (ST). In this implementation, the specific form of the compiler programming language is not limited. As long as the five languages ​​​​defined by the IEC61131-3 standard are within the scope of protection of this application.

[0032] It should be noted that, in this implementation mode, before the compiler performs compilation, it will perform compilation preparation work, including designing and defining the structure of the parameter extensible organization unit. A four-byte integer will be reserved at the beginning of the compiler to be used as the formal parameter variable RepCount of the number of valid variable parameters described above, that is, for the FBD language, it indicates how many variable parameters the user actually connected when compiling, and for the ST language, it indicates how many variable parameters the user actually used when compiling, and the compiler uses RepCount as an ordinary member variable.

[0033] For example, for the ADD-addition function module, the structure of the addition function module without parameter extension function is defined as:

[0034] In this embodiment, the structure of the addition function module with parameter extension function is defined as:

[0035]

[0036]

[0037] It can be seen from the above compiled language that the original addition function module without parameter extension function can only realize the addition and summation of two variable parameters, while the addition function module with parameter extension function in this embodiment can realize the addition and summation of multiple variable parameters, as long as the number of variable parameters does not exceed the set maximum threshold value of 64. Of course, in this embodiment, only the definition of the parameter extension function of the addition function module is used as an example for explanation, and the definition method of parameter extension of other function modules is roughly the same, and will not be repeated in this embodiment.

[0038] Optionally, compiling a parameter-extensible program organization unit to declare and obtain a first target file may include: performing syntax detection on a current compiled language through a compiler to obtain the parameter-extensible program organization unit; determining a formal parameter part and a code part of the organization unit itself in the parameter-extensible organization unit, wherein the formal parameter part includes fixed input parameters, extensible input parameters, and output parameters; generating a first abstract syntax tree according to the formal parameter part and the code part of the organization unit itself, and obtaining a first target file based on the first abstract syntax tree.

[0039] Among them, when the compiler performs syntax detection on the current compiled language, it obtains the parameter extensible program organization unit and determines the parameter part and the code part of the organization unit itself in the parameter extensible organization unit. When determining the parameter part in the parameter extensible organization unit, the structure is automatically generated to include: the parameter variable of the number of valid variable parameters is represented by _RepCount, EN is enabled, EN0 is not enabled, input parameters including fixed input parameters and extensible input parameters, and output parameters, and both input parameters and output parameters belong to formal parameters. Then, a first abstract syntax tree is generated according to the parameter part and the code part of the organization unit itself, and the syntax relationship and parameter variable relationship of the current compiled language are included in the first abstract syntax tree, and the first target file recognizable by the machine is compiled through the back end based on the first abstract syntax tree, so the formal parameters of the extensible program organization unit are included in the first target file.

[0040] Optionally, the extensible input parameters include basic data types or generic data types. In the preparation work, for generic data types, compiler developers or secondary developers using C language, such as secondary developers using LibDeveloper+C language, can use C language to implement each data type corresponding to the generic data, and then in the subsequent compilation process, the specific type is distinguished and called according to the context of the compiled language to be executed. For example, when the compiler developer of the addition function module with parameter extension function implements ADD(ANY, ANY, ...), where ANY represents the parameter of the generic data type, it is usually necessary to implement ADD_INT64(INT, INT...) in C language in advance, 64 means that the maximum number of extensible parameters supports 64, ADD_REAL64(REAL, REAL, ...), ADD_UDINT64(UDINT, UDINT, ...), etc. ADD containing multiple data types, is selectively called in the compilation process.

[0041] Step S102 , when the compiled language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, a second target file is obtained according to the compiled language to be executed.

[0042] The second target file contains actual parameters that match the formal parameters.

[0043] Optionally, when the compiled language to be executed is parsed to determine that a parameter-extensible program organization unit needs to be called, before obtaining the second target file according to the compiled language to be executed, it also includes: obtaining a program organization unit description file, the program organization unit description file includes a program organization unit name and an attribute identifier, and the attribute identifier includes whether it is extensible or not extensible.

[0044] It should be noted that, in this embodiment, before obtaining the second target file according to the compiled language to be executed, the preparatory work performed also includes: recording and saving the redefined parameter-extensible program organization unit, obtaining a description file of the program organization unit, and the program organization unit description file includes the program organization unit name and attribute identifier, and the attribute identifier is used to mark which organization units are parameter-extensible and which are not extensible, and the format of the description file can specifically be Json format. The specific format type of the description file is not limited in this embodiment.

[0045] Among them, there are three source scenarios for the attribute identification of the extensible program organization unit: the first scenario: the standard extensible program organization unit embedded in the development environment; the second scenario: the extensible program organization unit newly created based on user instructions; the third scenario: the extensible program organization unit newly created based on the specified development tool. And for the first and third scenarios, only the static description file is used to record whether the attribute is extensible, but for the second scenario, the extensible attribute needs to be recorded in the user programming project file to record the extensible program organization unit newly created by the user, so that the user can view it when using it.

[0046] Optionally, when the compiled language to be executed is parsed to determine that a parameter-extensible program organization unit needs to be called, a second target file is obtained according to the compiled language to be executed, including: when the compiled language to be executed is parsed to determine that a parameter-extensible program organization unit needs to be called, a second file is obtained according to the compiled language to be executed based on the program organization unit description file.

[0047] Optionally, obtaining a second file based on the compiled language to be executed based on the program organization unit description file includes: performing syntax parsing or graphical parsing on the compiled language to be executed to obtain the name of the program organization unit, the actual parameters contained therein, and the compiled language code to be executed; querying from the program organization unit description file according to the name of the program organization unit to obtain the query result; determining according to the query result that the attribute of the program organization unit is identified as extensible, and the number of actual parameters does not exceed a preset threshold, then generating a second abstract syntax tree according to the actual parameters and the compiled language code to be executed, and obtaining a second target file based on the second abstract syntax tree.

[0048] Specifically, when it is determined that the compiled language to be executed adopts the ST language, the compiled language to be executed will be parsed by syntax analysis. When it is determined that the compiled language to be executed adopts the FBD or LD language, the compiled language to be executed will be parsed by graphic analysis, and the name of the program organization unit, the actual parameters contained therein, and the code of the compiled language to be executed itself are obtained according to the parsing results. Since the description file of the program organization unit has been obtained in the compilation preparation process, and the name of each program organization unit and the attribute identifier of whether it is extensible are saved in the file, the description file is queried according to the name of the obtained program organization unit. If it is determined that the attribute identifier of the program organization unit is extensible, and it is determined that the number of actual parameters does not exceed the preset threshold, a second abstract syntax tree is generated according to the obtained actual parameters and the code of the compiled language to be executed itself, and the syntax relationship and parameter variable relationship of the compiled language to be executed are included in the second abstract syntax tree, and based on the second abstract syntax tree, it is compiled into a second machine-recognizable target file through the back end, so the actual parameters matching the formal parameters are included in the second target file.

[0049] It should be noted that, in this implementation, for the parameter-extensible program organization unit that supports generic data types, the ST compiler also needs to infer the data type actually corresponding to the generic data when parsing the compiled language to be executed, and call the specific implementation method determined for each data type in the preparation process according to the determined data type.

[0050] Step S103: linking the first target file and the second target file to obtain an execution file, and expanding the program organization unit based on execution parameters of the execution file.

[0051] Specifically, in this embodiment, after obtaining the first target file and the second target file, the formal parameters of the first target file can be assigned according to the actual parameters of the second target file to obtain an execution file, and the program organization unit can be extended based on the obtained execution file execution parameters.

[0052] For example, Figure 1B The figure shows an application example of the parameter-expandable program organization unit, specifically taking the ADD function of the FBD language as an example. The X parameter is a fixed input parameter, IN1 to IN10 are expandable input parameters, and the position of the expandable input parameter must be at the end of the input parameter list. It can be seen from the example figure that since the input corresponding to an expandable ADD with a parameter is at least three, the addition of eleven input parameters can be achieved through one function. Compared with using multiple ADDs without parameter expansion to connect to achieve the sequential summation of eleven input parameters, it can significantly reduce programming complexity and improve compilation efficiency.

[0053] It should be noted that the requirements for the compilation software used by the compiler in this implementation are mainly as follows: when calling the parameter extensible program organization unit, RepCount will be automatically hidden for the FBD programming language; when using the IEC language to implement the parameter extensible program organization unit, the source code of the parameter extensible program organization unit written by the user is visible, that is, the user can use RepCount as a common variable in the implementation code of the IEC language parameter extensible program organization unit to participate in the calculation, thereby obtaining the actual number of extensible parameters passed in.

[0054] The technical solution of the embodiment of the present invention is to compile and declare the parameter-extensible program organization unit in advance, and call the parameter-extensible program organization unit when executing the compiled language, so that the compiler can realize the extensible characteristics of the program organization unit, thereby reducing programming complexity and improving compilation efficiency.

[0055] Embodiment 2

[0056] Figure 2: is a flowchart of the execution method of the parameter extensible program organization unit provided by an embodiment of the present invention. This embodiment is based on the above embodiment, and after linking the first target file and the second target file to obtain the execution file, and executing the parameter extensible program organization unit based on the execution file, it also includes: detecting the execution result of the parameter extensible program organization unit. Accordingly, the method of this embodiment specifically includes the following operations:

[0057] Step S201, compile and declare the parameter extensible program organization unit to obtain a first target file.

[0058] Optionally, compiling a parameter-extensible program organization unit to declare and obtain a first target file may include: performing syntax detection on a current compiled language through a compiler to obtain the parameter-extensible program organization unit; determining a formal parameter part and a code part of the organization unit itself in the parameter-extensible organization unit, wherein the formal parameter part includes fixed input parameters, extensible input parameters, and output parameters; generating a first abstract syntax tree according to the formal parameter part and the code part of the organization unit itself, and obtaining a first target file based on the first abstract syntax tree.

[0059] Step S202 , when the compiled language to be executed is parsed to determine that a parameter extensible program organization unit needs to be called, a second target file is obtained according to the compiled language to be executed.

[0060] Optionally, when the compiled language to be executed is parsed to determine that a parameter-extensible program organization unit needs to be called, before obtaining the second target file according to the compiled language to be executed, it also includes: obtaining a program organization unit description file, the program organization unit description file includes a program organization unit name and an attribute identifier, and the attribute identifier includes whether it is extensible or not extensible.

[0061] Optionally, obtaining a second file based on the compiled language to be executed based on the program organization unit description file includes: performing syntax parsing or graphical parsing on the compiled language to be executed to obtain the name of the program organization unit, the actual parameters contained therein, and the compiled language code to be executed; querying from the program organization unit description file according to the name of the program organization unit to obtain the query result; determining according to the query result that the attribute of the program organization unit is identified as extensible, and the number of actual parameters does not exceed a preset threshold, then generating a second abstract syntax tree according to the actual parameters and the compiled language code to be executed, and obtaining a second target file based on the second abstract syntax tree.

[0062] Step S203: linking the first target file and the second target file to obtain an execution file, and expanding the program organization unit based on execution parameters of the execution file.

[0063] Step S204: detecting the execution result of the parameter-expandable program organization unit.

[0064] Specifically, in this embodiment, after executing the parameter-extensible program organization unit based on the execution file, it is detected whether there is an error in the execution result, or whether the execution result of the parameter-extensible program organization unit is correct. If an error occurs or the execution result is obviously wrong, there may be a problem with the internal structure design of the extensible program organization unit itself, or a problem with the operating environment configuration. At this time, an error prompt will be given to facilitate the operation and development personnel to carry out timely inspection and processing.

[0065] The technical solution of the embodiment of the present invention makes a compilation declaration for the parameter extensible program organization unit in advance, and calls the parameter extensible program organization unit when executing the compiled language, so that the compiler realizes the extensible characteristics of the program organization unit, thereby reducing programming complexity and improving compilation efficiency. In addition, by detecting the execution result of the parameter extensible program organization unit and issuing an alarm prompt when the execution result is wrong, it is convenient for users to perform maintenance in time, thereby further improving compilation efficiency.

[0066] Embodiment 3

[0067] Figure 3 It is a schematic diagram of the structure of an execution device of a parameter-expandable program organization unit provided in an embodiment of the present invention. The device includes: a first target file acquisition module 310, a second target file acquisition module 320 and an execution file acquisition module 330.

[0068] A first target file acquisition module 310 is used to compile and declare the parameter extensible program organization unit to acquire a first target file, wherein the first target file contains the formal parameters of the extensible program organization unit;

[0069] A second target file acquisition module 320 is used to parse the compiled language to be executed to determine that the parameter extensible program organization unit needs to be called, and then acquire a second target file according to the compiled language to be executed, wherein the second target file contains actual parameters that match the formal parameters;

[0070] The execution file acquisition module 330 is used to link the first target file and the second target file to acquire the execution file, and to expand the program organization unit based on the execution parameters of the execution file.

[0071] Optionally, the program organization unit includes: a function or a function block.

[0072] Optionally, a first target file acquisition module is specifically used to perform syntax detection on the current compiled language through a compiler to obtain a parameter extensible program organization unit;

[0073] Determine the parameter part and the code part of the organization unit itself in the parameter extensible organization unit, wherein the parameter part includes fixed input parameters, extensible input parameters and output parameters;

[0074] A first abstract syntax tree is generated according to the formal parameter part and the code part of the organization unit itself, and a first target file is obtained based on the first abstract syntax tree.

[0075] Optionally, the device further comprises a program organization unit description file acquisition module, which is used to acquire a program organization unit description file, wherein the program organization unit description file comprises a program organization unit name and an attribute identifier, wherein the attribute identifier comprises whether it is extensible or not extensible;

[0076] The second target file acquisition module is specifically used to parse the compiled language to be executed to determine that the parameter-expandable program organization unit needs to be called, and then acquire the second file according to the compiled language to be executed based on the program organization unit description file.

[0077] Optionally, a second target file acquisition module is used to perform syntax analysis or graphic analysis on the compiled language to be executed, and obtain the name of the program organization unit, the actual parameters contained therein, and the code of the compiled language to be executed itself;

[0078] Search the program organization unit description file according to the name of the program organization unit to obtain the query result;

[0079] If it is determined according to the query result that the attribute identifier of the program organization unit is extensible and the number of actual parameters does not exceed a preset threshold, a second abstract syntax tree is generated according to the actual parameters and the compiled language code to be executed, and a second target file is obtained based on the second abstract syntax tree.

[0080] Optionally, the execution file acquisition module is used to assign formal parameters of the first target file according to actual parameters of the second target file to acquire the execution file.

[0081] Optionally, the extensible input parameter includes a base data type or a generic data type.

[0082] The above device can execute the execution method of the parameter-expandable program organization unit provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by any embodiment of the present invention.

[0083] Embodiment 4

[0084] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. Figure 4 A block diagram of an exemplary electronic device 412 suitable for use in implementing embodiments of the present invention is shown. Figure 4The electronic device 412 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0085] like Figure 4 As shown, the electronic device 412 is in the form of a general purpose computing device. The components of the electronic device 412 may include, but are not limited to: one or more processors 416, a memory 428, and a bus 418 connecting different system components (including the memory 428 and the processor 416).

[0086] Bus 418 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0087] The electronic device 412 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 412, including volatile and non-volatile media, removable and non-removable media.

[0088] The memory 428 is used to store instructions. The memory 428 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 430 and / or cache memory 432. The electronic device 412 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 434 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 418 via one or more data medium interfaces. The memory 428 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0089] A program / utility 440 having a set (at least one) of program modules 442 may be stored, for example, in memory 428, such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 442 generally perform the functions and / or methods of the embodiments described herein.

[0090] The electronic device 412 may also communicate with one or more external devices 414 (e.g., keyboards, pointing devices, displays 424, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 412, and / or may communicate with any device that enables the electronic device 412 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 422. Furthermore, the electronic device 412 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 420. As shown, the network adapter 420 communicates with other modules of the electronic device 412 via a bus 418. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 412, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0091] The processor 416 executes various functional applications and data processing by running instructions stored in the memory 428, for example, implementing the execution method of the parameter extensible program organization unit provided in an embodiment of the present invention, including: compiling the parameter extensible program organization unit to obtain a first target file, wherein the first target file contains the formal parameters of the extensible program organization unit; when the compiled language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, a second target file is obtained according to the compiled language to be executed, wherein the second target file contains actual parameters that match the formal parameters; the first target file and the second target file are linked to obtain an execution file, and the parameter extensible program organization unit is executed based on the execution file.

[0092] Embodiment 5

[0093] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the execution method of the parameter-expandable program organization unit provided in all the embodiments of the present invention is implemented:

[0094] A compile declaration is performed on a parameter extensible program organization unit to obtain a first target file, wherein the first target file contains formal parameters of the extensible program organization unit; when a compiled language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, a second target file is obtained according to the compiled language to be executed, wherein the second target file contains actual parameters that match the formal parameters; the first target file and the second target file are linked to obtain an execution file, and the parameter extensible program organization unit is executed based on the execution file.

[0095] Any combination of one or more computer-readable media can be used. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0096] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0097] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0098] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely 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., via the Internet using an Internet service provider).

[0099] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for executing a parameter-expandable program organization unit, characterized in that: include: Compile and declare the parameter extensible program organization unit to obtain a first target file, wherein the first target file contains the formal parameters of the parameter extensible program organization unit; When the programming language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, a second target file is obtained according to the programming language to be executed, wherein the second target file contains actual parameters that match the formal parameters; Linking the first target file and the second target file to obtain an execution file, and executing the parameter extensible program organization unit based on the execution file; The step of compiling and declaring the parameter extensible program organization unit to obtain the first target file includes: performing syntax detection on the current programming language through a compiler to obtain the parameter extensible program organization unit; Determine the parameter part and the code part of the organization unit itself in the parameter extensible organization unit, wherein the parameter part includes fixed input parameters, extensible input parameters and output parameters; Generate a first abstract syntax tree according to the formal parameter part and the code part of the organization unit itself, and obtain the first target file based on the first abstract syntax tree; When the programming language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, obtaining a second target file according to the programming language to be executed includes: when the programming language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, performing syntax parsing or graphic parsing on the programming language to be executed to obtain the name of the program organization unit, the actual parameters contained therein, and the code of the programming language to be executed; According to the name of the program organization unit, a query is performed from a program organization unit description file to obtain a query result, wherein the program organization unit description file includes the name of the program organization unit and an attribute identifier, and the attribute identifier includes whether it is extensible or not extensible; If it is determined according to the query result that the attribute identifier of the program organization unit is extensible and the number of actual parameters does not exceed a preset threshold, a second abstract syntax tree is generated according to the actual parameters and the programming language to be executed itself, and the second target file is obtained based on the second abstract syntax tree.

2. The method according to claim 1, characterized in that: The parameter extensible program organization unit includes: a function or a function block.

3. The method according to claim 2, characterized in that When the programming language to be executed is parsed to determine that the parameter extensible program organization unit needs to be called, before obtaining the second target file according to the programming language to be executed, the method further includes: Obtain the program organization unit description file.

4. The method according to claim 1, characterized in that The linking of the first target file and the second target file to obtain an execution file includes: The execution file is obtained by assigning values ​​to the formal parameters of the first target file according to the actual parameters of the second target file.

5. The method according to claim 1, characterized in that The extensible input parameter includes a basic data type or a generic data type.

6. An execution device of a parameter-expandable program organization unit, characterized in that: include: A first target file acquisition module, used for compiling and declaring the parameter extensible program organization unit to acquire a first target file, wherein the first target file contains the formal parameters of the parameter extensible program organization unit; A second target file acquisition module is used to parse the programming language to be executed and determine that the parameter extensible program organization unit needs to be called, and then acquire a second target file according to the programming language to be executed, wherein the second target file contains actual parameters that match the formal parameters; an execution file acquisition module, used for linking the first target file and the second target file to acquire an execution file, and executing the parameter extensible program organization unit based on the execution file; The first target file acquisition module is used to perform syntax detection on the current programming language through a compiler to obtain the parameter extensible program organization unit; Determine the parameter part and the code part of the organization unit itself in the parameter extensible organization unit, wherein the parameter part includes fixed input parameters, extensible input parameters and output parameters; Generate a first abstract syntax tree according to the formal parameter part and the code part of the organization unit itself, and obtain the first target file based on the first abstract syntax tree; The second target file acquisition module is used to parse the programming language to be executed and determine that the parameter extensible program organization unit needs to be called, perform syntax analysis or graphic analysis on the programming language to be executed, and obtain the name of the program organization unit, the actual parameters contained therein, and the code of the programming language to be executed itself; According to the name of the program organization unit, a query is performed from a program organization unit description file to obtain a query result, wherein the program organization unit description file includes the name of the program organization unit and an attribute identifier, and the attribute identifier includes whether it is extensible or not extensible; If it is determined according to the query result that the attribute identifier of the program organization unit is extensible and the number of actual parameters does not exceed a preset threshold, a second abstract syntax tree is generated according to the actual parameters and the programming language to be executed itself, and the second target file is obtained based on the second abstract syntax tree.

7. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

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

Citation Information

Patent Citations

  • Method for compiling program organizing unit

    CN108804105A

  • Mini program application compiling method, operating method, storage medium and electronic equipment

    CN111736840A