Code processing method, device, electronic device and storage medium

By inserting dynamic AOP code into the code and using the mapping relationship table for dynamic brick insertion, the problem of low code brick insertion efficiency in the existing technology is solved, and dynamic insertion and efficient brick insertion during code execution are achieved.

CN112667245BActive Publication Date: 2024-10-18TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110057540.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-15
Publication Date
2024-10-18
Estimated Expiration
2041-01-15

AI Technical Summary

Technical Problem

The existing technology cannot dynamically insert code during the code execution process, resulting in low code insertion efficiency, and requires recompiling to implement brick insertion, which affects efficiency.

Method used

By inserting dynamic AOP code into the target code, the brick insertion code is judged and executed, new code is dynamically inserted, and recompilation is avoided. The mapping relationship between the dynamic AOP code and the brick insertion code is used for dynamic brick insertion.

Benefits of technology

It realizes the dynamic insertion of new code during code execution, improves the efficiency of code insertion, and reduces the compilation time and the size of the generated code files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112667245B_ABST
    Figure CN112667245B_ABST
Patent Text Reader

Abstract

The present application discloses a code processing method, which includes: adding brick insertion code to the current environment of the target code; wherein the target code has dynamic AOP code inserted therein; during the execution of the target code, determining whether the current content to be executed is the dynamic AOP code; if so, selecting the target brick insertion code from the current environment by executing the dynamic AOP code, and executing the target brick insertion code; after the target brick insertion code is executed, continuing to execute the target code. The present application can realize dynamic code brick insertion and improve the efficiency of code brick insertion. The present application also discloses a code processing device, an electronic device and a storage medium, which have the above beneficial effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code processing method, device, electronic device and storage medium. Background Art

[0002] After the code is written, it is usually necessary to insert corresponding code into the original code so that the inserted code can be executed when the original code is executed. The industry calls the code inserted into the original code "brick code".

[0003] In the related art, ASM technology is usually used to insert code into the original code, but the above method can only insert code when the code is compiled, and cannot insert code during the code execution process. If you want to insert code into the published code file, you can only recompile it, and the code insertion efficiency is low.

[0004] Therefore, how to implement dynamic code insertion and improve the efficiency of code insertion is a technical problem that those skilled in the art currently need to solve. Summary of the invention

[0005] The purpose of this application is to provide a code processing method, device, electronic device and storage medium, which can realize dynamic code insertion and improve the efficiency of code insertion.

[0006] In order to solve the above technical problems, the present application provides a code processing method, which includes:

[0007] Adding a brick insert code to the current environment of the target code; wherein the target code has a dynamic AOP code inserted into it;

[0008] During the execution of the target code, determining whether the current content to be executed is the dynamic AOP code;

[0009] If yes, then select the target brick code from the current environment by executing the dynamic AOP code, and execute the target brick code;

[0010] After the target brick-insertion code is executed, the target code continues to be executed.

[0011] Optionally, selecting a target plug-in code from the current environment by executing the dynamic AOP code includes:

[0012] Obtain a corresponding brick code list from the current environment by executing the dynamic AOP code;

[0013] If the brick-insertion code list is not empty, the brick-insertion code in the brick-insertion code list is set as the target brick-insertion code.

[0014] Optionally, obtaining a corresponding brick code list from the current environment by executing the dynamic AOP code includes:

[0015] The mapping relationship table is queried by executing the dynamic AOP code, and the corresponding brick plug-in code list is obtained from the current environment according to the queried mapping relationship table; wherein the mapping relationship between the dynamic AOP code and the brick plug-in code is stored in the mapping relationship table.

[0016] Optionally, also include:

[0017] If a code import instruction is received, adding a new brick insertion code in the current environment according to the code import instruction;

[0018] The dynamic AOP code corresponding to the new brick insertion code is queried, and the mapping relationship between the new brick insertion code and the dynamic AOP code is updated to the mapping relationship table.

[0019] Optionally, during the process of executing the target brick insertion code, the process further includes:

[0020] Import the function information of the function where the dynamic AOP code is located into the target brick code; wherein the function information includes any one or a combination of any several of the class name, function name and function parameters.

[0021] Optionally, before executing the target code, the method further includes:

[0022] During the process of compiling the target code, all functions in the target code are determined, and dynamic AOP code is inserted into each function.

