Code packaging method and device, computer device and storage medium

By establishing a syntax tree in the H5 game to detect keyword types and determine the reference strategy, the error problem during subpackage loading was solved, and a stable and efficient subpackage process was achieved.

CN114489768BActive Publication Date: 2025-10-17NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210067638.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-20
Publication Date
2025-10-17
Estimated Expiration
2042-01-20

AI Technical Summary

Technical Problem

In H5 games, existing technologies are prone to errors when loading game codes in subpackages, resulting in unstable program operation and a lack of effective keyword reference strategies, which affects program operation.

Method used

The code is packaged by establishing a syntax tree, the keyword type is detected according to the syntax tree, the keyword reference strategy is determined, and a subpackage containing the keyword reference strategy is generated.

Benefits of technology

It improves the convenience and efficiency of subcontracting, ensures the normal operation of the program, reduces errors, and increases the flexibility and scalability of subcontracting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114489768B_ABST
    Figure CN114489768B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose code packaging methods and devices, computer equipment and storage media. Embodiments of the present application can obtain a code block in source code, convert the code block into a code syntax tree, traverse the code syntax tree, determine a target keyword, determine a reference strategy of the target keyword according to a keyword type of the target keyword, and determine a corresponding package of the code block according to the target keyword and the reference strategy of the target keyword. In the embodiments of the present application, the code is packaged by establishing a syntax tree, the keyword type can be detected according to the syntax tree, and the reference strategy of the keyword can be determined, so that the obtained package contains the reference strategy of the keyword, to facilitate normal operation of a program.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a code package method and device, computer equipment and storage medium. BACKGROUND

[0002] HTML5 (H5 for short) is a language description way of building web content. It is a specification of the core language HTML in the Web, and the page made based on the H5 standard can normally run on different terminals such as computers, mobile phones and tablet computers.

[0003] With the increasing popularity of H5 standard, there are more and more small games made by using H5 standard, and the game play is more and more rich, and the demand for the package size of H5 game is more and more strong, thereby generating the function of H5 game package loading. The so-called package loading is to split the game content into several packages according to certain rules. The necessary package is downloaded first when starting for the first time, and this necessary package is called the main package. Then other packages are triggered to load in the main package, thereby dispersing the download time of the first start to the game running.

[0004] In the H5 game, all keywords are in the same scope. Therefore, when the game code is divided into packages for loading, it is easy to make mistakes and affect the program running. SUMMARY

[0005] The code package method and device, computer equipment and storage medium provided by the present application can detect the keyword type and determine the reference strategy of the keyword by establishing a syntax tree for code package, so that the obtained package contains the reference strategy of the keyword, so as to make the program run normally.

[0006] The code package method provided by the present application comprises the following steps: obtaining a code block in source code; converting the code block into a code syntax tree; traversing the code syntax tree to determine a target keyword, the target keyword being a keyword meeting a preset keyword type and a preset scope; determining a reference strategy of the target keyword according to the keyword type of the target keyword; and determining a package corresponding to the code block according to the target keyword and the reference strategy of the target keyword.

[0007] The embodiment of the present application further provides a code packaging device, comprising: an acquisition unit, configured to acquire a code block in source code; a conversion unit, configured to convert the code block into a code syntax tree; a target keyword determination unit, configured to traverse the code syntax tree, and determine a target keyword, the target keyword being a keyword meeting a preset keyword type and a preset scope; a reference strategy determination unit, configured to determine a reference strategy of the target keyword according to the keyword type of the target keyword; and a packaging unit, configured to determine a packaging corresponding to the code block according to the target keyword and the reference strategy of the target keyword.

[0008] The embodiment of the present application further provides a computer device, comprising a memory storing a plurality of instructions; and a processor loading the instructions from the memory to execute the steps in any code packaging method provided by the embodiment of the present application.

[0009] The embodiment of the present application further provides a computer readable storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in any code packaging method provided by the embodiment of the present application.

[0010] The embodiment of the present application can acquire a code block in source code; convert the code block into a code syntax tree; traverse the code syntax tree, and determine a target keyword, the target keyword being a keyword meeting a preset keyword type and a preset scope; determine a reference strategy of the target keyword according to the keyword type of the target keyword; and determine a packaging corresponding to the code block according to the target keyword and the reference strategy of the target keyword. In the present application, the code block is converted into a code syntax tree, the target keyword is determined from different keyword types by traversing the code syntax tree, the keyword type is detected according to the syntax tree, and the reference strategy of the keyword is determined, so that the obtained packaging contains the reference strategy of the keyword, the convenience and efficiency of the packaging are improved, and the program can be normally run. BRIEF DESCRIPTION OF DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.

[0012] Figure 1 is a scene schematic diagram of the code packaging method provided by the embodiment of the present application;

[0013] Figure 2 is a flow schematic diagram of the code packaging method provided by the embodiment of the present application;

[0014] Figure 3 is a flowchart of a code packaging method provided by another embodiment of the present application;

[0015] Figure 4 is a structural diagram of a code packaging apparatus provided by an embodiment of the present application;

[0016] Figure 5 is a structural diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0017] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0018] Before the embodiments of the present application are explained in detail, some terms related to the embodiments of the present application are explained.

[0019] Packaging, refers to dividing a program into different sub-packs, and packaging into different sub-packs during construction, and loading by a user as needed during use.

[0020] Loading of the sub-packs, refers to loading at least one sub-pack as needed by a user when starting a program.

[0021] H5 game, refers to a game using an h5 technology responsive website layout.

[0022] The embodiments of the present application provide a code packaging method, apparatus, computer device and storage medium.

[0023] The code packaging apparatus can be integrated in an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, or a personal computer (PC), etc. The server can be a single server or a server cluster composed of multiple servers.

[0024] In some embodiments, the code packaging apparatus can also be integrated in multiple electronic devices, for example, the code packaging apparatus can be integrated in multiple servers, and the multiple servers can implement the code packaging method of the present application.

[0025] In some embodiments, the server can also be implemented in the form of a terminal.

