Compiling method and apparatus, device, and storage medium

By adding the function name of the outer function to the inner function in the compiled file, the function name is ensured to be unique, which solves the problem of too large patch files and improves update coverage and reliability.

WO2024217143A1PCT designated stage expired Publication Date: 2024-10-24HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/078114
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-18
Filing Date
2024-02-22
Publication Date
2024-10-24

AI Technical Summary

Technical Problem

Excessively large patch files lead to long download times and insufficient memory, resulting in reduced coverage. This is mainly due to the fact that functions with the same function name in the original file are changed in the compiled file, causing functions with no change in logic to be recognized as changed functions. Add patch files.

Method used

By adding the function name of the outer function to the inner function in the compiled file, the function name of each inner function includes the first name and the second name, ensuring that the function name is unique, reducing the differences between the compiled files before and after modification, thereby narrowing the Patch file.

Benefits of technology

It effectively reduces the size of patch files, improves update coverage, avoids failures due to long download times and insufficient memory, and improves update reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024078114_24102024_PF_FP_ABST
    Figure CN2024078114_24102024_PF_FP_ABST
Patent Text Reader

Abstract

Provided are a compiling method and apparatus, a device, and a storage medium. The method comprises: acquiring a file to be compiled, wherein the file to be compiled comprises an initial nested function, and the initial nested function comprises an inner-layer function and an outer-layer function located outside the inner-layer function; and compiling the file to be compiled to generate a compiled file, wherein the compiled file comprises a target nested function, the target nested function is a function obtained after compiling the initial nested function, the function name of an inner-layer function in the target nested function comprises a first name and a second name, the first name is used for identifying the function name of the inner-layer function in the file to be compiled, and the second name is used for identifying the function name of an outer-layer function in the compiled file. During the generation of a patch file, the difference between compiled files generated by a file to be compiled before modification and a file to be compiled after modification can be reduced, thereby reducing the size of the patch file.
Need to check novelty before this filing date? Find Prior Art

Description

Compilation method, device, equipment and storage medium

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on April 18, 2023, with application number 202310456424.8 and application name “A compilation method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of computer technology, and in particular to a compilation method, apparatus, device, and storage medium. Background Art

[0003] After an application is released, if it encounters an emergency, such as a security vulnerability or public outcry caused by the application itself, updating it through the app market can be time-consuming, require user intervention, and result in low update coverage. However, patching technology, which is initiated proactively by the application without requiring market or user intervention, can achieve higher coverage. Patch technology is widely used in various applications and system software on mainstream platforms, including mobile platforms like iOS and Android, and personal computer platforms like Windows.

[0004] In patching technology, developers modify source code, generate patch files, and deploy them to a server. Applications retrieve the patch files from the server and use them to update the required program code and resources on the local device. The size of the patch file affects its coverage. Overly large patch files may cause download interruptions or storage failures due to insufficient memory, resulting in reduced coverage.

[0005] In the original file, two functions belonging to different outer functions can have the same name or be anonymous. However, in the compiled file, function names must exist and be unique. In some technologies, when compiling the original file into a compiled file, functions with the same name need to be renamed to ensure unique function names. For example, a numerical identifier can be added to the function name in the original file. This numerical identifier is generated during compilation using a global variable. All functions with the same name in the original file use this global variable to determine the numerical identifier. Therefore, adding or deleting functions with the same name in the original file may affect the numerical identifiers of functions with the same name belonging to other outer functions in the original file. In other words, a function with the same name belonging to another outer function may have its name changed in the compiled file after modification, even though its logic remains unchanged in the modified original file. Patch files are generated based on the differences between the compiled files before and after the modification of the original file. Therefore, when the patch file is generated, these functions with the same name belonging to other outer functions with the same logic and unchanged may also be identified as modified functions and added to the patch file, resulting in an excessively large patch file.

[0006] Summary of the Invention

[0007] In view of this, the present application provides a compilation method, apparatus, device and storage medium to facilitate solving the problem of excessively large patch files.

[0008] In a first aspect, an embodiment of the present application provides a compilation method, the method comprising:

[0009] Obtaining a file to be compiled; the file to be compiled includes an initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function;

[0010] Compile the file to be compiled to generate a compiled file; wherein, the compiled file includes a target nested function, which is a function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled.

[0011] In a possible implementation manner of the first aspect, the second name includes: a function name of the outer function in the compiled file.

[0012] In a possible implementation manner of the first aspect, if the inner function has a function name in the file to be compiled, the first name includes: a compiled value of the function name of the inner function in the file to be compiled.

[0013] In a possible implementation manner of the first aspect, the first name includes: a function name set for the inner function by a naming function corresponding to the outer function.

[0014] In a possible implementation manner of the first aspect, when the file to be compiled includes multiple outer functions, the outer functions correspond to the named functions in a one-to-one correspondence.

[0015] In a possible implementation of the first aspect, the naming function includes a naming variable; the value of the naming variable is related to the number of inner functions in the outer function that have been set with the first name by the naming function.

[0016] In a possible implementation of the first aspect, the value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name by the named function and 1.

[0017] In a possible implementation manner of the first aspect, the function name set for the inner function by the named function corresponding to the outer function includes the value of the named variable.

[0018] In a possible implementation manner of the first aspect, the inner function is an anonymous function in the file to be compiled.

[0019] In a possible implementation of the first aspect, when the file to be compiled includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of a special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled values ​​of the function names of other functions; the other functions include the outer functions and / or non-nested functions of the outermost nested function in other initial nested functions.

[0020] In a second aspect, an embodiment of the present application provides a compilation method, the method comprising:

[0021] Obtaining an update file of an original file and a compilation information table of the original file; the compilation information table is used to record location information of parameters included in an original function in a first compiled file, the first compiled file being the compiled file of the original file, and the original function being a function in the original file; the update file including a target function, the target function being an update function of the original function, and the target function including original parameters; the original parameters being parameters included in both the original function and the target function;

[0022] The update file is compiled according to the compilation information table to generate a second compiled file; the positioning information of the original parameters in the second compiled file is the same as the positioning information of the original parameters in the first compiled file.

[0023] In a possible implementation of the second aspect, before obtaining the update file of the original file and the compilation information table of the original file, the method further includes:

[0024] The original file is compiled to generate a first compiled file and a compilation information table.

[0025] In a possible implementation manner of the second aspect, the original parameters include closure parameters.

[0026] In a possible implementation of the second aspect, compiling the update file according to the compilation information table to generate a second compiled file includes:

[0027] determining target positioning information of the original parameter in the update file according to the compilation information table; the target positioning information of the original parameter is positioning information of the original parameter in the first compilation file;

[0028] The target positioning information of the original parameter is used as the positioning information of the original parameter in the second compiled file, and the updated file is compiled to generate a second compiled file.

[0029] In a possible implementation of the second aspect, when the update file includes an initial nested function, the second compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the update file, and the second name is used to identify the function name of the outer function in the update file.

[0030] In a possible implementation of the second aspect, when the original file includes an initial nested function, the first compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the original file, and the second name is used to identify the function name of the outer function in the original file.

[0031] In a possible implementation manner of the second aspect, the second name is a function name of the outer function in the target nested function.

[0032] In a possible implementation of the second aspect, if the inner function has a function name in the initial nested function, the first name includes a compiled value of the function name of the inner function in the initial nested function.