[0023] Optionally, if the number of the target brick insertion codes is greater than 1, executing the target brick insertion codes includes:

[0024] Determine the current target brick insertion code, and execute the current target brick insertion code;

[0025] After the current target brick insertion code is executed, determining whether all the target brick insertion codes are executed;

[0026] If yes, then starting the operation of continuing to execute the target code;

[0027] If not, the operation of determining the current target brick insertion code is started.

[0028] The present application also provides a code processing device, the code processing device comprising:

[0029] A brick inserting code adding module is used to add brick inserting code to the current environment of the target code; wherein the target code has dynamic AOP code inserted into it;

[0030] A dynamic brick insertion module is used to determine whether the current content to be executed is the dynamic AOP code during the execution of the target code; if so, select the target brick insertion code from the current environment by executing the dynamic AOP code, and execute the target brick insertion code;

[0031] The code execution module is used to continue executing the target code after the target brick insertion code is executed.

[0032] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps of executing the above-mentioned code processing method are implemented.

[0033] The present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of executing the above-mentioned code processing method when calling the computer program in the memory.

[0034] The present application provides a code processing method, including: adding brick-insertion code to the current environment of the target code; wherein the target code has dynamic AOP code inserted therein; during the execution of the target code, determining whether the current content to be executed is the dynamic AOP code; if so, selecting the target brick-insertion code from the current environment by executing the dynamic AOP code, and executing the target brick-insertion code; after the execution of the target brick-insertion code is completed, continuing to execute the target code.

[0035] The present application adds brick insertion code to the current environment of the target code, and the target code is inserted with dynamic AOP code. When executing the target code, if the current content to be executed is the dynamic AOP code, the target brick insertion code can be selected and executed from the current environment by executing the dynamic AOP code to realize the dynamic insertion of the code. After the target brick insertion code is executed, the target code can continue to be executed. The above-mentioned code processing method can realize dynamic brick insertion during the execution of the target code based on the dynamic AOP code, and the new code can be added to the target code in the form of brick insertion without recompiling the code. Therefore, the present application can realize dynamic code brick insertion and improve the efficiency of code brick insertion. The present application also provides a code processing device, an electronic device and a storage medium, which have the above-mentioned beneficial effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to 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 work.

[0037] Figure 1 An architectural diagram of a code processing system provided in an embodiment of the present application;

[0038] Figure 2 A flowchart of a code processing method provided in an embodiment of the present application;

[0039] Figure 3 A flowchart of a brick insertion code execution method provided in an embodiment of the present application;

[0040] Figure 4 A schematic diagram of a code compilation process provided by an embodiment of the present application;

[0041] Figure 5 A flowchart of a brick insertion code execution method provided in an embodiment of the present application;

[0042] Figure 6 A schematic diagram of the structure of a code processing device provided in an embodiment of the present application;

[0043] Figure 7 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0045] In order to facilitate understanding of the code processing method provided by this application, the system used by it is introduced below. Figure 1 , which shows an architecture diagram of a code processing system provided by an embodiment of the present application, such as Figure 1 The code processing system shown includes a first host 101 and a second host 102. The first host 101 stores a target code, and the target code inserts dynamic AOP code into each function during the compilation process, so that when the first host executes the function of the target code, it can determine and execute the plug-in code by executing the dynamic AOP code. The second host 102 can transmit the plug-in code to the first host 101 through the network, so that when the first host 101 executes the target code, it can execute the plug-in code transmitted by the second host 102, thereby realizing dynamic plug-in.

[0046] See below Figure 2 , Figure 2A flowchart of a code processing method provided in an embodiment of the present application.

[0047] Specific steps may include:

[0048] S201: Adding a brick insert code to the current environment of the target code;

[0049] Among them, this embodiment can be applied to electronic devices for writing and compiling codes, and the target code is the code content in the already written code file. Before this step, there may be an operation of compiling the target code. The target code in this embodiment can be a code written in a programming language such as Java or C++. The current environment of the target code can be the execution environment of the code, and this embodiment can add any number of brick codes in the current environment.

[0050] Dynamic AOP code is inserted into the target code. When the dynamic AOP code is executed, the corresponding inserted code can be determined and executed from the current environment. AOP (Aspect Oriented Programming) is a technology that implements unified maintenance of program functions through pre-compilation and dynamic proxy during runtime. As a feasible implementation method, before executing the target code, all functions in the target code can also be determined during the compilation of the target code, and the dynamic AOP code can be inserted into each function. Specifically, when the target code is a code written in Java, this embodiment can insert the dynamic AOP code into the function through ASM technology during the compilation of the target code. The above-mentioned ASM is a Java bytecode manipulation framework.