[0026] For example, refer to Figure 1In some embodiments, a scenario diagram of a code packaging system is provided, which can implement code packaging. The system can include a terminal 1000, a server 2000, and a network 3000, the server 2000 and the terminal 1000 can perform data interaction through the network 3000.

[0027] The server is configured to obtain a code block in the source code, convert the code block into a code syntax tree, traverse the code syntax tree, determine a target keyword, the target keyword being a keyword satisfying a preset keyword type and a preset scope, determine a reference strategy of the target keyword according to a keyword type of the target keyword, and determine a packaging corresponding to the code block according to the target keyword and the reference strategy of the target keyword. The terminal is configured to obtain all the packagings of the program from the server, load the packagings, and run the program. The network is configured to perform data transmission between the server and the terminal, and can be a wireless network or a wired network, such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, and the like.

[0028] The following will be described in detail. It should be noted that the serial numbers of the following embodiments do not limit the preferred order of the embodiments.

[0029] In this embodiment, a code packaging method is provided, as shown in Figure 2 The specific process of the code packaging method can be as follows:

[0030] 110. Obtain a code block in the source code.

[0031] The source code refers to source code to be packaged, and can include all or part of the code text of the software. The code block refers to a code region in the source code, which can be a piece of code enclosed by "{}", or a piece of code divided according to software function modules.

[0032] It should be noted that when there are multiple code blocks in the source code in the present application, a code block of the source code is obtained in step 110, and steps 120-150 are performed on the code block to obtain a packaging corresponding to the code block. Steps 120-150 are performed on each code block respectively to obtain a packaging corresponding to each code block, so as to implement packaging of the entire source code.

[0033] In some embodiments, in order to reduce the coupling between the packagings and increase the stability during loading of the packagings, before step 110, the method further includes: dividing the source code into multiple code blocks according to a function module corresponding to the source code.

[0034] The function module refers to a function module of a program corresponding to the source code. Before obtaining any code block in the source code, the code of each function module is divided into a code block according to the function requirement of the program corresponding to the source code. For example, an H5 software program with login and user information recording functions can include a login module and a user information module.

[0035] In some embodiments, the embodiments of the present application can be applied to a modular H5 software program, for example, a small game program based on a social platform software. In step 110, the code block corresponding to any function module of the small game program can be directly obtained.

[0036] 120, converting the code block into a code syntax tree.

[0037] The code syntax tree refers to an abstract syntax tree obtained by converting the code, which is a tree representation of the abstract syntax structure of the source code. Each node on the tree represents a structure in the source code.

[0038] In some embodiments, step 120 can include steps 1.1-1.2, as follows:

[0039] 1.1, performing lexical analysis on the code block to obtain a plurality of lexical units;

[0040] 1.2, performing syntax analysis on the plurality of lexical units to generate a code syntax tree.

[0041] The lexical analysis is a process of converting a character sequence in the code block into a word (Token) sequence. The lexical unit refers to a word obtained by converting the character sequence. The task of syntax analysis is to combine the word sequence into various syntax phrases, such as "program", "statement", "expression", and the like, on the basis of lexical analysis. The code syntax tree, i.e., the abstract syntax tree, is an abstract representation of the code block structure, which is a conversion of the lexical unit into a tree representing the syntax structure of the program, which is composed of elements nested at each level.

[0042] By performing lexical analysis and syntax analysis on the code block, a code syntax tree is generated, so as to perform checking, analysis and other operations on the code through the code syntax tree.

[0043] 130, traversing the code syntax tree to determine a target keyword, the target keyword being a keyword meeting a preset keyword type and a preset scope.

[0044] The keyword refers to a keyword on an abstract syntax tree. The keyword types on the abstract syntax tree include variable declaration, function declaration, class declaration, protocol declaration, assignment expression, keyword expression, private variable expression, comment section, parameter definition, text, function protocol type, declaration attribute, and the like. The preset keyword type refers to one or more preset keyword types, which can include but is not limited to at least one of the keyword types on the abstract syntax tree. The specific preset type can be set as needed.

[0045] The scope refers to the available range of the keyword. The preset scope refers to the preset available range of the keyword. The preset scope can include but is not limited to at least one of a global scope or a block scope. The global scope refers to the available range of the keyword being the entire source code. The block scope refers to the available range of the keyword being the code block in which the keyword is located.

[0046] By traversing each node on the code syntax tree, if the node is associated with a keyword, it is determined whether the keyword is a target keyword according to the preset keyword type and the preset scope. The keyword with the preset keyword type and the preset scope is determined as the target keyword. The target keyword is determined from the multiple keywords on the code syntax tree, so as to find the keywords that may be referenced in the package process, thereby facilitating the determination of the reference strategy for these keywords in the subsequent steps.

[0047] In some embodiments, in order to identify all keywords that meet the preset keyword type, when the preset keyword type includes multiple keyword types, the keyword that meets any one of the multiple keyword types is determined as the target keyword. In some embodiments, the preset keyword type includes variable declaration, function declaration, class declaration, and assignment expression.

[0048] In some embodiments, in order to enable the reference strategy to represent the collaboration relationship between the packages, the preset scope can be the global scope.

[0049] 140. According to the keyword type of the target keyword, a reference strategy of the target keyword is determined.

[0050] The reference strategy refers to a strategy in which the target keyword is referenced. The reference strategy can also be understood as an available range of the target keyword after the package is divided. For example, when the code block is a piece of code divided according to program function modules, the reference strategy can be a strategy in which the target keyword can be acquired by all or part of the function modules, or the reference strategy is a strategy in which the target keyword is acquired by all or part of the packages during loading of the package, and the like. In some embodiments, the reference strategy can further include a position of the reference strategy corresponding code in the code block or a reference order, and the like. For example, when the code block is a piece of code divided according to the package, the reference strategy can include a reference range in which the target keyword can be acquired by all the modules corresponding to the packages, and can further include a position of adding the reference strategy corresponding code in the code block in which the target keyword is located. The position can be set according to actual needs, for example, can be a head, tail or any position in the middle of the code block.