[0033] In a possible implementation manner of the second aspect, the first name is set by a naming function corresponding to the initial nested function.

[0034] In a possible implementation manner of the second aspect, when there are multiple outer functions, the outer functions correspond to the named functions in a one-to-one manner.

[0035] In a possible implementation of the second aspect, the naming function includes a naming variable; the value of the naming variable is related to the number of inner functions in the outer function that have been set with the first name by the naming function.

[0036] In a possible implementation of the second aspect, the value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name by the named function and 1.

[0037] In a possible implementation manner of the second aspect, the first name includes the value of the named variable.

[0038] In a possible implementation of the second aspect, if the inner function is an anonymous function in the initial nested function, the first name is set by a named function corresponding to the outer function.

[0039] In a possible implementation of the second aspect, when the original file or updated file includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of a special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled values ​​of the function names of other functions; the other functions include the outer functions and / or non-nested functions of the outermost nested function in other initial nested functions.

[0040] In a third aspect, an embodiment of the present application provides a compilation device, including:

[0041] An acquisition unit, configured to acquire a file to be compiled; the file to be compiled includes an initial nested function; the initial nested function includes an inner function and at least one outer function located outside the inner function;

[0042] A compilation unit is used to compile the file to be compiled to generate a compiled file; wherein, the compiled file includes a target nested function, and the target nested function is the function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the compiled file; wherein, when compiling the file to be compiled, the first name and the second name are determined.

[0043] In a fourth aspect, an embodiment of the present application provides a compilation device, including:

[0044] an acquisition unit, configured to acquire an update file of an original file and a compilation information table of the original file; the compilation information table being configured to record location information of parameters contained in an original function in a first compiled file, wherein the first compiled file is a compiled file of the original file, and the original function is a function in the original file; the update file includes a target function, which is an update function of the original function, and the target function includes original parameters; the original parameters are parameters contained in both the original function and the target function;

[0045] A compiling unit is configured to compile the update file according to the compilation information table to generate a second compiled file; the positioning information of the original parameters in the second compiled file is the same as the positioning information of the original parameters in the first compiled file.

[0046] In a fifth aspect, an embodiment of the present application provides an electronic device comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein, when the computer program instructions are executed by the processor, the electronic device is triggered to execute the method described in any one of the first aspects above, or the method described in any one of the second aspects above.

[0047] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the method described in any one of the first aspects or to execute the method described in any one of the second aspects.

[0048] Using the solution provided in an embodiment of the present application, a file to be compiled is obtained; the file to be compiled includes an initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the file to be compiled is compiled to generate a compiled file; wherein the compiled file includes a target nested function, which is the function after the initial nested function is compiled; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled. Thus, in an embodiment of the present application, after the file to be compiled is compiled, a compiled file is generated. The function names of the inner functions in the compiled file include the first name and the second name. That is, the function name of each inner function in the compiled file includes not only the first name but also the second name, i.e., the function name of the outer function that must be included. The inner function is uniquely identified in the compiled file by adding the function name of the outer function. Thus, the function name of the inner function is related to the function names of the inner function in the file to be compiled and the function names of the outer function in the file to be compiled, and is unrelated to the function names of other functions. When generating a patch file, the difference between the compiled files generated by the files to be compiled before and after the modification can be reduced, thereby reducing the size of the patch file. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0050] FIG1 is a schematic diagram of a scenario of a compilation method provided in an embodiment of the present application;

[0051] FIG2 is a schematic diagram of another scenario of a compilation method provided in an embodiment of the present application;

[0052] FIG3 is a schematic diagram of a flow chart of a compilation method provided in an embodiment of the present application;

[0053] FIG4 is a schematic diagram of another scenario of a compilation method provided in an embodiment of the present application;

[0054] FIG5 is a schematic diagram of another scenario of a compilation method provided in an embodiment of the present application;

[0055] FIG6 is a flow chart of another compilation method provided in an embodiment of the present application;

[0056] FIG7a is a schematic diagram of another scenario of a compilation method provided in an embodiment of the present application;

[0057] FIG7 b is a schematic diagram of another scenario of a compilation method provided in an embodiment of the present application;

[0058] FIG8 is a flow chart of another compilation method provided in an embodiment of the present application;

[0059] FIG9 is a schematic diagram of another scenario of a compilation method provided in an embodiment of the present application;

[0060] FIG10 is a schematic diagram of the structure of a compilation device provided in an embodiment of the present application;

[0061] FIG11 is a schematic structural diagram of another compiling device provided in an embodiment of the present application;

[0062] FIG12 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0064] It should be clear that the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0065] The terms used in the embodiments of the present application are for the purpose of describing specific embodiments only and are not intended to limit the present application. The singular forms "a", "an", "the" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise.

[0066] It should be understood that the term "and / or" as used herein simply describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the associated objects.

[0067] Before providing a detailed introduction to the embodiments of the present application, the terms that are applied or may be applied to the embodiments of the present application are first explained.

[0068] After an application is released, if it encounters an emergency, such as a security vulnerability or public outcry caused by the application itself, updating it through the app market can be time-consuming, require user intervention, and result in low update coverage. However, patching technology, which is initiated proactively by the application without requiring market or user intervention, can achieve higher coverage. Patch technology is widely used in various applications and system software on mainstream platforms, including mobile platforms like iOS and Android, and personal computer platforms like Windows.

[0069] In patching technology, developers modify source code, generate patch files, and deploy them to a server. Applications retrieve the patch files from the server and use them to update the required program code and resources on the local device. The size of the patch file affects its coverage. Overly large patch files may cause download interruptions or storage failures due to insufficient memory, resulting in reduced coverage.

[0070] As shown in Figure 1, the original file is modified to obtain an updated file. A patch file is generated based on the differences between the compiled file of the original file and the compiled file of the updated file. The patch file is uploaded to the server. The application obtains the patch file from the server and uses the patch file to update the compiled file of the original file on the local device.

[0071] In the original file, two functions belonging to different outer functions can have the same function name. For example, if the two functions mentioned above have function names, they have the same function name. Alternatively, both functions are anonymous. However, function names must exist and be unique in the compiled file. In some technologies, when compiling the original file into a compiled file, functions with the same function name need to be renamed to ensure unique function names. For example, a numerical identifier can be added to the function name in the original file. This numerical identifier is generated during compilation using a global variable. All functions with the same function name in the original file use this global variable to determine the numerical identifier. Therefore, adding or deleting a function with the same function name in the original file may affect the numerical identifiers of functions with the same function name belonging to other outer functions in the original file. In other words, a function with the same function name belonging to another outer function in the modified original file may have a different function name in the modified compiled file, even though its logic remains unchanged. Patch files are generated based on the differences between the compiled files compiled before and after the modification of the original file. Therefore, when the patch file is generated, functions with the same function name as other outer functions with the same logic but no change will also be identified as changed functions and then added to the patch file, resulting in an excessively large patch file.