[0051] S202: During the execution of the target code, determine whether the current content to be executed is the dynamic AOP code; if so, proceed to S203;

[0052] If the current content to be executed of the target code is a dynamic AOP code, the dynamic brick insertion operation in S203 can be performed. If the current content to be executed of the target code is not a dynamic AOP code, the current content to be executed can be executed to determine a new current content to be executed.

[0053] S203: selecting a target brick code from the current environment by executing the dynamic AOP code, and executing the target brick code;

[0054] Among them, this embodiment can pre-set the mapping relationship between dynamic AOP code and brick-insertion code, and select the target brick-insertion code from the current environment based on the mapping relationship, and execute the target brick-insertion code. By using the dynamic AOP code to implement the code brick-insertion solution in this step, the number of inserted codes in the compilation process can be reduced, and dynamic code brick-insertion can be implemented in the process of executing the target code without recompiling the code version, thereby improving the compilation efficiency and brick-insertion efficiency of the target code. Brick-insertion refers to inserting the corresponding code into the original code, and executing the corresponding brick-insertion code when the original code is executed.

[0055] Furthermore, the dynamic AOP code can be added to the function of the target code. In this embodiment, the function to which the dynamic AOP code is added can be set as the target function. Therefore, in the process of executing the target code, the target function to be executed in the target code can be determined. Since the target function has been inserted with the dynamic AOP code, the dynamic AOP code can be executed in the process of executing the target function to determine the inserted brick code in the current environment, and execute the corresponding inserted brick code. It can be understood that since there can be multiple functions in the target code, after executing the target function, the new target function to be executed in the target code can be determined. If the new target function is inserted with the dynamic AOP code, the relevant operations can be performed according to the above-mentioned code insertion method.

[0056] As a feasible implementation, during the execution of the plug-in code, the function information of the function where the dynamic AOP code is located can also be imported into the target plug-in code so that the target plug-in code is executed based on the above function information. Specifically, the above function information includes any one or a combination of any of the class name, function name and function parameters.

[0057] S204: After the target brick-insertion code is executed, continue to execute the target code.

[0058] Among them, since dynamic AOP code is inserted into the target code in this embodiment, the target brick code can be selected and executed from the current environment when the dynamic AOP code is executed. After all the target brick codes are executed, the unexecuted code content in the target code can continue to be executed.

[0059] This embodiment adds brick insertion code to the current environment of the target code, and dynamic AOP code is inserted into the target code. When executing the target code, if the current content to be executed is the dynamic AOP code, the target brick insertion code can be selected and executed from the current environment by executing the dynamic AOP code to realize dynamic insertion of the code. After the target brick insertion code is executed, the target code can continue to be executed. The above-mentioned code processing method can realize dynamic brick insertion during the execution of the target code based on the dynamic AOP code, and the new code can be added to the target code in the form of brick insertion without recompiling the code. Therefore, this embodiment can realize dynamic code brick insertion and improve the efficiency of code brick insertion.

[0060] Furthermore, this embodiment can also reduce the time consumption of compiling code. Assuming that it takes M minutes to insert bricks into all functions each time the target code is compiled, if there are N bricks, the total time consumption is N*M=MN minutes. In the code processing solution based on dynamic AOP provided in this embodiment, it is only necessary to execute the code for inserting dynamic AOP during the process of compiling the target code. The time consumption is always M minutes, which can be reduced by (N-1)*M minutes.

[0061] Furthermore, this embodiment can also reduce the size of the code file generated by the final compilation. Assuming that the code inserted in each compilation is Q KB, if there are X functions, then if there are N plug-ins, then the total increase in the size of the target code is X*Q*NKB; and in the code processing solution based on dynamic AOP provided in this embodiment, it is only necessary to execute the code inserted into the dynamic AOP during the compilation of the target code. If the size of the added dynamic AOP code is also Q KB, the total increase in the size of the target code = X*Q KB, which is reduced by X*Q*(N-1)KB. For common applications, N and X are very large, and the use of dynamic AOP technology will reduce the size of the code file generated in the end.