[0051] After the target keyword is determined, the reference strategy of the target keyword is determined through the keyword type of each target keyword. The determination method of the reference strategy can be to determine different reference strategies for different types of keywords. For example, when the preset keyword type includes variable declaration, function declaration, class declaration and assignment expression, the reference strategy of the variable declaration is determined as a global reference strategy, so that it can be acquired by all the packages during loading of the package. The reference strategies of the function declaration, the class declaration and the assignment expression are determined as partial reference strategies, so that they are acquired by part of the packages during loading of the package. The specific reference strategy can be set as needed.

[0052] In some embodiments, the reference strategy includes a global reference strategy and a block reference strategy, the preset keyword type includes a preset keyword sub-type, and step 140 can include steps 2.1-2.2, as follows:

[0053] 2.1, determining the reference strategy of the target keyword as a global reference strategy;

[0054] 2.2, when the keyword type of the target keyword meets the preset keyword sub-type, and when the assignment of the target keyword meets the preset value, determining the reference strategy of the target keyword as a block reference strategy.

[0055] The global reference strategy refers to that the target keyword can be acquired by all sub-packages or function modules, and the block reference strategy refers to that the target keyword can be acquired by the sub-package or function module corresponding to the current code block. The preset keyword sub-type is at least one of the preset keyword types, can include all or part of the preset keyword types, and can be specifically set as needed. For example, when the preset keyword types include variable declaration, function declaration, class declaration, and assignment expression, the preset keyword sub-type includes variable declaration. The assignment of the target keyword refers to the assignment of the variable in the target keyword. The preset value can be that the variable in the target keyword is assigned or not assigned, or the assignment of the variable in the target keyword satisfies a preset numerical size. In some embodiments, when the target keyword has no variable, that is, the assignment of the target keyword does not satisfy the preset value.

[0056] In the process of determining the reference strategy of the target keyword, the reference strategy of the target keyword is first determined as the global reference strategy, and when the keyword type of the target keyword is the preset keyword sub-type, the target keyword is judged again to determine the reference strategy as the block reference strategy. At this time, the reference strategy of the target keyword has two kinds, that is, the global reference strategy and the block reference strategy.

[0057] In step 130, the target keyword is screened out through the preset keyword type and the preset scope, and the reference strategy of the target keyword is determined as the global reference strategy, so as to determine all keywords that can be globally referenced through two steps. Then, the keyword that can be referenced by the sub-package or module corresponding to the code block is determined from the target keyword. In this embodiment, the reference strategy is divided into the global reference strategy and the block reference strategy, so that the target keyword can only be referenced by all sub-packages or modules or the sub-package or module corresponding to the code block where the target keyword is located. In this way, the reference rule of the target keyword is determined, the coupling relationship between sub-packages is clarified by the global reference strategy, the reference relationship in the code block is clarified by the block reference strategy, and the stability of program running when the sub-package is loaded is increased.

[0058] In some embodiments, in order to further clarify the coupling relationship between sub-packages and the reference relationship in the code block, the preset keyword type includes at least one of variable declaration, function declaration, class declaration, and assignment expression.

[0059] The variable declaration refers to indicating the type and name of the variable to the program. The function declaration refers to informing the name, type, and argument type, number, and order of the function to the compiling system, so that the system performs the check according to the function when the function is called. The class is an abstraction of an object, and is a user-defined data type. If the class type is used in the program, it must be declared. The class declaration refers to declaring the existence of the class in the header file. The assignment expression refers to an expression containing a variable and an assignment operator.

[0060] In some embodiments, the preset keyword sub-type includes a variable declaration, and step 2.2 can include step 2.2.1, as follows:

[0061] 2.2.1, when the keyword type of the target keyword is a variable declaration, and when the assignment of the variable declaration satisfies the preset value, the reference strategy of the target keyword includes the block reference strategy.

[0062] In some embodiments, the preset value is that the variable in the keyword is not assigned.

[0063] By determining the reference strategy of the variable declaration whose assignment satisfies the preset value as the block reference strategy, since the reference strategy of the variable declaration is first determined as the global reference strategy, different reference strategies can be performed on the variable declaration in the process of loading the package corresponding to the two different reference strategies. For example, in some embodiments, the execution order of the global reference strategy and the block reference strategy can be determined to determine the order in which the target keyword is referenced in the process of loading the package. In some embodiments, the reference priority of the block reference strategy is higher than that of the global reference strategy, that is, in the process of loading the package, the package or module corresponding to the code block first acquires the target keyword with the reference strategy of the block reference strategy to ensure that the package can be successfully loaded, and then all the packages can acquire the target keyword with the reference strategy of the global reference strategy to couple different packages, so that the program can run normally.

[0064] 150, determining the package corresponding to the code block according to the target keyword and the reference strategy of the target keyword.

[0065] The package refers to a unit for compiling and installing composed of a code block. The package corresponding to the code block can include the code block, the target keyword, and the reference strategy of the target keyword, or can only include the code block and the reference strategy of the target keyword, etc.

[0066] In some embodiments, in order to facilitate the acquisition of the target keyword, the reference strategy corresponding to the target keyword is added to the code block to obtain the package corresponding to the code block.

[0067] In some embodiments, step 150 can include steps 3.1-3.2, as follows:

[0068] 3.1, obtaining identification information of the target keyword;

[0069] 3.2, determining the package corresponding to the code block according to the identification information of the target keyword and a reference strategy of the target keyword.

[0070] The identification information of the target keyword refers to information capable of representing the target keyword, and can include all information of the target keyword or part of feature information of the target keyword, such as a name, a variable assignment, a numerical value type, a variable type, and the like. The identification information of different types of target keywords can be different. When the target keyword is a variable declaration, the identification information can be a variable name. When the target keyword is a function declaration, the identification information can be a function declaration. When the target keyword is a class declaration, the identification information can be a class name. When the target keyword is an assignment expression, the identification information can be a variable name on the left side of the assignment expression.