[0072] For example, as shown in Figure 2, assume that the original file contains function a, function b, and function c. Function a contains a first function, function b contains a second function, and function c contains a third function. The first, second, and third functions all have the same function name, f. In some technologies, when compiling a source code file to generate a compiled file, functions with the same function name are renamed by adding a numerical identifier to their original function name. That is, when generating the compiled file, since the first, second, and third functions have the same function name, they need to be renamed by adding a numerical identifier to their original function name. In some technologies, a global variable can be used to determine the numerical identifier corresponding to each function with the same function name. Typically, the initial value of this global variable is 1, and the value of the global variable is incremented by 1 after each call. That is, when generating the compiled file, the numerical identifier of the first function is determined to be 1 by calling the global variable. After determining the numerical identifier corresponding to the first function, the value of the global variable is incremented by 1, and the value of the global variable is now 2. The global variable is called again to determine that the numerical identifier of the second function is 2. After determining the numerical identifier corresponding to the second function, the value of the global variable is increased by 1, and the value of the global variable is now 3. The global variable is called again to determine that the numerical identifier of the third function is 3. After determining the numerical identifier corresponding to the third function, the global variable is increased by 1, and the value of the global variable is now 4. In this way, the function names of the first, second, and third functions in the compiled file are #1#f, #2#f, and #3#f, respectively.

[0073] After modifying the original file, an updated file is generated. Compared to the original file, the updated file deletes the first function. When compiling the updated file using the above compilation method, numeric identifiers are added to the original function names of the second and third functions. For details, refer to the above process. In this case, the function names of the second and third functions in the compiled file of the updated file are #1#f and #2#f, respectively.

[0074] In this way, the second function and function b, which have no logical changes, will be identified as changed functions because the function name of the second function has changed. Similarly, the third function and function c will be identified as changed functions because the function name of the third function has changed, and then added to the patch file, causing the patch file to be too large.

[0075] To address the above-mentioned issues, embodiments of the present application provide a compilation method, apparatus, device, and storage medium, which obtain a file to be compiled; the file to be compiled includes an initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the file to be compiled is compiled to generate a compiled file; wherein the compiled file includes a target nested function, which is the function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled. Thus, in embodiments of the present application, after the file to be compiled is compiled, a compiled file is generated. wherein the function name of the inner function in the compiled file includes a first name and a second name. That is, the function name of each inner function in the compiled file includes not only the first name but also the second name, i.e., the function name of the outer function that needs to be included, and the inner function is uniquely identified in the compiled file by adding the function name of the outer function. In this way, the function name of the inner function is related to the function names of the inner functions in the to-be-compiled file and the function names of the outer functions in the to-be-compiled file, and is unrelated to the function names of other functions. When generating a patch file, this can reduce the difference between the compiled files generated before and after the modification of the to-be-compiled file, thereby reducing the size of the patch file. This is explained in detail below.

[0076] See Figure 3, which is a flow chart of a compilation method provided in an embodiment of the present application. As shown in Figure 3, the method includes:

[0077] Step S301: Obtain the file to be compiled.

[0078] The file to be compiled includes an initial nested function, and the initial nested function includes an inner function and an outer function outside the inner function.

[0079] In the embodiments of the present application, the file to be compiled is a file that needs to be compiled. Compilation is the process of converting a high-level language into machine language. In some embodiments, the file to be compiled is a source code file written in a high-level language, such as JavaScript.

[0080] Functions can be nested within a function in a file to be compiled, meaning that the file to be compiled contains an initial nested function. In this case, the function nested within is called an inner function, and the function that nests the inner function is called an outer function.

[0081] In some embodiments, there are multiple layers of nesting within the initial nested functions. In this case, each nested function has an inner function and an outer function. For example, if function foo nests function fo, which in turn nests function fi, then function foo contains two layers of nested functions. One layer of nested functions has function fi as its inner function and function fo as its outer function. The other layer of nested functions has function fo as its inner function and function fo as its outer function.

[0082] Step S302: compile the file to be compiled to generate a compiled file.

[0083] Among them, the compiled file includes a target nested function, which is a function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled.

[0084] In an embodiment of the present application, a source code file written in a high-level language needs to be converted into a machine-oriented code file. That is, the file to be compiled is compiled to generate a compiled file. When the file to be compiled is compiled into a compiled file, the initial nested function in the file to be compiled is compiled into the target nested function in the compiled file. The function names in the compiled file must correspond one-to-one with the functions in the file to be compiled. That is, the function names of the functions in the file to be compiled and the corresponding functions in the compiled file must be unique and no duplication is allowed.

[0085] To achieve this one-to-one correspondence, the function names of different inner functions in the compiled file can be distinguished by combining the first name and the second name. Although the first names contained in the function names of different inner functions in the same outer function are all different, the first names contained in the function names of at least some inner functions in different outer functions may be the same. Therefore, the function names of different inner functions in the compiled file can be distinguished by combining the first name and the second name. Among them, the second names corresponding to the function names of different outer functions are all different.

[0086] It should be noted that in the compiled file, if the outermost function names of each target nested function are all different, then the second names included in the function names of the inner functions of the outermost nested function are all different. When the inner functions of multiple outermost nested functions serve as the outer functions of other nested functions, the outer functions of these other nested functions all have different function names, that is, the second names included in the function names of the inner functions of these other nested functions are all different.

[0087] The outermost nested function of the target nested function refers to a nested function that is not nested in other functions in the target nested function but nests other functions.

[0088] For example, assume that the file to be compiled contains functions foo and goo, where function foo refers to a function named foo, and function goo refers to a function named goo. In the following examples, for ease of description, function names will be expressed in this manner. Function foo contains a first initial function nested within it, which contains a second initial function nested within it. The first initial function is named fo, and the second initial function is named fi. Function goo contains a third initial function nested within it, which contains a fourth initial function nested within it. The third initial function is also named fo, and the fourth initial function is also named fi. In other words, the file to be compiled contains two layers of nested initial nested functions: the first initial nested function and the second initial nested function. In the first initial nested function, the outermost nested function has the function name foo, and the innermost function has the function name fo. The second nested function has the outermost function name fo, and the innermost function has the function name fi. Similarly, in the second initial nested function, the outermost nested function has the function name goo, and the innermost function has the function name fo. The outer function name of the second nested function is fo, and the inner function name is fi.

[0089] When compiling the file to be compiled, the first initial nested function is compiled into the first target nested function, and the second initial nested function is compiled into the second target nested function. Since the function name of the outer function of the outermost nested function of each initial nested function in the file to be compiled is different, the compiled value of the function name of the outer function of each outermost nested function can be directly used as the function name of the outer function of each outermost nested function after compilation during the compilation process. Based on this, the function name of the outer function of the outermost nested function in the first target nested function is foo, and the function name of the outer function of the outermost nested function in the second target nested function is goo. After determining that the function name of the outer function of the outermost nested function in the first target nested function is foo, the second name of the inner function of the outermost nested function in the first target nested function can be determined as foo and its first name can be determined as fo during the compilation process, that is, the function name of the inner function of the outermost nested function in the first target nested function is foofo. After determining the function name of the inner function of the outermost nested function in the first target nested function, the outer function in the second nested function of the first target nested function is the inner function of the outermost nested function in the first target nested function, that is, the function name of the outer function in the second nested function of the first target nested function is foofo. At this time, the second name of the inner function of the second nested function in the first target nested function can be determined as foofo, and its first name can be determined as fi, that is, the function name of the inner function of the second nested function in the first target nested function is foofofi. Similarly, the second name of the inner function of the outermost nested function in the second target nested function is determined as goo, and its first name is determined as fo, that is, the function name of the inner function of the outermost nested function in the second target nested function is goofo. After determining the function name of the inner function of the outermost nested function in the second target nested function, the outer function in the second nested function of the second target nested function is the inner function of the outermost nested function in the second target nested function, that is, the function name of the outer function in the second nested function of the first target nested function is goofo. At this time, the second name of the inner function of the second nested function in the second target nested function can be determined as goofo, and its first name can be determined as fi, that is, the function name of the inner function of the second nested function in the second target nested function is goofofi.