[0062] As for Figure 1 Further introduction to the corresponding embodiment can be performed by determining the target brick code in the following manner: obtaining a corresponding brick code list from the current environment by executing the dynamic AOP code; if the brick code list is not empty, setting the brick code in the brick code list as the target brick code.

[0063] Specifically, this embodiment can query the mapping relationship table by executing the dynamic AOP code, and obtain the corresponding brick code list from the current environment according to the query mapping relationship table; wherein the mapping relationship table stores the mapping relationship between the dynamic AOP code and the brick code. In this embodiment, the dynamic AOP code can correspond to any number of brick codes, and there may be multiple dynamic AOP codes corresponding to the same brick code. If the brick code list is empty, it means that there is no corresponding brick code for the dynamic AOP code, and the target code can continue to be executed. If the brick code list is not empty, the target brick codes in the brick code list can be executed sequentially.

[0064] The brick-insertion code in this embodiment can be a code transmitted through the network, or it can be a code in a file imported by the user through a mobile hard disk. Specifically, if a code import instruction is received, a new brick-insertion code is added to the current environment according to the code import instruction; the dynamic AOP code corresponding to the new brick-insertion code is queried, and the mapping relationship between the new brick-insertion code and the dynamic AOP code is updated to the mapping relationship table. After updating the mapping relationship table, the brick-insertion code can be executed based on the updated mapping relationship table when executing the target code.

[0065] See also Figure 3 , Figure 3 A flowchart of a method for executing a brick code provided in an embodiment of the present application. This embodiment can be implemented on the basis that the number of brick codes corresponding to the target function is greater than 1. The process of executing the brick code may include the following steps:

[0066] S301: Determine the current target brick insertion code and execute the current target brick insertion code.

[0067] S302: After the current target brick insertion code is executed, determine whether all target brick insertion codes are executed; if so, enter S303; if not, enter S301.

[0068] S303: Start the operation of continuing to execute the target code.

[0069] Through the above method, all the plug-in codes corresponding to the dynamic AOP code can be executed in sequence. Although the plug-in code is not inserted into the target code, the corresponding plug-in code can be executed during the execution of the target code, achieving the same effect as inserting the code.

[0070] The following is an example of an actual application to illustrate the process described in the above embodiment. Figure 4 , Figure 4A code compilation flow diagram is provided for an embodiment of the present application. This embodiment describes the process of compiling the target code to generate an Android apk file. After starting to compile the .java code file, dynamic AOP insertion can be performed for each function of each .java file, so that the dynamic AOP code can be inserted after the function header and adjacent to the function header, thereby generating the final Android apk file.

[0071] exist Figure 4 During the code compilation process shown, ASM technology can be used to insert dynamic AOP code into each function in each .java file, so that the generated Android apk file has the basic capabilities of dynamic AOP.

[0072] Furthermore, when running an Android apk file, each function will first execute the dynamic AOP code inserted during the compilation process. In the dynamic AOP code, you can execute Figure 5 The dynamic brick insertion logic shown, Figure 5 A flow chart of a brick code execution method provided by an embodiment of the present application. This embodiment can determine whether there is a brick code to be executed after entering the dynamic AOP code; if not, continue to execute the function where the dynamic AOP code is located; if so, construct execution parameters, and use the execution parameters to execute the corresponding brick code, and re-determine whether there is a brick code to be executed after executing the brick code.

[0073] exist Figure 5 During the code compilation process shown in the figure, the execution of dynamic AOP code can first determine whether there is a plug-in code that needs to be dynamically executed in the current environment. If so, the plug-in code is executed, and then check whether there is the next plug-in code that needs to be dynamically executed. If not, the dynamic AOP code is executed and returns to the original function code to continue execution.

[0074] For example, the process of inserting dynamic AOP code into each function in a .java file:

[0075] Suppose there is a say function in the com.test.java class. The function is as follows:

[0076] Void say(String name){

[0077] Log(“say name="+name);

[0078] }

[0079] After the dynamic AOP code is inserted during compilation, the above function becomes the following:

[0080] Void say(String name){

[0081] 1. Note 1

[0082] List <aop>allAop=AopManager.getAllAop();

[0083] If (allAop! = null) {

[0084] 2. Note 2

[0085] for(int i=0; i <allAop.size();i++){

[0086] 3. Note 3

[0087] allAop.get(i).execute("com.test","say",new Object[]{name});

[0088] }

[0089] }

[0090] 4. Note 4

[0091] Log("say name="+name);

[0092] }

[0093] When executing, the following points can exist:

[0094] Note 1: Get the dynamic brick insertion supported by the current environment. If there is a brick insertion, the returned brick insertion code list allAop is not empty.

[0095] Note 2: If the returned brick insertion code list is not empty, each brick insertion code needs to be executed in sequence.

[0096] Note 3: When executing the brick-insertion code, you need to pass in the corresponding information of the original function, such as the class name, function name and function parameters, and this line of brick-insertion code can obtain the corresponding data.

[0097] Note 4: After the above steps 1, 2, and 3 are completed, or if Note 1 cannot obtain the dynamic brick, the logic of the original function is executed.

[0098] The above-mentioned embodiment needs to insert the dynamic AOP code once during compilation in order to insert the dynamic AOP execution environment. At runtime, it is determined whether to execute the dynamic code insertion based on whether there is currently any insertion code. This embodiment only needs to insert the dynamic AOP code into the .java file, and there is no need to insert the insertion code multiple times, thereby improving the code compilation efficiency. Since this embodiment does not directly insert the insertion code into the .java file, the size of the compiled apk file can be reduced. In addition, this embodiment can insert code at any time during runtime through dynamic AOP technology, and even in the apk officially released on the external network, any code can be issued at will for all functions without recompilation, thereby improving the insertion efficiency.

[0099] See also Figure 6 , Figure 6 A schematic diagram of the structure of a code processing device provided in an embodiment of the present application;

[0100] The device may include:

[0101] The brick inserting code adding module 601 is used to add the brick inserting code to the current environment of the target code; wherein the target code has dynamic AOP code inserted into it;

[0102] The dynamic brick insertion module 602 is used to determine whether the current content to be executed is the dynamic AOP code during the execution of the target code; if so, select the target brick insertion code from the current environment by executing the dynamic AOP code, and execute the target brick insertion code;

[0103] The code execution module 603 is used to continue executing the target code after the target brick insertion code is executed.

[0104] This embodiment adds brick insertion code to the current environment of the target code, and dynamic AOP code is inserted into the target code. When executing the target code, if the current content to be executed is the dynamic AOP code, the target brick insertion code can be selected and executed from the current environment by executing the dynamic AOP code to realize dynamic insertion of the code. After the target brick insertion code is executed, the target code can continue to be executed. The above-mentioned code processing method can realize dynamic brick insertion during the execution of the target code based on the dynamic AOP code, and the new code can be added to the target code in the form of brick insertion without recompiling the code. Therefore, this embodiment can realize dynamic code brick insertion and improve the efficiency of code brick insertion.

[0105] Furthermore, the dynamic brick insertion module 602 includes:

[0106] A list acquisition unit, used for acquiring a corresponding brick code list from the current environment by executing the dynamic AOP code;

[0107] The code setting unit is used to set the brick insertion code in the brick insertion code list as the target brick insertion code if the brick insertion code list is not empty.

[0108] Furthermore, the list acquisition unit is used to query the mapping relationship table by executing the dynamic AOP code, and obtain the corresponding brick code list from the current environment according to the queried mapping relationship table; wherein the mapping relationship between the dynamic AOP code and the brick code is stored in the mapping relationship table.

[0109] Furthermore, it also includes:

[0110] The brick-insertion code adding module is used to add new brick-insertion code to the current environment according to the code import instruction if a code import instruction is received; it is also used to query the dynamic AOP code corresponding to the new brick-insertion code, and update the mapping relationship between the new brick-insertion code and the dynamic AOP code to the mapping relationship table.

[0111] Furthermore, it also includes:

[0112] An information import module is used to import the function information of the function where the dynamic AOP code is located into the target brick code; wherein the function information includes any one or a combination of any several of the class name, function name and function parameters.

[0113] Furthermore, it also includes:

[0114] The AOP code insertion module is used to determine all functions in the target code during the process of compiling the target code before executing the target code, and insert dynamic AOP code into each function.

[0115] Furthermore, the dynamic brick insertion module 602 includes:

[0116] A code determination unit, which determines a current target brick insertion code and executes the current target brick insertion code;

[0117] The code query unit is used to determine whether all the target brick-insertion codes have been executed after the current target brick-insertion code has been executed; if so, start the operation of continuing to execute the target code; if not, start the operation of determining the current target brick-insertion code.

[0118] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0119] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0120] The present application also provides an electronic device, see Figure 7 , a structural diagram of an electronic device provided in an embodiment of the present application, such as Figure 7 As shown, a processor 710 and a memory 720 may be included.