[0071] By obtaining the identification information of the target keyword, the identification information is used to represent the target keyword, which simplifies the length of the target keyword information carried in the package and increases the readability of the package code.

[0072] In some embodiments, the step 150 can include a step of determining the package corresponding to the code block according to the reference strategy of the target keyword. Specifically, the reference strategy of the target keyword can be added to the package corresponding to the code block. The adding manner can be to add a code corresponding to the reference strategy in the code block, or a code file can be separately established to store the reference strategy. In some embodiments, the execution priority of the block reference strategy is higher than that of the global reference strategy. The execution priority refers to the order of code execution during program running, and the code with high priority is executed before the code with low priority. In some embodiments, the reference strategy of the target keyword includes the identification information of the target keyword. By determining that the execution priority of the block reference strategy is higher than that of the global reference strategy, the target keyword corresponding to the block reference strategy is called first, and the target keyword corresponding to the global reference strategy is called later, which is beneficial to the loading process of the package and can increase the flexibility of the package.

[0073] In some embodiments, the reference strategy includes the global reference strategy and the block reference strategy, and between the steps 3.1 and 3.2, steps 3.1.1-3.1.2 can be included, as follows:

[0074] 3.1.1, when the reference strategy of the target keyword is the global reference strategy, loading the identification information of the target keyword in the first queue;

[0075] 3.1.2, when the reference strategy of the target keyword is the block reference strategy, loading the identification information of the target keyword in the second queue.

[0076] The queue refers to a linear table used for storing data, the first queue refers to a linear table used for storing keyword identification information of the global reference strategy, and the second queue refers to a linear table used for storing keyword identification information of the block reference strategy. The first queue and the second queue can be established before the start of the packet, or can be established during the packet process, and can be set according to actual needs. The identification information of the target keyword can be sequentially stored in the queue according to the time sequence of acquisition, or can be stored in batches according to the set order after acquiring the identification information of all target keywords.

[0077] Since there are usually multiple target keywords satisfying the preset keyword type and the preset scope on the code syntax tree, by respectively storing the keyword identification information corresponding to different reference strategies in the first queue and the second queue, all target keywords with the same reference strategy can be stored in the same position, the classification storage of the target keywords is realized, the target keyword information corresponding to all global reference strategies or block reference strategies is conveniently called once, and the packet efficiency is improved.

[0078] In some embodiments, when the reference strategies of part of the keywords include both the global reference strategy and the block reference strategy, the reference strategies of the part of the keywords are stored in the first queue and the second queue at the same time.

[0079] In some embodiments, step 3.2 can include steps 3.2.1-3.2.3, as follows:

[0080] 3.2.1, traversing the first queue to determine the first reference strategy, the first reference strategy being used to represent the global reference strategy;

[0081] 3.2.2, traversing the second queue to determine the second reference strategy, the second reference strategy being used to represent the block reference strategy;

[0082] 3.2.3, determining the packet corresponding to the code block, the packet corresponding to the code block including the code block, the first reference strategy, and the second reference strategy.

[0083] The reference code refers to code for determining the reference range of the target keyword, and the code information can include the target keyword or the identification information of the target keyword, and the reference strategy corresponding to the target keyword. The first reference strategy includes all target keyword identification information in the first queue and the corresponding global reference strategy. The second reference strategy includes all target keyword identification information in the second queue and the corresponding block reference strategy. The first reference strategy and the first reference strategy can be added to the packet corresponding to the code block, and the adding mode can be to increase the code corresponding to the reference strategy in the code block, or to separately establish a code file for storing the reference strategy, etc.

[0084] By traversing the first queue and the second queue, the identification information of all target keywords in the first queue and the corresponding block reference strategy can be added as the first reference strategy to the corresponding package of the code block, and the identification information of all target keywords in the second queue and the corresponding global reference strategy can be added as the second reference strategy to the corresponding package of the code block, so that the obtained package contains all target keyword reference strategy information, and the corresponding target keyword can be quickly obtained through the identification information of the target keyword contained in the first reference strategy and the second reference strategy in the package. In the prior art, the package is usually not modified at will, especially in the H5 program, all declarations and variables are in the same scope, and when the package is modified, all code contents usually need to be traversed to reconfigure the scope rules. In the present application, only the reference strategy and the corresponding code content need to be modified to modify the package, and when the package is to be split or merged, it can also be quickly completed, thereby increasing the scalability and flexibility of the package.

[0085] In some embodiments, the execution priority of the second reference strategy is higher than that of the first reference strategy. The execution priority refers to the order of execution of the strategies during program running, and the strategy with high priority is executed before the strategy with low priority. By setting the execution priority, the information identification corresponding to the keyword in the declaration queue is preferentially obtained from the block scope during package loading, so as to facilitate the current code block corresponding module to obtain data, expose the information identification corresponding to the keyword in the queue to the global, so that other modules can obtain the keyword, and the keyword is obtained after the keyword is added at the tail of the current code block corresponding module.

[0086] In some embodiments, step 3.2.3 can include steps 3.2.3.1-3.2.3.3, as follows:

[0087] 3.2.3.1, adding the first reference strategy at the bottom of the code block;

[0088] 3.2.3.2, adding the second reference strategy at the top of the code block;

[0089] 3.2.3.3, obtaining the corresponding package of the code block.

[0090] The bottom of the code block is the tail of the code block, and the top of the code block is the top of the code block. During program running, the code is generally executed from the top to the tail, therefore, the second reference strategy added at the top of the code block is executed before the first reference strategy. The first reference strategy and the second reference strategy can be embodied in the form of code. For example, the first reference strategy can be added after the code block, the second reference strategy can be added before the code block, or the first reference strategy can be added in the second half of the code block, and the second reference strategy can be added in the first half of the code block, etc.

[0091] By adding different reference strategies at the beginning and end of the code block respectively, the target keyword corresponding to the block reference strategy is called first, and the target keyword corresponding to the global reference strategy is called last, which is beneficial to the loading process of the subpackage and can also increase the flexibility of the subpackage.