[0090] From the above example, it can be seen that in the file to be compiled, even if the function names of the inner functions in two nested functions are the same, through the above compilation method, the function names of each function in the compiled file are different, thereby achieving the purpose of unique function names in the compiled file.

[0091] As a possible implementation manner, when the file to be compiled includes multiple initial nested functions and / or non-nested functions, the function names of inner functions in the target nested functions further include compiled values ​​of special characters.

[0092] The compiled value of the special character is used to distinguish the compiled value of the function name of the inner function from the function name of other functions; other functions include the outer function and / or non-nested function of the outermost nested function in other initial nested functions.

[0093] That is, when the file to be compiled includes multiple initial nested functions and / or non-nested functions, in order to avoid the function name of the inner function of the target nested function being the string directly formed by the second name and the first name, which is the same as the compiled value of the function name of other functions in the file to be compiled, the function name of the inner function of the target nested function includes the compiled value of the second name, the first name and the special character. In some embodiments, the character type of the special character can be a character type that is different from the character type of the characters contained in the function names of other functions. For example, the special character can be #. Alternatively, in some embodiments, the character type of the special character can also be a numeric type. Since the first character of the function name of other functions can only be a letter or an underscore, the special character can be set before the string directly formed by the second name and the first name, that is, set at the first position of the function name of the inner function.

[0094] The compiled value of a function name refers to the compiled result after the function name is compiled. The compiled value of a special character refers to the compiled result after the special character is compiled.

[0095] As described in the example above, the file to be compiled may contain a function named fofoo or foofo. In this case, the name of the innermost function of the target nested function is a string formed by the second name and the first name, which is the same as the compiled value of the function name of the function in the file to be compiled. To avoid this, if the name of the innermost function of the outermost nested function of the target nested function also includes the special character #, the name of the innermost function of the outermost nested function of the target nested function can be set to foo#fo.

[0096] In this way, adding or deleting outer functions during modification of the to-be-compiled file does not change the function names of inner functions belonging to other outer functions in the compiled file, thereby reducing the differences between the compiled files generated by the to-be-compiled file before and after the modification. The patch file is generated based on the differences between the compiled files generated by the to-be-compiled file before and after the modification. Therefore, when generating a patch file, using the compilation method of this application to compile the to-be-compiled file before and after the modification can reduce the size of the patch file.

[0097] As a possible implementation manner, the second name includes: the function name of the outer function in the compiled file.

[0098] Before determining the function name of the inner function of the nested function in the target nested function, the function name of the outer function of the nested function in the compiled file has been determined. Therefore, the function name of the outer function of the nested function in the compiled file can be directly used as the second name of the inner function of the nested function.

[0099] Among them, when the outer function of the nested function is the inner function of other nested functions of the target nested function, the function name of the outer function of the nested function can be determined by the method of determining the function name of the inner function mentioned above.

[0100] In some embodiments, when the outer function of the nested function is the outermost outer function of the target nested function, the compiled value of the function name of the outer function of the nested function in the file to be compiled can be directly used as the function name of the outer function of the nested function in the compiled file.

[0101] Of course, other methods can also be used to set the function name of the outer function of the nested function in the compiled file, so that the function names of different outermost functions correspond one-to-one with the function names of these different outermost functions in the file to be compiled. This application does not impose any restrictions on this.

[0102] As a possible implementation manner, if the inner function has a function name in the file to be compiled, the first name includes: a compiled value of the function name of the inner function in the file to be compiled.

[0103] In this embodiment of the present application, if an inner function has a function name in the file to be compiled, since different inner functions within the same outer function have different function names in the file to be compiled, the compiled value of the function name of the inner function in the file to be compiled can be used as the first name. This reduces compilation complexity and improves compilation efficiency and accuracy.

[0104] As a possible implementation manner, the first name includes: a function name set for the inner function by a named function corresponding to the outer function.

[0105] In an embodiment of the present application, in order to improve the security, flexibility, and universality of compilation, the function name of the inner function in the file to be compiled may not be used, or when the inner function does not have a function name in the file to be compiled, the first name may be set by the naming function corresponding to the outer function. In some embodiments, the naming function corresponding to the outer function is a single function. In some embodiments, multiple outer functions correspond to the same naming function, that is, the first name of the inner functions to which these outer functions belong is set by the naming function.

[0106] As a possible implementation manner, the inner function is an anonymous function in the file to be compiled. In this case, the first name includes: a function name set for the anonymous function by a named function corresponding to the outer function.

[0107] In this embodiment of the present application, only when the inner function is an anonymous function, the first name of the anonymous function can be set by the named function corresponding to the outer function. In this way, the addition or deletion of an anonymous function only affects the function name of the anonymous function in the inner function corresponding to the same named function, and does not affect the function name of the inner function belonging to the same outer function that does not have the first name set by the named function.

[0108] As a possible implementation method, when the file to be compiled contains multiple outer functions, the outer functions correspond one-to-one to the named functions.

[0109] In the embodiment of the present application, when the file to be compiled contains multiple outer functions, each outer function is assigned a named function. That is, the first name of the inner function of the outer function is set by the outer function's named function. This prevents the addition or deletion of an inner function from affecting the first names of the inner functions of other outer functions.

[0110] As a possible implementation, the named function includes a named variable, and the value of the named variable is related to the number of inner functions in the outer function that have been assigned a first name by the named function.

[0111] In an embodiment of the present application, when a first name is set for the function name of an inner function in a compiled file using a naming function, the first name is associated with a naming variable. At this time, since the value of the naming variable is related to the number of inner functions in the outer function that have been set with the first name using the naming function, that is, the value of the naming variable changes with the number of inner functions in the outer function that have been set with the first name using the naming function, therefore, when different inner functions corresponding to the same naming function use the naming function to set the first name, the first name is different.

[0112] As a possible implementation, the value of the named variable is the sum of the number of anonymous functions whose first names have been set by the named function in the outer function and 1.

[0113] In an embodiment of the present application, to reduce compilation complexity and improve compilation efficiency and accuracy, the value of the named variable is set to the sum of the number of anonymous functions in the outer function that have been assigned a first name by the named function, plus 1. That is, each time the first name is assigned by the named function, the value of the named variable is incremented by 1, so that different inner functions belonging to the same named function have different first names. In some embodiments, the initial value of the named variable is 1.

[0114] As a possible implementation, the function name set for the inner function by the named function corresponding to the outer function includes the value of the named variable.

[0115] In the embodiment of the present application, in order to reduce the complexity of compilation and improve compilation efficiency and compilation accuracy, the value of the named variable is set to the first name through the naming function corresponding to the outer function. For different inner functions belonging to the same naming function, the value of the named variable is different, and therefore the first name is different.

[0116] For example, the first name of the first inner function in the outer function that sets the first name through the named function is 1, the first name of the second inner function in the outer function that sets the first name through the named function is 2, and the first name of the third inner function in the outer function that sets the first name through the named function is 3.