[0121] Among them, the processor 710 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 710 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 710 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 710 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 710 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0122] The memory 720 may include one or more computer-readable storage media, which may be non-transitory. The memory 720 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 720 is at least used to store the following computer program 721, wherein, after the computer program is loaded and executed by the processor 710, it can implement the relevant steps in the code processing method executed by the electronic device side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 720 may also include an operating system 722 and data 723, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 722 may include Windows, Linux, Android, etc.

[0123] In some embodiments, the electronic device may further include a display screen 730 , an input / output interface 740 , a communication interface 750 , a sensor 760 , a power source 770 , and a communication bus 780 .

[0124] certainly, Figure 7 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include Figure 7 More or fewer components than shown, or combinations of certain components.

[0125] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

[0126] It should also be noted that, in this specification, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.< / aop>

Claims

1. A code processing method, characterized in that: include: Adding a brick insert code to the current environment of the target code; wherein the target code has a dynamic AOP code inserted into it; During the execution of the target code, determining whether the current content to be executed is the dynamic AOP code; If yes, then select the target brick code from the current environment by executing the dynamic AOP code, and execute the target brick code; After the target brick insertion code is executed, continue to execute the target code; Wherein, in the process of executing the target brick insertion code, it also includes: Importing function information of the function where the dynamic AOP code is located into the target brick code, so that the target brick code is executed based on the function information; wherein the function information includes a class name, a function name and function parameters; Before executing the target code, the method further includes: During the process of compiling the target code, all functions in the target code are determined, and dynamic AOP code is inserted into each function.

2. The code processing method according to claim 1, characterized in that: The step of selecting a target plug-in code from the current environment by executing the dynamic AOP code includes: Obtain a corresponding brick code list from the current environment by executing the dynamic AOP code; If the brick-insertion code list is not empty, the brick-insertion code in the brick-insertion code list is set as the target brick-insertion code.

3. The code processing method according to claim 2, characterized in that: Obtaining a corresponding brick code list from the current environment by executing the dynamic AOP code includes: The mapping relationship table is queried by executing the dynamic AOP code, and the corresponding brick plug-in code list is obtained from the current environment according to the queried mapping relationship table; wherein the mapping relationship between the dynamic AOP code and the brick plug-in code is stored in the mapping relationship table.

4. The code processing method according to claim 3, characterized in that: Also includes: If a code import instruction is received, adding a new brick insertion code in the current environment according to the code import instruction; The dynamic AOP code corresponding to the new brick insertion code is queried, and the mapping relationship between the new brick insertion code and the dynamic AOP code is updated to the mapping relationship table.

5. The code processing method according to any one of claims 1 to 4, characterized in that: If the number of the target brick insertion codes is greater than 1, executing the target brick insertion codes includes: Determine the current target brick insertion code, and execute the current target brick insertion code; After the current target brick insertion code is executed, determining whether all the target brick insertion codes are executed; If yes, then starting the operation of continuing to execute the target code; If not, the operation of determining the current target brick insertion code is started.

6. A code processing device, characterized in that: include: A brick inserting code adding module is used to add brick inserting code to the current environment of the target code; wherein the target code has dynamic AOP code inserted into it; A dynamic brick insertion module is used to determine whether the current content to be executed is the dynamic AOP code during the execution of the target code; if so, select the target brick insertion code from the current environment by executing the dynamic AOP code, and execute the target brick insertion code; A code execution module, used for continuing to execute the target code after the target brick insertion code is executed; An information import module, used to import the function information of the function where the dynamic AOP code is located into the target brick code, so that the target brick code is executed based on the function information; wherein the function information includes a class name, a function name and function parameters; The AOP code insertion module is used to determine all functions in the target code during the process of compiling the target code before executing the target code, and insert dynamic AOP code into each function.

7. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the code processing method according to any one of claims 1 to 5 are implemented.

8. A storage medium, characterized in that: The storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the steps of the code processing method as described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Software test method and system

    CN104834590A

  • Automatic test case determination method and device, equipment and storage medium

    CN111382073A