[0092] The code subpackage solution provided in the embodiments of the present application can be applied in various code subpackage scenarios. For example, taking an H5 program as an example, in the prior art, especially in an H5 game, there is no modularization concept, and all variable and function declarations are in the same scope, so that problems occur when the game code is loaded in subpackages. If the script code is added with a modularization function, the separate files have separate scopes, which will also cause that the declared variables and functions cannot be directly obtained between subpackages.

[0093] In the prior art, subpackages are often configured through a configuration module or a regular expression, and the configuration process is tedious and prone to errors. However, in the embodiments of the present application, the code blocks in the H5 program code are obtained, the code blocks are converted into a code syntax tree, the code syntax tree is traversed, the target keyword is determined, the target keyword is a keyword that meets a preset keyword type and a preset scope, the reference strategy of the target keyword is determined according to the keyword type of the target keyword, the subpackage corresponding to the code block is determined according to the target keyword and the reference strategy of the target keyword, and all the code blocks in the H5 program code are processed in sequence to implement the subpackage of the H5 program. In the subpackage process, the code blocks are converted into the code syntax tree, the target keyword is determined from different keyword types by traversing the code syntax tree, and the subpackage is not configured through a regular expression, so as to reduce the error situation, and the additional configuration module is not required in the subpackage process, thereby improving the convenience and efficiency of the subpackage.

[0094] As can be seen from the above, the embodiments of the present application can detect the keyword type and determine the reference strategy of the keyword according to the syntax tree, so that the obtained subpackage contains the reference strategy of the keyword, to facilitate the normal operation of the program.

[0095] According to the method described in the above embodiments, the following will be further described in detail.

[0096] In this embodiment, the method of the present application will be described in detail by taking an H5 game as an example.

[0097] As Figure 3 shown, a code subpackage method specifically includes the following steps:

[0098] 210, performing lexical analysis on the code block, and decomposing the characters in the string into a plurality of lexical units.

[0099] Before step 210, a step of obtaining a code block in source code can be included. The H5 game has multiple modules, and the obtained code block corresponds to a module of the H5 game.

[0100] 220, syntax analysis is performed on the multiple lexical units to convert the code block into a code syntax tree composed of elements nested at different levels.

[0101] 230, the code syntax tree is traversed, and a keyword is detected according to a preset keyword type.

[0102] The preset keyword type includes variable declaration, function declaration, class declaration, and expression. The process of detecting the keyword can include determining whether the keyword is the target keyword in the foregoing embodiments, and if so, further determining the reference strategy of the keyword. If the reference strategy of the keyword is a global reference strategy, the identification information of the keyword is placed in an exposure queue (equivalent to the first queue in the foregoing embodiments). If the reference strategy of the keyword is a block reference strategy, the identification information of the keyword is placed in a declaration queue (equivalent to the second queue in the foregoing embodiments). The specific judgment rules and processes can refer to steps 241-272 of the present embodiment. The execution process of steps 241-242 can be that, in the process of traversing the code syntax tree, the judgment processes of 241-272 are sequentially executed on the keywords on the code syntax tree in the order of traversal, and the identification information of the keywords meeting the corresponding reference strategy is sequentially placed in the exposure queue or the declaration queue.

[0103] For example, step 230 obtains a code syntax tree with n nodes, and the code syntax tree is traversed from node 1 to node n in turn, and the judgment process is executed according to steps 241-272. For example, the keyword type of node 3 is variable declaration, and steps 241-244 are executed. If the variable declaration is placed in the exposure queue and the declaration queue at the end of the execution, the next node 4 is judged. If the keyword type of node 4 is protocol declaration, which does not belong to the preset keyword type, no operation is performed, and the next node 5 is judged. If the keyword type of node 5 is function declaration, and the scope is global scope, the function name of the function declaration is placed in the exposure queue, and the next node 6 is judged. In this way, the judgment of all nodes is completed, and steps 280-290 are executed.

[0104] 241, when the keyword type is variable declaration, it is judged whether the scope of the variable declaration is global scope.

[0105] At this time, when the scope of the variable declaration is global scope, the variable declaration can be determined as the target keyword, and step 242 is executed. If not, no operation is performed.

[0106] 242. If so, obtain the variable name declared for the variable and put the variable name into the exposure queue.

[0107] Before putting the variable name into the exposure queue, the process may further include the following steps: determining whether the variable name exists in the exposure queue; if so, putting the variable name into the exposure queue; if not, not performing any operation.

[0108] 243. Determine whether the variable in the variable declaration has been assigned a value.

[0109] If yes, execute step 244; if no, do not execute the operation.

[0110] 244. If so, put the variable name of the variable declaration into the declaration queue.

[0111] Before putting the variable name into the declaration queue, the step may also be included: determining whether the variable name exists in the declaration queue, if so, putting the variable name into the declaration queue, if not, not performing the operation.

[0112] 251. When the keyword type is a function declaration, determine whether the scope of the function declaration is the global scope.

[0113] At this time, when the scope of the function declaration is the global scope, the function declaration can be determined as the target keyword and step 252 is executed. Otherwise, no operation is performed.

[0114] 252. If so, obtain the function name declared by the function and put the function name into the exposure queue.

[0115] Before putting the function name into the exposure queue, the method may further include the following steps: determining whether the function name exists in the exposure queue; if so, putting the function name into the exposure queue; if not, not performing any operation.

[0116] 261. When the keyword type is a class declaration, determine whether the scope of the class declaration is the global scope.

[0117] At this time, when the scope of the class declaration is the global scope, the class declaration can be determined as the target keyword and step 262 is executed. Otherwise, no operation is performed.

[0118] 262. If so, obtain the class name declared by the class and put the class name declared by the class into the exposure queue.

[0119] Before putting the class name into the exposure queue, the method may further include the following steps: determining whether the class name exists in the exposure queue; if so, putting the class name into the exposure queue; if not, not performing any operation.

[0120] 271. If the keyword type is an assignment expression, determine whether the assignment expression is in global scope.