[0117] It should be noted that in order to improve the security of the compiled file, other methods can also be used to set the first name, so that the first names included in the function names of different inner functions correspond one-to-one with the function names of these different inner functions in the file to be compiled. This application does not impose any restrictions on this.

[0118] In an embodiment of the present application, after the file to be compiled is compiled, a compiled file is generated. The function name of the inner function in the compiled file includes a first name and a second name. That is, the function name of each inner function in the compiled file includes not only the first name but also the second name, that is, the function name of its outer function must be included. The inner function is uniquely identified in the compiled file by adding the function name of its outer function. In this way, the function name of the inner function is related to the function name of the inner function in the file to be compiled and the function name of the outer function in the file to be compiled, and has nothing to do with the function names of other functions. When generating a patch file, the difference between the compiled files generated by the file to be compiled before and after the modification can be reduced, thereby reducing the size of the patch file.

[0119] For example, as shown in FIG4 , the file to be compiled includes a function called outer, within which are nested the first and second functions. The first function is named g, and the second function is named h. The first function is nested within the third, fourth, and fifth functions. The second function is nested within the sixth and seventh functions. The third function is named h, and the fourth, fifth, sixth, and seventh functions are all anonymous functions.

[0120] For the function outer, the compiled value of the function name outer in the file to be compiled is used as the function name of the function in the compiled file.

[0121] For the first function, i.e., function g nested in function outer, the compiled value of the function name g of the inner function in the to-be-compiled file is used as the first name, and the function name outer of the outer function in the compiled file is used as the second name. In this example, the second name in the function name of the inner function in the target nested function is located before the first name, and the function name of the inner function in the target nested function also includes the compiled value of a special character. Among them, the special character is set to # and is located between the second name and the first name. Then, for the first function, the corresponding function name in the target nested function is outer#g. Similarly, for the second function, i.e., function h nested in function outer, the compiled value of the function name g of the inner function in the to-be-compiled file is used as the first name, and the function name outer of the outer function in the compiled file is used as the second name, and the corresponding function name in the target nested function is outer#h.

[0122] For the third function, the function name outer#g of the outer function in the compiled file is used as the second name, and the compiled value of the function name h of the inner function in the file to be compiled is used as the first name, and the corresponding function name in the target nested function is outer#g#h.

[0123] For the fourth function, the function name outer#g of the outer function in the compiled file is used as the second name. In this example, the outer function corresponds to the named function one-to-one, and the first function corresponds to a named function, that is, the first names of the fourth and fifth functions are set by the named function corresponding to the first function. For the named function corresponding to the first function, the value of the named variable is the sum of the number of anonymous functions that have been set as the first name by the named function and 1, and the value of the named variable is used as the first name. For the fourth function, the number of anonymous functions that have been set as the first name by the named function is 0, and the sum of the number of anonymous functions that have been set as the first name by the named function and 1 is 1, that is, the value of the named variable is 1. Taking 1 as the first name, the function name of the fourth function in the compiled file is outer#g#1.

[0124] Similarly, for the fifth function, the outer function's name in the compiled file, outer#g, is used as the second name. The number of anonymous functions with the first name set by the named function corresponding to the first function is 1, and the sum of the number of anonymous functions with the first name set by the named function corresponding to the first function and 1 is 2, that is, the value of the named variable is 2. With 2 as the first name, the fifth function's name in the compiled file is outer#g#2.

[0125] The second function corresponds to a named function, that is, the first names of the sixth function and the seventh function are set by the named function corresponding to the second function.

[0126] For the sixth function, the function name outer#h of the outer function in the compiled file is used as the second name. The number of anonymous functions with the first name set by the named function corresponding to the second function is 0, and the sum of the number of anonymous functions with the first name set by the named function corresponding to the second function plus 1 is 1, that is, the value of the named variable is 1. With 1 as the first name, the function name of the sixth function in the compiled file is outer#h#1.

[0127] Similarly, for the seventh function, the outer function's name in the compiled file, outer#h, is used as the second name. The number of anonymous functions with the first name set by the named function corresponding to the second function is 1, and the sum of the number of anonymous functions with the first name set by the named function corresponding to the second function plus 1 is 2, that is, the value of the named variable is 2. With 2 as the first name, the function name of the seventh function in the compiled file is outer#h#2.

[0128] For example, as shown in FIG5 , the original file includes function a, function b, and function c. Function a includes a first function, function b includes a second function, and function c includes a third function. The first, second, and third functions all have the same function name, f.

[0129] For function a, the compiled value of function name a in the original file is used as the function name in the compiled file of the original file. For function b, the compiled value of function name b in the original file is used as the function name in the compiled file of the original file. For function c, the compiled value of function name c in the original file is used as the function name in the compiled file of the original file.

[0130] For the first function, the outer function's function name "a" in the compiled file is used as the second name, and the compiled value of the inner function's function name "f" in the original file is used as the first name. In this example, the second name in the inner function's function name in the target nested function precedes the first name, and the inner function's function name in the target nested function also includes the compiled value of a special character. The special character is set to "#" and is located between the second name and the first name. Therefore, for the first function, in the compiled file of the original file, the function name of the first function is "a#f." Similarly, for the second function, the outer function's function name "b" in the compiled file is used as the second name, and the compiled value of the inner function's function name "f" in the original file is used as the first name. Therefore, in the compiled file of the original file, the function name of the second function is "b#f." For the third function, the outer function's function name "c" in the compiled file is used as the second name, and the compiled value of the inner function's function name "f" in the original file is used as the first name. Therefore, in the compiled file of the original file, the function name of the third function is "c#f."

[0131] The file obtained after the original file is modified is the updated file of the original file. Compared with the original file, the updated file deletes the first function. For the second function, the function name b of the outer function in the compiled file is used as the second name, and the compiled value of the function name f of the inner function in the updated file is used as the first name. In the compiled file of the updated file, the function name of the second function is b#f. For the third function, the function name c of the outer function in the compiled file is used as the second name, and the compiled value of the function name f of the inner function in the updated file is used as the first name. In the compiled file of the updated file, the function name of the third function is c#f.

[0132] The function name of the second function in the compiled file of the updated file remains unchanged from the function name of the second function in the compiled file of the original file. The function name of the third function in the compiled file of the updated file remains unchanged from the function name of the third function in the compiled file of the original file.

[0133] See Figure 6, which is a flow chart of a compilation method provided in an embodiment of the present application. As shown in Figure 6, the method includes:

[0134] Step 601: Obtain an update file of an original file and a compilation information table of the original file.

[0135] Among them, the compilation information table is used to record the positioning information of the parameters contained in the original function in the first compilation file, the first compilation file is the compilation file of the original file, and the original function is the function in the original file; the update file includes the target function, the target function is the update function of the original function, and the target function includes the original parameters; the original parameters refer to the parameters contained in both the original function and the target function.

[0136] In an embodiment of the present application, the location information of the parameters is the address information assigned by the compiler to the parameters contained in the original function in the original file during the compilation process of the original file, and is recorded in the compilation information table of the original file.

[0137] The file obtained after modifying the original file is called the updated file of the original file. The original file is compiled to generate a compiled file of the original file, namely the first compiled file. If the updated file contains an update function of the original function, and the updated function also contains the parameters of the corresponding original function, the parameters can be used as the original parameters, and the updated function can be used as the target function.

[0138] In order to reduce the difference between the compiled file of the updated file and the compiled file of the original file, when compiling the updated file, it is necessary to refer to the positioning information of the original parameters in the first compiled file to determine the positioning information of the original parameters in the compiled file of the updated file, so it is necessary to obtain the compilation information table of the original file.

[0139] In some embodiments, when the original file is compiled, a compilation information table of the original file can be generated and stored simultaneously. In this way, when the compilation information table of the original file needs to be obtained, the stored compilation information table of the original file can be directly obtained.

[0140] Step 602: Compile the update file according to the compilation information table to generate a second compiled file.

[0141] The positioning information of the original parameter in the second compiled file is the same as the positioning information of the original parameter in the first compiled file.

[0142] In an embodiment of the present application, in order to reduce the difference between the compiled file of the update file and the compiled file of the original file, when compiling the update file, the compilation information table can be referenced to determine the positioning information of each original parameter of the update file, so that the update file can be compiled based on the positioning information of each original parameter to obtain a second compiled file, wherein the positioning information of the original parameter in the second compiled file is the same as the positioning information of the original parameter in the first compiled file.

[0143] In this way, when an updated file adds or deletes some parameters relative to the original file, the parameters in the updated file that remain unchanged relative to the original file, that is, the location information of the original parameters, remain unchanged. The compiled file of the updated file, that is, the statements in the target function in the second compiled file related to the location information of the original parameters, remain unchanged. When generating the patch file, the differences between the first and second compiled files can be reduced, thereby reducing the size of the patch file.

[0144] As a possible implementation, the original parameters include closure parameters.

[0145] In an embodiment of the present application, functions can be nested inside the original function. The function nested inside is the inner function, and correspondingly, the function in which the inner function is nested is the outer function. The inner function can access the parameters in the outer function, and the parameters are the closure parameters of the outer function. The closure parameter can be a closure variable or a closure function. The inner function can access the closure parameter through the location information of the closure parameter. When the original parameter includes the closure parameter, the statements related to the location information of the closure parameter in the original parameter in the compiled file do not change. In the generation of the patch file, the difference between the second compiled file and the first compiled file is reduced, thereby reducing the size of the patch file.

[0146] To reduce the complexity of patch generation, the differences between the first and second compiled files are identified on a function-by-function basis. Specifically, when identifying differences between the first and second compiled files, the system checks whether a function in the first compiled file exists in the second compiled file. If so, the system checks whether the function differs from the corresponding function in the second compiled file. If so, the function is identified as a difference function. If not, the function remains unchanged. When generating the patch file, the difference function is added to the patch file.

[0147] When the location information of a closure parameter changes, it not only affects the function in which it is located, but also causes changes in other functions that access the closure parameter. Therefore, when generating a patch file, if the location information of a closure parameter changes, the difference function determined will include not only the function in which the closure parameter is located, but also other functions that access the closure parameter. These other functions may have their logic unchanged.

[0148] In the prior art, when compiling an update file, the location information of the parameters contained therein is determined from preset initial values. If a closure parameter is deleted or added to a function in the update file relative to the original file, the location information of other closure parameters contained in that function in the compiled file of the update file will also change. As a result, when generating the patch file, the difference function determined will not only include the function in question, but also other functions that access other closure parameters in that function. These other functions may have the same logic, resulting in an excessively large patch file.

[0149] In an embodiment of the present application, when a function in an updated file contains deletions or additions of closure parameters relative to the original file, the compilation information table is referenced when compiling the updated file, so that the location information of the other closure parameters contained in the function in the second compiled file is the same as the location information in the first compiled file. In this way, other functions that access other closure parameters in the function are the same in the second compiled file and the first compiled file when their logic remains unchanged. In this case, when the patch file is generated, the difference function determined only includes the function, and does not include other functions that access other closure parameters in the function whose logic remains unchanged, thereby greatly reducing the size of the patch file.

[0150] For example, assume that the original file contains the original function f, which contains variables a, b, and c. Function f1 and f2 are nested within the original function f. Function f1 accesses variable a in the original function f. Function f2 accesses variable b in the original function f. Therefore, the original function f contains two closure parameters, variables a and b. As shown in Figure 7a, in the prior art, when the original file is compiled, the location information of the closure parameters contained therein is determined from a preset initial value. Assume that the initial preset value is position 0. When the original file is compiled, variable b is assigned location information at position 0, and variable b is assigned location information at position 1. The original file is modified to obtain an updated file of the original file. The updated file deletes function f1 from the original file. In the updated file, the closure parameter of function f is only variable b. When the updated file is compiled, the location information of the closure parameters contained therein is still determined from the preset initial value, and variable b is assigned location information at position 0. The location information of variable b has changed. When generating the patch file, the determined difference function includes not only the function f, but also the function f2 which accesses the variable b and whose logic remains unchanged, resulting in an excessively large patch file.

[0151] As shown in Figure 7b, in this embodiment of the present application, when compiling the update file, it is necessary to refer to the compilation information table so that the location information of variable b in the second compiled file is the same as the location information of variable b in the first compiled file, that is, the location information assigned to variable b is position 1. In this way, function f2 in the second compiled file is the same as the first compiled file. In this case, when generating the patch file, the difference function determined only includes function f, and does not include function f2, whose logic accesses variable b and remains unchanged, greatly reducing the size of the patch file.

[0152] As a possible implementation manner, compiling the update file according to the compilation information table to generate the second compiled file includes:

[0153] The target positioning information of the original parameter in the update file is determined according to the compilation information table; the target positioning information of the original parameter is used as the positioning information of the original parameter in the second compilation file, and the update file is compiled to generate a second compilation file.

[0154] The target positioning information of the original parameter is the positioning information of the original parameter in the first compiled file.

[0155] In an embodiment of the present application, the target function of the updated file can be compared with the original function of the original file to determine the parameters contained in both the target function and the original function, that is, to determine the original parameters. The compilation information table records the location information of the parameters contained in the original function in the first compiled file. Therefore, the location information of the original parameters in the first compiled file can be determined based on the compilation information table, that is, to determine the target location information of the original parameters. When compiling the updated file, the target location information of the original parameters is determined as the location information of the original parameters in the second compiled file, and compilation is performed to generate a second compiled file. In this way, the location information of the original parameters in the second compiled file is the same as the location information of the original parameters in the first compiled file.

[0156] As a possible implementation method, when the update file includes an initial nested function, the second compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and at least one outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the update file, and the second name is used to identify the function name of the outer function in the update file.

[0157] As a possible implementation, the second name is the function name of the outer function in the target nested function.

[0158] As a possible implementation, if the inner function has a function name in the initial nested function, the first name includes the compiled value of the function name of the inner function in the initial nested function.

[0159] As a possible implementation, the first name is set by a named function corresponding to the outer function.

[0160] As a possible implementation method, when there are multiple outer functions, the outer functions correspond one-to-one to the named functions.

[0161] As a possible implementation, the named function includes a named variable; the value of the named variable is related to the number of inner functions in the outer function that have been given a first name by the named function.

[0162] As a possible implementation, the value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name through the named function and 1.

[0163] As one possible implementation, the first name includes the value of the named variable.

[0164] As a possible implementation, if the inner function is an anonymous function in the initial nested function, the first name is set by the named function corresponding to the outer function.

[0165] As a possible implementation method, when the update file includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of the special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled value of the function name of other functions; other functions include the outer function and / or non-nested function of the outermost nested function in other initial nested functions.