[0121] At this time, if the assignment expression is in global scope, the assignment expression can be determined as the target keyword, and step 272 is executed. If not, no operation is performed. In determining that the keyword type is an assignment expression, it can be determined first whether the keyword type is an expression, and if so, it is further determined whether it is an assignment expression.

[0122] 272. If so, the variable name on the left side of the assignment operator in the assignment expression is obtained, and the variable name is put into the exposure queue.

[0123] Before putting the assignment expression into the exposure queue, a step of determining whether the assignment expression exists in the exposure queue can also be included. If so, the class name is put into the exposure queue. If not, no operation is performed.

[0124] 280. The declaration queue is traversed, the second reference code is added at the top of the code block, and the exposure queue is traversed, and the first reference code is added at the bottom of the code block.

[0125] The second reference code is a second reference strategy in code form, and the first reference code is a first reference strategy in code form. When the identification information of the keyword is a variable name, the second reference code can be a code example of var{variable name}=global["{variable name}"]. By adding the second reference code corresponding to the declaration queue at the top of the code block, the information identification corresponding keyword in the declaration queue is obtained from the block scope in priority when the package is loaded, so as to facilitate the current code block corresponding module to obtain data. If the declaration queue stores variable names of n keywords, which are variable name 1, variable name 2, … variable name n, the second reference strategy is a block reference strategy containing n keywords, and the second reference code can be var{variable name 1, variable name 2, … variable name n}=global["{variable name 1, variable name 2, … variable name n}"]. When the identification information of the keyword is a variable name, the first reference code can be a code example of global["{variable name}"]={variable name}. If the exposure queue stores variable names of m keywords, which are variable name 1, variable name 2, … variable name m, the first reference strategy is a global reference strategy containing m keywords, and the first reference code can be global["{variable name 1, variable name 2, … variable name m}"]={variable name 1, variable name 2, … variable name m}. By adding the first reference code corresponding to the exposure queue at the bottom of the code block, the information identification corresponding keyword in the exposure queue is exposed to the global when the package is loaded, so that other modules can obtain the keyword, and the first reference code is added at the tail, so that the keyword is obtained by the current code block corresponding module, and then other modules obtain the keyword.

[0126] 290. Determine the code block corresponding to the package, the code block corresponding to the package includes the code block, the first reference code and the second reference code.

[0127] At this time, all codes including the second reference code, the first reference code and the original code block can be taken as the code block corresponding package, so that the package carries the reference strategy of the keyword, facilitates the loading process of the package, and also increases the flexibility of the package. By performing the above package process on all code segments of the H5 game, all packages of the H5 game are obtained.

[0128] As can be seen from the above, in the subpackaging process, the embodiment of the present application converts the code block into a code syntax tree, and by traversing the code syntax tree, the target keyword is determined from different keyword types, and there is no need to use regular expressions for subpackaging, thereby reducing errors and eliminating the need for additional configuration modules in the subpackaging process, thereby improving the convenience and efficiency of subpackaging. At the same time, by adding different reference strategies at the beginning and end of the code block, so that the keywords corresponding to the block reference strategy are called first, and the keywords corresponding to the global reference strategy are called later, it is beneficial to the subpackaging loading process and can also increase the flexibility of subpackaging. Since H5 games do not support independent subpackaging, by formulating reference strategies, the coordination between different subpackaging during the subpackaging loading process can also be improved.

[0129] To better implement the above method, the present application also provides a code subpackaging device, which can be integrated into an electronic device, such as a terminal, a server, or the like. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, or the like; the server can be a single server or a server cluster consisting of multiple servers.

[0130] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the specific integration of the code subpackaging device in the server as an example.

[0131] For example, Figure 4 As shown, the code subpackaging device may include an acquisition unit 310, a conversion unit 320, a target keyword determination unit 330, a reference strategy determination unit 340, and a subpackaging unit 350, as follows:

[0132] (1) Acquisition Unit 310

[0133] Used to get a code block in the source code.

[0134] In some implementations, before obtaining code blocks in the source code, the obtaining unit 310 is further configured to divide the source code into multiple code blocks according to the functional modules corresponding to the source code.

[0135] (2) Conversion Unit 320

[0136] Used to convert a code block into a code syntax tree.

[0137] In some embodiments, the conversion unit 320 is also used in steps 4.1 to 4.2 as follows:

[0138] 4.1. Perform lexical analysis on the code block to obtain multiple lexical units;

[0139] 4.2. Perform grammatical analysis on multiple lexical units and generate a code syntax tree.

[0140] (iii) the target keyword determining unit 330

[0141] The target keyword determining unit 330 is configured to traverse the code syntax tree, and determine a target keyword, the target keyword being a keyword satisfying a preset keyword type and a preset scope.

[0142] (iv) the reference strategy determining unit 340

[0143] The reference strategy determining unit 340 is configured to determine a reference strategy of the target keyword according to the keyword type of the target keyword.

[0144] In some embodiments, the reference strategy includes a global reference strategy and a block reference strategy, and the reference strategy determining unit 340 is further configured to perform steps 5.1-5.2 as follows:

[0145] 5.1, determining the reference strategy of the target keyword as the global reference strategy;

[0146] 5.2, when the keyword type of the target keyword satisfies a preset keyword sub-type, and when the assignment of the target keyword satisfies a preset value, determining the reference strategy of the target keyword as the block reference strategy.

[0147] In some embodiments, the preset keyword type includes at least one of a variable declaration, a function declaration, a class declaration, and an assignment expression.

[0148] In some embodiments, the preset keyword sub-type includes a variable declaration.

[0149] (v) the packaging unit 350

[0150] The packaging unit 350 is configured to determine a code block corresponding package according to the target keyword and the reference strategy of the target keyword.

[0151] In some embodiments, the packaging unit 350 is further configured to perform steps 6.1-6.2 as follows:

[0152] 6.1, obtaining identification information of the target keyword;

[0153] 6.2, determining the code block corresponding package according to the identification information of the target keyword and the reference strategy of the target keyword.

[0154] In some embodiments, the reference strategy includes a global reference strategy and a block reference strategy, and between steps 6.1 and 6.2, steps 6.1.1-6.1.2 can be included as follows:

[0155] 6.1.1, when the reference strategy of the target keyword is the global reference strategy, loading the identification information of the target keyword in a first queue;

[0156] 6.1.2, when the reference strategy of the target keyword is the block reference strategy, loading the identification information of the target keyword in the second queue.

[0157] In some embodiments, the reference strategy includes the global reference strategy and the block reference strategy, and step 6.2 can include steps 6.2.1-6.2.3 as follows:

[0158] 6.2.1, traversing the first queue to determine the first reference strategy, the first reference strategy being used to represent the global reference strategy;

[0159] 6.2.2, traversing the second queue to determine the second reference strategy, the second reference strategy being used to represent the block reference strategy;

[0160] 6.2.3, determining the package corresponding to the code block, the package corresponding to the code block including the code block, the first reference strategy and the second reference strategy.

[0161] In some embodiments, step 6.2.3 can include steps 6.2.3.1-6.2.3.3 as follows:

[0162] 6.2.3.1, adding the first reference strategy at the bottom of the code block;

[0163] 6.2.3.2, adding the second reference strategy at the top of the code block;

[0164] 6.2.3.3, obtaining the package corresponding to the code block.

[0165] In implementation, each of the above units can be implemented as an independent entity, or can be combined as the same or several entities, and the specific implementation of each of the above units can refer to the method embodiments above, which will not be repeated here.

[0166] As can be seen from the above, the code packaging apparatus of the embodiment includes an acquisition unit for acquiring a code block in source code; a conversion unit for converting the code block into a code syntax tree; a target keyword determination unit for traversing the code syntax tree to determine a target keyword, the target keyword being a keyword meeting a preset keyword type and a preset scope; a reference strategy determination unit for determining a reference strategy of the target keyword according to the keyword type of the target keyword; and a package determination unit for determining a package corresponding to the code block according to the target keyword and the reference strategy of the target keyword.

[0167] Therefore, in the embodiment of the present application, the code block is converted into a code syntax tree. By traversing the code syntax tree, the target keyword is determined from different keyword types. The keyword type can be detected based on the syntax tree and the keyword reference strategy can be determined, so that the obtained subpackage contains the keyword reference strategy, thereby improving the convenience and efficiency of subpackage so that the program can run normally.

[0168] Accordingly, an embodiment of the present application also provides a computer device, which may be a terminal or a server, and the terminal may be a smart phone, tablet computer, laptop computer, touch screen, game console, personal computer, personal digital assistant (PDA) and other terminal devices.

[0169] like Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device 400 includes a processor 410 having one or more processing cores, a memory 420 having one or more computer-readable storage media, and a computer program stored in the memory 420 and executable on the processor. The processor 410 is electrically connected to the memory 420. Those skilled in the art will appreciate that the computer device structure shown in the figure does not limit the computer device and may include more or fewer components than shown, or combine certain components, or arrange the components differently.

[0170] The processor 410 is the control center of the computer device 400. It uses various interfaces and lines to connect various parts of the entire computer device 400. By running or loading software programs and / or modules stored in the memory 420 and calling data stored in the memory 420, it executes various functions of the computer device 400 and processes data, thereby monitoring the computer device 400 as a whole.

[0171] In the embodiment of the present application, the processor 410 in the computer device 400 loads instructions corresponding to one or more application processes into the memory 420 according to the following steps, and the processor 410 runs the application stored in the memory 420 to implement various functions:

[0172] Obtain a code block in the source code; convert the code block into a code syntax tree; traverse the code syntax tree to determine a target keyword, where the target keyword is a keyword that meets a preset keyword type and a preset scope; determine a reference strategy for the target keyword based on the keyword type of the target keyword; determine a subpackage corresponding to the code block based on the target keyword and the reference strategy for the target keyword.

[0173] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0174] Optional, such as Figure 5 As shown, the computer device 400 further includes: a touch screen 430, a radio frequency circuit 440, an audio circuit 450, an input unit 460, and a power supply 470. Among them, the processor 410 is electrically connected to the touch screen 430, the radio frequency circuit 440, the audio circuit 450, the input unit 460, and the power supply 470 respectively. It can be understood by those skilled in the art that Figure 5 The computer device structure shown in the figure does not constitute a limitation to the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0175] The touch display screen 430 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 430 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the computer device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light emitting diode (OLED, Organic Light-Emitting Diode), etc. The touch panel can be used to collect the user's touch operations on or near it (such as the user uses any suitable object or accessory such as a finger, stylus, etc. on the touch panel or near the touch panel) and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 410, and can receive the command sent by the processor 410 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 410 to determine the type of touch event, and then the processor 410 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 430 to realize input and output functions. However, in some embodiments, the touch panel and the display panel can be used as two independent components to realize input and output functions. That is, the touch display screen 430 can also be used as part of the input unit 460 to realize the input function.

[0176] In the embodiments of the present application, the game application executed by the processor 410 generates a graphical user interface on the touch display screen 430, and the virtual scene in the graphical user interface includes at least one skill control area, and the skill control area includes at least one skill control. The touch display screen 430 is configured to present the graphical user interface and receive operation instructions generated by the user acting on the graphical user interface.

[0177] The radio frequency circuit 440 can be configured to transceive radio frequency signals to establish wireless communication with a network device or other computer device.

[0178] The audio circuit 450 can be configured to provide an audio interface between the user and the computer device through a speaker and a microphone. The audio circuit 450 can convert received audio data into an electrical signal and transmit the electrical signal to the speaker, which converts the electrical signal into an audible signal and outputs the audible signal. On the other hand, the microphone collects a sound signal and converts the sound signal into an electrical signal, which is received by the audio circuit 450 and converted into audio data. The audio data is output to the processor 410 for processing, and then transmitted to another computer device through the radio frequency circuit 440, or output to the memory 420 for further processing. The audio circuit 450 can also include a jack for connecting an external earphone to the computer device.