[0166] For details, please refer to steps S301-S302 and will not be repeated here.

[0167] See Figure 8, which is a flow chart of a compilation method provided in an embodiment of the present application. As shown in Figure 8, the method includes:

[0168] Step 801: Compile the original file to generate a first compiled file and a compilation information table.

[0169] In the embodiment of the present application, it is necessary to obtain the compilation information table of the original file. In the process of compiling the original file, the positioning information is allocated to the parameters contained in the original function in the original file and recorded in the compilation information table of the original file.

[0170] As a possible implementation method, when the original file includes an initial nested function, the first compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the original file, and the second name is used to identify the function name of the outer function in the original file.

[0171] As a possible implementation, the second name is the function name of the outer function in the target nested function.

[0172] As a possible implementation, if the inner function has a function name in the initial nested function, the first name includes the compiled value of the function name of the inner function in the initial nested function.

[0173] As a possible implementation, the first name is set by a named function corresponding to the outer function.

[0174] As a possible implementation method, when there are multiple outer functions, the outer functions correspond one-to-one to the named functions.

[0175] As a possible implementation, the named function includes a named variable; the value of the named variable is related to the number of inner functions in the outer function that have been given a first name by the named function.

[0176] As a possible implementation, the value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name through the named function and 1.

[0177] As one possible implementation, the first name includes the value of the named variable.

[0178] As a possible implementation, if the inner function is an anonymous function in the initial nested function, the first name is set by the named function corresponding to the outer function.

[0179] As a possible implementation method, when the original file includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of the special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled value of the function name of other functions; other functions include the outer function and / or non-nested function of the outermost nested function in other initial nested functions.

[0180] For details, please refer to steps S301-S302 and will not be repeated here.

[0181] Step 802: Obtain the update file of the original file and the compilation information table of the original file.

[0182] For details, please refer to step S601 and no further details will be given here.

[0183] Step 803: Compile the update file according to the compilation information table to generate a second compiled file.

[0184] For details, please refer to step S602 and will not be repeated here.

[0185] As shown in FIG9 , the original file is compiled to generate a first compiled file and a compilation information table. The updated file is compiled according to the compilation information table to generate a second compiled file. A patch file is generated based on the differences between the first compiled file and the second compiled file. The differences between the first compiled file and the second compiled file can be identified to generate a patch file. If the compilation information table can also record other information during the compilation process, such as function information, then the patch file can also be generated using the compilation information table of the original file and the second compiled file, and this application does not impose any restrictions on this.

[0186] Referring to Figure 10, there is shown a schematic diagram of the structure of a compilation device provided in an embodiment of the present application. As shown in Figure 10, the device includes:

[0187] The acquisition unit 1001 is used to acquire the file to be compiled.

[0188] The file to be compiled includes an initial nested function; the initial nested function includes an inner function and at least one outer function located outside the inner function.

[0189] The compiling unit 1002 is used to compile the file to be compiled to generate a compiled file.

[0190] Among them, the compiled file includes a target nested function, which is a function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled.

[0191] As a possible implementation manner, the second name includes: the function name of the outer function in the compiled file.

[0192] As a possible implementation manner, if the inner function has a function name in the file to be compiled, the first name includes: a compiled value of the function name of the inner function in the file to be compiled.

[0193] As a possible implementation manner, the first name includes: a function name set for the inner function by a named function corresponding to the outer function.

[0194] As a possible implementation method, when the file to be compiled contains multiple outer functions, the outer functions correspond one-to-one to the named functions.

[0195] As a possible implementation, the named function includes a named variable; the value of the named variable is related to the number of inner functions in the outer function that have been given a first name by the named function.

[0196] As a possible implementation, the value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name through the named function and 1.

[0197] As a possible implementation, the function name set for the inner function by the named function corresponding to the outer function includes the value of the named variable.

[0198] As a possible implementation method, the inner function is an anonymous function in the file to be compiled.

[0199] As a possible implementation method, when the file to be compiled includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compilation value of the special character, and the compilation value of the special character is used to distinguish the function name of the inner function from the compilation value of the function name of other functions; other functions include the outer function and / or non-nested function of the outermost nested function in other initial nested functions.

[0200] Referring to Figure 11, there is shown a schematic diagram of the structure of a compilation device provided in an embodiment of the present application. As shown in Figure 11, the device includes:

[0201] The acquiring unit 1101 is configured to acquire an update file of an original file and a compilation information table of the original file.

[0202] Among them, the compilation information table is used to record the positioning information of the parameters contained in the original function in the first compilation file, the first compilation file is the compilation file of the original file, and the original function is the function in the original file; the update file includes the target function, the target function is the update function of the original function, and the target function includes the original parameters; the original parameters refer to the parameters contained in both the original function and the target function.

[0203] The compiling unit 1102 is configured to compile the update file according to the compilation information table to generate a second compiled file.

[0204] The positioning information of the original parameter in the second compiled file is the same as the positioning information of the original parameter in the first compiled file.

[0205] As a possible implementation manner, the compiling unit 1102 is further configured to compile the original file to generate a first compiled file and a compilation information table.

[0206] As a possible implementation manner, the parameters included in the original function include the closure parameters of the original function.

[0207] As a possible implementation, the compilation unit 1102 is specifically configured to determine target positioning information of original parameters in the update file based on the compilation information table, where the target positioning information of the original parameters is positioning information of the original parameters in the first compilation file; and compile the update file using the target positioning information of the original parameters as positioning information of the original parameters in the second compilation file to generate the second compilation file.

[0208] As a possible implementation method, when the update file includes an initial nested function, the second compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the update file, and the second name is used to identify the function name of the outer function in the update file.

[0209] As a possible implementation method, when the original file includes an initial nested function, the first compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the original file, and the second name is used to identify the function name of the outer function in the original file.

[0210] As a possible implementation, the second name is the function name of the outer function in the target nested function.

[0211] As a possible implementation, if the inner function has a function name in the initial nested function, the first name includes the compiled value of the function name of the inner function in the initial nested function.

[0212] As a possible implementation, the first name is set by a named function corresponding to the outer function.

[0213] As a possible implementation method, when there are multiple outer functions, the outer functions correspond one-to-one to the named functions.

[0214] As a possible implementation, the named function includes a named variable; the value of the named variable is related to the number of inner functions in the outer function that have been given a first name by the named function.

[0215] As a possible implementation, the value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name through the named function and 1.

[0216] As one possible implementation, the first name includes the value of the named variable.

[0217] As a possible implementation, if the inner function is an anonymous function in the initial nested function, the first name is set by the named function corresponding to the outer function.

[0218] As a possible implementation method, when the original file or updated file includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of the special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled value of the function name of other functions; other functions include the outer function and / or non-nested function of the outermost nested function in other initial nested functions.

[0219] Corresponding to the above embodiments, the present application also provides an electronic device. Figure 12 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 1200 may include: a processor 1201, a memory 1202, and a communication unit 1203. These components communicate through one or more buses. Those skilled in the art will understand that the structure of the electronic device shown in the figure does not constitute a limitation on the embodiments of the present invention. It can be a bus structure or a star structure, and can also include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0220] The communication unit 1203 is configured to establish a communication channel so that the electronic device can communicate with other devices, receive user data sent by other devices, or send user data to other devices.

[0221] The processor 1201 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 1202, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 1201 can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.

[0222] The memory 1202 is used to store the execution instructions of the processor 1201. The memory 1202 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0223] When the execution instructions in the memory 1202 are executed by the processor 1201 , the electronic device 1200 is enabled to execute part or all of the steps in the embodiment shown in FIG. 3 or FIG. 6 .

[0224] In a specific implementation, the present invention further provides a computer storage medium, wherein the computer storage medium may store a program that, when executed, may include some or all of the steps of each embodiment of the compilation method provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0225] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus a necessary general-purpose hardware platform. Based on this understanding, the technical solutions in the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention or certain portions of the embodiments.

[0226] In this specification, reference can be made to the same or similar parts between the various embodiments. In particular, for the device embodiment and the terminal embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

Claims

1. A compilation method, It is characterized in that include: Obtain a file to be compiled; the file to be compiled includes an initial nested function; the initial nested function includes an inner function and an outer function outside the inner function; Compile the file to be compiled to generate a compiled file; wherein the compiled file includes a target nested function, which is a function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled.

2. The method according to claim 1, It is characterized in that The second name includes: the function name of the outer function in the compiled file.

3. The method according to claim 1, It is characterized in that If the inner function has a function name in the file to be compiled, the first name includes: a compiled value of the function name of the inner function in the file to be compiled.

4. The method according to claim 1, It is characterized in that The first name includes: a function name set for the inner function by a naming function corresponding to the outer function.

5. The method according to claim 4, It is characterized in that When the file to be compiled includes multiple outer functions, the outer functions correspond to the named functions one by one.

6. The method according to claim 4 or 5, It is characterized in that The naming function includes a naming variable; the value of the naming variable is related to the number of inner functions in the outer function that have been set with a first name by the naming function.

7. The method according to claim 6, It is characterized in that The value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name by the named function and 1.

8. The method according to claim 6 or 7, It is characterized in that The function name set for the inner function by the named function corresponding to the outer function includes the value of the named variable.

9. The method according to any one of claims 4 to 8, It is characterized in that The inner function is an anonymous function in the file to be compiled.

10. The method according to claim 1, It is characterized in that When the file to be compiled includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of a special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled values ​​of the function names of other functions; the other functions include the outer functions and / or non-nested functions of the outermost nested function in other initial nested functions.

11. A compilation method, It is characterized in that include: Obtaining an update file of an original file and a compilation information table of the original file; the compilation information table is used to record the location information of the parameters contained in the original function in the first compilation file, the first compilation file is the compilation file of the original file, and the original function is the function in the original file; the update file includes a target function, the target function is an update function of the original function, and the target function includes original parameters; the original parameters refer to the parameters contained in both the original function and the target function; The update file is compiled according to the compilation information table to generate a second compiled file; the positioning information of the original parameter in the second compiled file is the same as the positioning information of the original parameter in the first compiled file.

12. The method according to claim 11, It is characterized in that Before obtaining the update file of the original file and the compilation information table of the original file, the method further includes: The original file is compiled to generate a first compiled file and a compilation information table.

13. The method according to claim 11 or 12, It is characterized in that The original parameters include closure parameters.

14. The method according to any one of claims 11 to 13, It is characterized in that The compiling the update file according to the compilation information table to generate a second compiled file comprises: Determine the target positioning information of the original parameter in the update file according to the compilation information table; the target positioning information of the original parameter is the positioning information of the original parameter in the first compilation file; The target positioning information of the original parameter is used as the positioning information of the original parameter in the second compiled file, and the update file is compiled to generate a second compiled file.

15. The method according to any one of claims 11 to 14, It is characterized in that When the update file includes an initial nested function, the second compiled file includes a target nested function; wherein the target The nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function located outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the update file, and the second name is used to identify the function name of the outer function in the update file.

16. The method according to claim 12, It is characterized in that When the original file includes an initial nested function, the first compiled file includes a target nested function; wherein the target nested function is a function compiled from the initial nested function; the initial nested function includes an inner function and an outer function outside the inner function; the function name of the inner function in the target nested function includes a first name and a second name; the first name is used to identify the function name of the inner function in the original file, and the second name is used to identify the function name of the outer function in the original file.

17. The method according to claim 15 or 16, It is characterized in that The second name is the function name of the outer function in the target nested function.

18. The method according to claim 15 or 16, It is characterized in that If the inner function has a function name in the initial nested function, the first name includes the compiled value of the function name of the inner function in the initial nested function.

19. The method according to claim 15 or 16, It is characterized in that The first name is set by a naming function corresponding to the outer function.

20. The method according to claim 19, It is characterized in that When there are multiple outer functions, the outer functions correspond to the named functions one by one.

21. The method according to claim 19 or 20, It is characterized in that The naming function includes a naming variable; the value of the naming variable is related to the number of inner functions in the outer function that have been set with a first name by the naming function.

22. The method according to claim 21, It is characterized in that The value of the named variable is the sum of the number of inner functions in the outer function that have been given a first name by the named function and 1.

23. The method according to claim 21 or 22, It is characterized in that The first name includes a value of the named variable.

24. The method according to any one of claims 19 to 23, It is characterized in that If the inner function is an anonymous function in the initial nested function, the first name is set by a named function corresponding to the outer function.

25. The method according to claim 15 or 16, It is characterized in that When the original file or updated file includes multiple initial nested functions and / or non-nested functions, the function name of the inner function in the target nested function also includes the compiled value of a special character, and the compiled value of the special character is used to distinguish the function name of the inner function from the compiled values ​​of the function names of other functions; the other functions include the outer functions and / or non-nested functions of the outermost nested function in other initial nested functions.

26. A compiling device, It is characterized in that include: An acquisition unit, configured to acquire a file to be compiled; the file to be compiled includes an initial nested function; the initial nested function includes an inner function and at least one outer function outside the inner function; A compilation unit is used to compile the file to be compiled to generate a compiled file; wherein the compiled file includes a target nested function, which is a function compiled from the initial nested function; the function name of the inner function in the target nested function includes a first name, a second name and a separator between the two names; the first name is used to identify the function name of the inner function in the file to be compiled, and the second name is used to identify the function name of the outer function in the file to be compiled.

27. A compiling device, It is characterized in that include: an acquisition unit, configured to acquire an update file of an original file and a compilation information table of the original file; the compilation information table is configured to record location information of parameters contained in an original function in a first compilation file, the first compilation file is a compilation file of the original file, and the original function is a function in the original file; the update file includes a target function, the target function is an update function of the original function, and the target function includes original parameters; the original parameters refer to parameters contained in both the original function and the target function; A compiling unit is used to compile the update file according to the compiling information table to generate a second compiled file; the positioning information of the original parameter in the second compiled file is the same as the positioning information of the original parameter in the first compiled file.

28. An electronic device, It is characterized in that It comprises a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the method described in any one of claims 1-10 or to execute the method described in any one of claims 11-25.

29. A computer-readable storage medium, It is characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method described in any one of claims 1 to 10 or to execute the method described in any one of claims 11 to 25.

Citation Information

Patent Citations

  • Method for transforming switch special language into C language

    CN102222004A

  • Method and device for compiling functions

    CN107992307A

  • Function-compiling method, compile system and storage medium

    CN109308182A

  • Function injector

    US6996808B1

  • Systems and methods for generating and applying operating system live updates

    US9477461B1