[0179] The input unit 460 can be configured to receive inputted digital, character information or user feature information (e.g., fingerprint, iris, face information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0180] The power supply 470 is configured to supply power to various components of the computer device 400. Optionally, the power supply 470 can be logically connected to the processor 410 through a power management system, so that the power management system can be used to manage charging, discharging, power consumption management and other functions. The power supply 470 can also include one or more direct current or alternating current power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and any other components.

[0181] Although Figure 5 The computer device 400 can also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which are not shown in the embodiments of the present application.

[0182] In the above embodiments, the description of each embodiment focuses on different aspects, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0183] As can be seen, the computer device provided in the embodiment can detect the keyword type and determine the reference strategy of the keyword according to the syntax tree, so that the obtained package contains the reference strategy of the keyword, and the convenience and efficiency of the package are improved, so that the program can be normally run.

[0184] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by related hardware controlled by the instructions, which can be stored in a computer readable storage medium and loaded and executed by a processor.

[0185] To this end, the embodiment of the present application provides a computer readable storage medium, which stores a plurality of computer programs. The computer programs can be loaded by a processor to execute the steps in any code packaging method provided by the embodiment of the present application. For example, the computer programs can execute the following steps:

[0186] Obtaining a code block in source code; converting the code block into a code syntax tree; traversing the code syntax tree to determine a target keyword, the target keyword being a keyword satisfying a preset keyword type and a preset scope; determining a reference strategy of the target keyword according to the keyword type of the target keyword; and determining a package corresponding to the code block according to the target keyword and the reference strategy of the target keyword.

[0187] The specific implementation of each operation can be referred to the foregoing embodiments, which will not be described here.

[0188] The storage medium can include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0189] Since the computer programs stored in the storage medium can execute the steps in any code packaging method provided by the embodiment of the present application, the beneficial effects of any code packaging method provided by the embodiment of the present application can be achieved. Details can be referred to the foregoing embodiments, which will not be described here.

[0190] The above describes in detail the code packaging method, device, storage medium and computer device provided by the embodiment of the present application. The specific examples are applied to explain the principle and implementation manner of the present application. The above embodiment is only used to help understand the method and its core idea of the present application. Meanwhile, for those skilled in the art, the specific implementation manner and application range can be changed according to the idea of the present application. In conclusion, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A code subpackaging method, characterized in that: include: Get a code block in the source code; Convert the code block into a code syntax tree; Traversing the code syntax tree to determine a target keyword, where the target keyword is a keyword that meets a preset keyword type and a preset scope; Determining a citation strategy for the target keyword according to the keyword type of the target keyword, wherein the citation strategy includes a global citation strategy and a block citation strategy; The subpackage corresponding to the code block is determined according to the target keyword and the reference strategy of the target keyword.

2. The code subpackaging method according to claim 1, wherein: Determining a citation strategy for the target keyword according to the keyword type of the target keyword includes: Determining the citation strategy of the target keyword as a global citation strategy; When the keyword type of the target keyword satisfies a preset keyword subtype, and when the value assigned to the target keyword satisfies a preset value, the reference strategy of the target keyword is determined to be a block reference strategy.

3. The code subpackaging method according to claim 2, wherein: The preset keyword type includes at least one of a variable declaration, a function declaration, a class declaration, and an assignment expression.

4. The code subpackaging method according to claim 2, wherein: The preset keyword subtype includes variable declaration.

5. The code subpackaging method according to claim 1, wherein: Determining a subpackage corresponding to the code block according to the target keyword and the reference strategy of the target keyword includes: Obtaining identification information of the target keyword; The subpackage corresponding to the code block is determined according to the identification information of the target keyword and the reference strategy of the target keyword.

6. The code subpackaging method according to claim 5, wherein: The reference strategy includes a global reference strategy and a block reference strategy, and the steps of obtaining the identification information of the target keyword and determining the subpackage corresponding to the code block according to the identification information of the target keyword and the reference strategy of the target keyword include: When the reference strategy of the target keyword is a global reference strategy, loading the identification information of the target keyword into a first queue; When the reference strategy of the target keyword is a block reference strategy, the identification information of the target keyword is loaded into the second queue.

7. The code subpackaging method according to claim 6, wherein: The determining, based on the identification information of the target keyword and the reference strategy of the target keyword, the subpackage corresponding to the code block includes: Traversing the first queue to determine a first citation strategy, where the first citation strategy is used to represent the global citation strategy; Traversing the second queue to determine a second quoting strategy, where the second quoting strategy is used to characterize the block quoting strategy; A subpackage corresponding to the code block is determined, where the subpackage corresponding to the code block includes the code block, the first reference strategy, and the second reference strategy.

8. The code subpackaging method according to claim 7, wherein: Determining the subpackage corresponding to the code block includes: Adding the first reference strategy to the bottom of the code block; Adding the second reference strategy to the top of the code block; Get the subpackage corresponding to the code block.

9. The code subpackaging method according to claim 1, wherein: Before obtaining the code block in the source code, the method further includes: The source code is divided into a plurality of code blocks according to the functional modules corresponding to the source code.

10. The code subpackaging method according to claim 1, wherein: The converting the code block into a code syntax tree comprises: Performing lexical analysis on the code block to obtain multiple lexical units; Performing grammatical analysis on the multiple lexical units to generate a code syntax tree.

11. A code subpackaging device, characterized in that: include: The acquisition unit is used to obtain a code block in the source code; A conversion unit, configured to convert the code block into a code syntax tree; a target keyword determining unit, configured to traverse the code syntax tree and determine a target keyword, wherein the target keyword is a keyword that satisfies a preset keyword type and a preset scope; a citation strategy determining unit, configured to determine a citation strategy for the target keyword according to the keyword type of the target keyword, wherein the citation strategy includes a global citation strategy and a block citation strategy; The subpackaging unit is configured to determine the subpackaging corresponding to the code block according to the target keyword and the reference strategy of the target keyword.

12. A computer device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the code subpackaging method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the code subpackaging method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Anti-confusion processing method, terminal, and computer device

    CN109033764A

  • Software structure visualization program and system

    JP2013156786A