Code analysis method and device, electronic equipment and readable storage medium
By performing offline simulation analysis on the code to be analyzed of ATE equipment through preset code rules, the problem that code errors of ATE equipment can only be found in the formal application stage is solved, enabling timely correction of code writing problems and improving the efficiency of equipment use.
Patent Information
- Application Number
- CN202211645530.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-16
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-12-16
AI Technical Summary
Existing ATE equipment can only detect code errors during the formal application phase, which affects the efficiency of equipment use.
This paper provides a code analysis method that analyzes the code to be analyzed by pre-defined code rules, identifies writing problems, including code unit extraction, type matching and error location, and realizes simulation analysis in offline mode.
Once the code is written, problems can be identified and corrected, ensuring the correctness of the code in the formal application phase and improving the efficiency of device use.
Smart Images

Figure CN115809066B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of device programming, and particularly relates to a code analysis method and device, an electronic device and a readable storage medium. BACKGROUND
[0002] The existing ATE (Automatic Test Equipment) requires a user to write a program according to a programming manual provided by a device supplier, and in an entity debugging stage after the program is written, an error message collection window is used to inform the user of an error in code writing, which can only discover a code error in a formal application stage, thereby affecting the use efficiency of the device. SUMMARY
[0003] The present application provides a code analysis method and device, an electronic device and a readable storage medium, and aims to solve the technical problem that the ATE device in the prior art can only discover a code error in a formal application stage, thereby affecting the use efficiency of the device.
[0004] In order to solve the above technical problem, the present application provides a code analysis method, which comprises the following steps:
[0005] If an analysis instruction is received, a code to be analyzed corresponding to the analysis instruction is acquired;
[0006] A preset code rule is acquired, and an analysis operation is performed on the code to be analyzed based on the preset code rule to obtain an analysis result;
[0007] A writing problem of the code to be analyzed is determined according to the analysis result.
[0008] Optionally, the step of performing the analysis operation on the code to be analyzed based on the preset code rule to obtain the analysis result comprises:
[0009] A unit extraction operation is performed on the code to be analyzed to obtain a plurality of code units;
[0010] A code type corresponding to each code unit is determined, and a sub-rule corresponding to the code type is matched in the preset code rule;
[0011] For each code unit, an analysis operation is performed on the code unit according to the corresponding sub-rule to obtain an analysis result.
[0012] Optionally, the step of performing the unit extraction operation on the code to be analyzed to obtain the plurality of code units comprises:
[0013] Each code line of the code to be analyzed is read line by line, and line information corresponding to each code line is generated;
[0014] According to the line information, the code lines are merged to obtain a plurality of code units.
[0015] Optionally, the step of matching the sub-rule corresponding to the code type in the preset code rule comprises:
[0016] If the code unit is a function unit, it is judged whether the function unit is a board object calling function.
[0017] If the function unit is the board object calling function, a board type corresponding to the function unit is obtained, and a board function rule corresponding to the board type in the preset code rule is obtained.
[0018] The sub-rule corresponding to the function unit is matched in the board function rule.
[0019] Optionally, the step of judging whether the function unit is the board object calling function comprises:
[0020] If the function unit is not the board object calling function, a general function rule in the preset code rule is obtained.
[0021] The sub-rule corresponding to the function unit is matched in the general function rule.
[0022] Optionally, the step of obtaining the analysis result by analyzing the code unit according to the corresponding sub-rule comprises:
[0023] A preset time rule is obtained, and a unit time corresponding to each code unit is matched in the preset time rule, wherein the unit time comprises a unit delay time and a unit execution time.
[0024] A total execution time of the code to be analyzed is determined based on the unit delay time and the unit execution time.
[0025] Optionally, the step of obtaining the analysis result by analyzing the code to be analyzed based on the preset code rule comprises:
[0026] Error code lines in the code to be analyzed are determined by analyzing the code to be analyzed based on the preset code rule.
[0027] Error information of each error code line is obtained, and the analysis result is obtained by collecting the error information.
[0028] To achieve the above object, the application further provides a code analysis device, which comprises:
[0029] The first obtaining module is configured to, if an analysis instruction is received, obtain a code to be analyzed corresponding to the analysis instruction.
[0030] The second obtaining module is configured to obtain a preset code rule, and perform an analysis operation on the code to be analyzed based on the preset code rule to obtain an analysis result.
[0031] The first determining module is configured to determine a writing problem of the code to be analyzed according to the analysis result.
[0032] To achieve the above object, the present application further provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the computer program is executed by the processor to implement the steps of the code analysis method.
[0033] To achieve the above object, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the code analysis method.
[0034] The code analysis method, device, electronic device and readable storage medium provided by the present application are as follows: if an analysis instruction is received, a code to be analyzed corresponding to the analysis instruction is obtained; a preset code rule is obtained, and an analysis operation is performed on the code to be analyzed based on the preset code rule to obtain an analysis result; and a writing problem of the code to be analyzed is determined according to the analysis result. By pre-setting the preset code rule and analyzing the code to be analyzed based on the preset code rule to determine the writing problem in the code to be analyzed, the code to be analyzed can be analyzed and the writing problem can be determined after the code is written, so that the user can modify the writing problem in time, the correctness of the code in the formal application stage is ensured, and the use efficiency of the device is ensured. BRIEF DESCRIPTION OF DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the specification.
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced here. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0037] Figure 1 Flowchart of the first embodiment of the code analysis method of the present application;
[0038] Figure 2A detailed flow chart of step S20 of the second embodiment of the code analysis method of the present application;
[0039] Figure 3 A schematic diagram of the module structure of the electronic device of the present application. DETAILED DESCRIPTION
[0040] It should be understood that the specific embodiments described herein are merely exemplary and are not intended to limit the present application. In order to enable a person skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person skilled in the art without creative labor should be within the scope of protection of the present application.
[0041] The present application provides a code analysis method, referring to Figure 1 , Figure 1 A flowchart of the first embodiment of the code analysis method of the present application, the method comprising the steps of:
[0042] Step S10, if an analysis instruction is received, the corresponding code to be analyzed of the analysis instruction is obtained;
[0043] The analysis instruction is used to indicate the analysis operation on the code to be analyzed; the code to be analyzed is the code written by the user that needs to be analyzed; it should be noted that the analysis instruction can be triggered during the code to be analyzed is written, or it can be triggered after the code to be analyzed is written, that is, the code to be analyzed can be an incomplete code or a complete code.
[0044] Specifically, the code to be analyzed can be directly included in the analysis instruction, and it can also be obtained at the corresponding code position after receiving the analysis instruction; for example, the user writes the code to be analyzed in the writing bar, and when the analysis instruction is triggered, the code to be analyzed is obtained from the writing bar.
[0045] Step S20, obtaining a preset code rule, and performing an analysis operation on the code to be analyzed based on the preset code rule to obtain an analysis result;
[0046] The preset code rule is a set of features preset to indicate the correctness of the code; the preset code rule includes but is not limited to format requirements, function order, index requirements, parameter range, and parameter relationship between functions, and the preset code rule can also be divided into card code rule and general code rule based on the association relationship between the code and the card, the card code rule is used for the special code set for a single or partial type card, and the general code rule is used for the general code.
[0047] It can be understood that the index requirements and program writing requirements of each board card in the ATE system can be integrated in advance to obtain preset code rules in an offline manner, and the preset code rules are stored in a configuration file of the ATE system. When the preset code rules are needed, the configuration file of the ATE system is obtained, and the configuration file is parsed to obtain the preset code rules.
[0048] The analysis operation is an operation of judging whether the to-be-analyzed code meets the preset code rules. The analysis result is used to indicate the writing condition of the to-be-analyzed code, and the analysis result includes but is not limited to whether there is a code error, an error position, an error type, an error severity, and a modification suggestion.
[0049] Step S30, determining the writing problem of the to-be-analyzed code according to the analysis result.
[0050] After obtaining the analysis result, it is necessary to determine the writing problem of the to-be-analyzed code and return to the user interface. If there is no code error in the analysis result, the to-be-analyzed code has no writing problem. At this time, preset correct information is returned to the user interface. If there is a code error in the analysis result, the to-be-analyzed code has a writing problem. At this time, the error information of the error code is determined in the analysis result, and the error information is returned to the user interface.
[0051] The embodiment sets the preset code rules in advance, and analyzes the to-be-analyzed code by using the preset code rules to determine the writing problem in the to-be-analyzed code. After the code is written, the to-be-analyzed code can be simulated and analyzed to determine the writing problem in an offline state without waiting for an online stage of formal application, so that the user can modify the writing problem in time to ensure the correctness of the code in the formal application stage, thereby ensuring the use efficiency of the equipment.
[0052] Further, referring to Figure 2 In the second embodiment of the code analysis method of the present application based on the first embodiment of the present application, the step S20 includes the following steps:
[0053] Step S21, performing a unit extraction operation on the to-be-analyzed code to obtain a plurality of code units;
[0054] The code unit is a continuous code set for realizing a single function or a combined function, such as a complete function, a complete description statement, etc. The extraction operation is used to divide the to-be-analyzed code to obtain a plurality of code units. Specifically, the step S21 includes the following steps:
[0055] Step S211, reading each code line of the to-be-analyzed code line by line, and generating line information corresponding to each code line;
[0056] Step S212, merging the code lines according to the line information to obtain a plurality of code units.
[0057] The line information contains relevant information of the code lines, and the line information includes but is not limited to function name, line number, function internal line number, content, corresponding board type, and board object name.
[0058] After the line information is generated, the code lines belonging to the same code unit can be determined according to the line information. For a function unit, if a left bracket is read in the code line, the left bracket identifier and the line number are recorded in the line information corresponding to the code line. If a right bracket is read in the code line, the right bracket identifier and the line number are recorded in the line information corresponding to the code line. After the reading is completed, the left bracket and the right bracket in a same bracket can be located according to the left bracket identifier and the right bracket identifier in the line information, and the start line and the end line of the function unit can be determined according to the line numbers in the line information corresponding to the left bracket identifier and the right bracket identifier, that is, the code line where the left bracket is located is the start line of the function unit, and the code line where the right bracket is located is the end line of the function unit. The code lines between the start line and the end line are merged as a function unit. For the code unit of the statement, a keyword can be set for extraction, and after the function unit is extracted, the continuous code lines interposed between the function units can be merged as a code unit. Different types of code units can be extracted according to their characteristics, which will not be described here.
[0059] It should be noted that a code unit can be contained in another code unit, that is, there are overlapping code lines between two code units, such as a complete function as a variable in a function. At this time, the code lines corresponding to the two functions are taken as two code units, and the code unit with more lines contains all the code lines of the code unit with fewer lines.
[0060] Step S22, determining the code type corresponding to each code unit, and matching the sub-rules corresponding to the code type in the preset code rules;
[0061] It can be understood that the types of the code units contained in the code to be analyzed are different based on different functions to be implemented, and therefore, the code types corresponding to different code units need to be determined. The code types include but are not limited to board object calling functions and general functions. It can be understood that a plurality of sub-rules are set in the preset code rules under different code type groups. After the code type of the code unit is determined, the sub-rule corresponding to the code unit can be determined in the group corresponding to the code type, so that the matching efficiency of the sub-rules is improved while the sub-rules are accurately matched without matching in the entire preset code rules.
[0062] Further, the step S22 includes the steps of:
[0063] Step S221, if the code unit is a function unit, determining whether the function unit is a board object calling function;
[0064] Step S222, if the function unit is the board object calling function, obtaining a board type corresponding to the function unit, and obtaining a board function rule corresponding to the board type in the preset code rule;
[0065] Step S223, matching the sub-rule corresponding to the function unit in the board function rule.
[0066] The board object calling function refers to a special function applied to a board or a function with differences in application on a board. It should be noted that the board object calling function can be the same as the general function, but when applied to a specific board, there can be differences in parameter requirements and implementation means compared with the general function. Therefore, it is necessary to determine whether the function unit is a board object calling function first to avoid analyzing the board object calling function as a general function, which can lead to errors in the analysis result. It can be understood that the corresponding board object calling functions of different types of boards can be different.
[0067] The preset code rule sets a plurality of sub-rules under different board type groups. After determining the board type corresponding to the function unit, the sub-rule corresponding to the function unit can be determined in the board function rule corresponding to the board type. Specifically, when matching the sub-rule, the function type of the function unit can be determined based on the line information corresponding to the function unit, and then the sub-rule corresponding to the function type is matched in the board function rule.
[0068] Step S224, if the function unit is not the board object calling function, obtaining a general function rule in the preset code rule;
[0069] Step S225, matching the sub-rule corresponding to the function unit in the general function rule.
[0070] If the function unit is not a board object calling function, it means that the function unit can be analyzed by the general function rule. At this time, the sub-rule corresponding to the function unit is determined in the general function group, i.e. the general function rule in the preset code rule. Specifically, the function type of the function unit can be determined based on the line information corresponding to the function unit, and then the sub-rule corresponding to the function type is matched in the general function rule.
[0071] It should be noted that it can also be determined whether the function unit is a general function. If the function unit is a general function, the sub-rule corresponding to the function unit is matched in the general function rule.
[0072] If the function unit is not a general function, the function unit is not analyzed.
[0073] The general function is used to indicate a function that needs to be analyzed and is not set for a specific board card; it can be understood that a complete code to be analyzed contains some functions that are fixedly set, formal or need special attention, and the influence of these functions on the ATE is lower or needs special analysis by the user, and thus, the automatic analysis is not needed or is not convenient, and therefore, these functions are excluded from the general functions, so as to skip the analysis of these functions, thereby improving the analysis efficiency.
[0074] In step S23, for each code unit, the code unit is analyzed according to the corresponding sub-rule to obtain an analysis result.
[0075] After determining the sub-rule corresponding to the code unit, the code unit is analyzed based on the corresponding sub-rule to determine whether the code unit has a writing problem; specifically:
[0076] 1. The code unit is fpvi0.Set(FV, 15, FPVI10_10V, FPVI10_100MA, RELAY_ON);
[0077] The sub-rule corresponding to the code unit requires that the voltage value of the second parameter “15” needs to be within the voltage range of the third parameter “FPVI10_10V”; if the second parameter is not within the voltage range of the third parameter, it may cause abnormal test results or damage to the hardware, and therefore, when the second parameter is not within the voltage range of the third parameter, it is considered that the code unit has a writing problem;
[0078] 2. The code unit is used to set the AWG (Arbitrary Waveform Generator) scanning parameters, and the specific jump point is set to 50uA and the current range is set to 100mA.
[0079] According to the sub-rule corresponding to the code unit, it can be determined that the current accuracy corresponding to the 100mA current range is 100uA, and at this time, the jump point of 50uA cannot be triggered, and therefore, it is considered that the code unit has a writing problem.
[0080] 3. The code unit is used for power curve detection, and needs to set the current output value, voltage range and delay.
[0081] The VI source pulse duration is related to the voltage level, and if the set delay is relatively long, it will affect the test, so it is necessary to comprehensively judge whether the current output value, voltage level and delay setting are reasonable. The specific judgment steps of whether the current output value, voltage level and delay setting are reasonable can be set based on the actual application scene.
[0082] The embodiment illustrates the analysis operation of different types of code units. Other types of code units can set corresponding sub-rules and analysis operations based on actual characteristics, and details are not repeated:
[0083] The embodiment can accurately analyze the code unit.
[0084] Further, after the step S23, the step S24 is included:
[0085] Step S24, acquiring a preset time rule, and matching the unit time corresponding to each code unit in the preset time rule, the unit time including unit delay time and unit execution time;
[0086] Step S25, determining the total execution time of the code to be analyzed based on each unit delay time and the unit execution time.
[0087] Specifically, the preset time rule can include a preset delay rule and a preset execution rule.
[0088] It can be understood that the execution of the code needs to occupy a certain time, that is, the execution time. Since the function implemented by the code unit is basically determined, the approximate time required for the execution of different types of code units can be obtained in advance by detection or empirical statistics, that is, the unit execution time. The set of corresponding relationships between each unit execution time and the code unit is taken as the preset execution rule.
[0089] It can be understood that the code needs to wait for a certain time, i.e. delay time, when performing certain operations, such as relay switching action, instruction transmission, capacitor charging and discharging, etc. Since the function implemented by the code unit is basically determined, the approximate time required for different types of code units to perform a specific operation, i.e. unit delay time, can be obtained in advance by detection or empirical statistics, and the set of corresponding relationship between each unit delay time and the code unit is taken as a preset delay rule. After the code unit is determined, the unit delay time corresponding to each code unit in the preset delay rule is matched, and the unit execution time corresponding to each code unit in the preset execution rule is matched. The sum of the unit delay time and the unit execution time is the unit time corresponding to the code unit, and the sum of the obtained unit time is the total execution time of the complete execution of the code to be analyzed. It should be noted that when calculating the total execution time, an error time can also be added. For example, when the code unit involves capacitor charging and discharging, the capacitor charging and discharging time is different based on the actual circuit conditions, so the unit delay time corresponding to this code unit cannot be accurately determined. At this time, the unit delay time corresponding to this code unit can be set as the optimal value determined based on historical data, and an error time can be additionally set. When calculating the total execution time, in addition to calculating the sum of the unit delay times, the error time can be added and / or subtracted to obtain the final total execution time. That is, the total execution time can be a specific numerical value or an interval determined based on the addition and subtraction of the error time.
[0090] The embodiment can preliminarily analyze and simulate the total execution time of the code to be analyzed before formal application, which facilitates time control by the user.
[0091] Further, in the third embodiment of the code analysis method of the present application based on the first embodiment of the present application, the step S20 comprises the steps of:
[0092] Step S21, analyzing the error code lines in the code to be analyzed based on the preset code rule;
[0093] Step S22, obtaining error information of each error code line, and obtaining the analysis result by collecting each error information.
[0094] When analyzing that there is a writing problem in the code to be analyzed, the code line corresponding to the writing problem, i.e. the error code line, is located, and the error information corresponding to the error code line is obtained. The error information includes but is not limited to code, error position, error type, error severity, and modification suggestion.
[0095] It can be understood that when the content in the code to be analyzed is too much, it is inconvenient to view the analysis result, therefore, the analysis result in the embodiment only contains error information, so as to facilitate the user to directly determine the writing error; it should be noted that in other embodiments, the information corresponding to all code lines can be set in the analysis result according to actual needs. Further, the analysis result can also include code lines that are not analyzed, such as the function units that are not general functions, to remind the user to perform additional analysis on them.
[0096] After obtaining the analysis result, the analysis result is sent to the user interface for display, and the user can locate the error code line based on the analysis result and modify it.
[0097] The analysis result in the embodiment only contains error information, so as to facilitate the user to directly determine the writing error.
[0098] It should be noted that for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0099] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, or network device, etc.) execute the method described in each embodiment of the present application.
[0100] The present application also provides a code analysis device for implementing the above code analysis method, the code analysis device comprising:
[0101] The first acquisition module is configured to acquire the code to be analyzed corresponding to the analysis instruction if the analysis instruction is received;
[0102] The second acquisition module is configured to acquire the preset code rule and perform an analysis operation on the code to be analyzed based on the preset code rule to obtain an analysis result;
[0103] The first determining module is configured to determine the writing problem of the code to be analyzed according to the analysis result.
[0104] The code analysis apparatus determines the writing problem in the code to be analyzed by presetting the preset code rule and analyzing the code to be analyzed according to the preset code rule, so that the writing problem can be determined after the code is written, the user can correct the writing problem in time, the correctness of the code in the formal application stage is ensured, and the use efficiency of the equipment is ensured.
[0105] It should be noted that the first obtaining module in this embodiment can be configured to perform step S10 in the embodiments of the present application, the second obtaining module in this embodiment can be configured to perform step S20 in the embodiments of the present application, and the first determining module in this embodiment can be configured to perform step S30 in the embodiments of the present application.
[0106] Further, the second obtaining module comprises:
[0107] The first execution unit is configured to perform a unit extraction operation on the code to be analyzed to obtain a plurality of code units.
[0108] The first determining unit is configured to determine a code type corresponding to each code unit and match a sub-rule corresponding to the code type in the preset code rule.
[0109] The first analysis unit is configured to, for each code unit, perform an analysis operation on the code unit according to the corresponding sub-rule to obtain an analysis result.
[0110] Further, the first execution unit comprises:
[0111] The first generation sub-unit is configured to read the code lines of the code to be analyzed line by line and generate line information corresponding to each code line.
[0112] The first merging sub-unit is configured to merge the code lines according to the line information to obtain a plurality of code units.
[0113] Further, the first determining unit comprises:
[0114] The first judgment sub-unit is configured to, if the code unit is a function unit, judge whether the function unit is a board object calling function.
[0115] The first obtaining sub-unit is configured to, if the function unit is the board object calling function, obtain a board type corresponding to the function unit and obtain a board function rule corresponding to the board type in the preset code rule.
[0116] The first matching subunit is configured to match the subrule corresponding to the function unit in the board card function rule.
[0117] Further, the first determining unit further comprises:
[0118] The second obtaining subunit is configured to obtain a general function rule in the preset code rule if the function unit does not invoke a function of the board card object.
[0119] The second matching subunit is configured to match the subrule corresponding to the function unit in the general function rule.
[0120] Further, the second obtaining module further comprises:
[0121] The third obtaining subunit is configured to obtain a preset time rule and match a unit time corresponding to each code unit in the preset time rule, wherein the unit time comprises a unit delay time and a unit execution time.
[0122] The first determining subunit is configured to determine a total execution time of the code to be analyzed based on each unit delay time and the unit execution time.
[0123] Further, the second obtaining module further comprises:
[0124] The second determining unit is configured to analyze the code to be analyzed based on the preset code rule to determine error code lines in the code to be analyzed.
[0125] The first obtaining unit is configured to obtain error information of each error code line and obtain the analysis result by collecting each error information.
[0126] It should be noted that the above modules and the examples and application scenarios realized by the corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules as part of the device can be realized by software or hardware, wherein the hardware environment includes a network environment.
[0127] Reference Figure 3 The electronic device can include a communication module 10, a memory 20, and a processor 30, etc. in terms of hardware structure. In the electronic device, the processor 30 is connected with the memory 20 and the communication module 10 respectively, the memory 20 stores a computer program, the computer program is executed by the processor 30, and the computer program realizes the steps of the above method embodiments when executed.
[0128] The communication module 10 can be connected with an external communication device through a network. The communication module 10 can receive a request sent by the external communication device, and can also send a request, an instruction and information to the external communication device. The external communication device can be another electronic device, a server or an Internet of Things device, such as a television and the like.
[0129] The memory 20 can be used to store software programs and various data. The memory 20 can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as obtaining the to-be-analyzed code corresponding to the analysis instruction), and the like. The data storage area can include a database, and can store data or information created according to the use of the system, and the like. In addition, the memory 20 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device.
[0130] The processor 30 is the control center of the electronic device, connects all parts of the electronic device through various interfaces and lines, executes the software programs and / or modules stored in the memory 20 and the data stored in the memory 20, and performs various functions and processes data of the electronic device, thereby monitoring the whole electronic device. The processor 30 can include one or more processing units. Optionally, the processor 30 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface and the application program, and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 30.
[0131] Although Figure 3 Although not shown, the above-mentioned electronic device can also include a circuit control module for connecting with a power supply to ensure the normal work of other components. Those skilled in the art can understand that Figure 3 The structure of the electronic device shown in the above-mentioned embodiment does not constitute a limitation on the electronic device, and can include more or fewer components than shown, or combine certain components, or different component arrangements.
[0132] The application also provides a computer readable storage medium having a computer program stored thereon. The computer readable storage medium can be a Figure 3The computer readable storage medium can be at least one of a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk, and an optical disk, and the computer readable storage medium includes a plurality of instructions to cause an end device (which can be a television, a car, a mobile phone, a computer, a server, a terminal, or a network device, etc.) having a processor to execute the method described in various embodiments of the present application.
[0133] In the present application, the terms "first", "second", "third", "fourth", "fifth" are only for the purpose of description, and cannot be understood as indicating or implying relative importance, and for those skilled in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances.
[0134] In the description of the present application, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present application, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, different embodiments or examples described in the present application and the features of different embodiments or examples can be combined and combined by those skilled in the art without contradiction.
[0135] Although the embodiments of the present application have been shown and described above, the scope of protection of the present application is not limited thereto, and it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application, and those skilled in the art can make changes, modifications and replacements to the above embodiments within the scope of the present application, and these changes, modifications and replacements should be covered within the scope of protection of the present application. Therefore, the scope of protection of the present application should be subject to the scope of protection of the claims.
Claims
1. A code analysis method characterized by, The method comprises: If an analysis instruction is received, obtaining the code to be analyzed corresponding to the analysis instruction; Obtaining a preset code rule, and performing an analysis operation on the code to be analyzed based on the preset code rule to obtain an analysis result; Determining the writing problem of the code to be analyzed according to the analysis result; The step of performing the analysis operation on the code to be analyzed based on the preset code rule to obtain the analysis result comprises: Performing a unit extraction operation on the code to be analyzed to obtain a plurality of code units; Determining the code type corresponding to each code unit, and matching the sub-rule corresponding to the code type in the preset code rule; For each code unit, performing an analysis operation on the code unit according to the corresponding sub-rule to obtain an analysis result; The step of matching the sub-rule corresponding to the code type in the preset code rule comprises: If the code unit is a function unit, determining whether the function unit is a board object calling function; If the function unit is the board object calling function, obtaining the board type corresponding to the function unit, and obtaining the board function rule corresponding to the board type in the preset code rule; Matching the sub-rule corresponding to the function unit in the board function rule; The sub-rule indicates the parameter of the hardware index, the requirement of the implementation means, and the like. The step of performing the unit extraction operation on the code to be analyzed to obtain a plurality of code units comprises:
2. The code analysis method of claim 1, wherein, Reading each code line of the code to be analyzed line by line, and generating line information corresponding to each code line; According to the line information, the code lines are merged to obtain a plurality of code units. After the step of determining whether the function unit is the board object calling function, the following step is included:
3. The code analysis method of claim 1, wherein, If the function unit is not the board object calling function, obtaining a general function rule in the preset code rule; Matching the sub-rule corresponding to the function unit in the general function rule. After the step of performing the analysis operation on the code unit according to the corresponding sub-rule to obtain the analysis result, the following step is included:
4. The code analysis method of claim 1, wherein, Obtaining a preset time rule, and matching the unit time corresponding to each code unit in the preset time rule, wherein the unit time comprises a unit delay time and a unit execution time; Determining the total execution time of the code to be analyzed based on the unit delay time and the unit execution time. The step of performing the analysis operation on the code to be analyzed based on the preset code rule to obtain the analysis result comprises:
5. The code analysis method of claim 1, wherein, Based on the preset code rule, the error code lines in the code to be analyzed are determined by performing an analysis operation on the code to be analyzed; Obtaining the error information of each error code line, and collecting the error information to obtain the analysis result. The code analysis device comprises:
6. A code analysis apparatus characterized by comprising: A first obtaining module is configured to, if an analysis instruction is received, obtain the code to be analyzed corresponding to the analysis instruction; The second obtaining module is configured to obtain a preset code rule, and perform an analysis operation on the code to be analyzed based on the preset code rule to obtain an analysis result. The first determining module is configured to determine a writing problem of the code to be analyzed according to the analysis result. The second obtaining module includes: The first execution unit is configured to perform a unit extraction operation on the code to be analyzed to obtain a plurality of code units. The first determining unit is configured to determine a code type corresponding to each code unit, and match a sub-rule corresponding to the code type in the preset code rule. The first analysis unit is configured to, for each code unit, perform an analysis operation on the code unit according to the corresponding sub-rule to obtain an analysis result. The first determining unit includes: The first judgment sub-unit is configured to, if the code unit is a function unit, judge whether the function unit is a board object calling function. The first obtaining sub-unit is configured to, if the function unit is the board object calling function, obtain a board type corresponding to the function unit, and obtain a board function rule corresponding to the board type in the preset code rule. The first matching sub-unit is configured to match the sub-rule corresponding to the function unit in the board function rule. The preset code rule sets a plurality of sub-rules under different board type groups. After determining the board type corresponding to the function unit, the sub-rule corresponding to the function unit is determined in the group corresponding to the board type. The sub-rule indicates the requirements of the corresponding board type on the parameters of the hardware index and the implementation means.
7. An electronic device, comprising: The electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is executed by the processor to implement the steps of the code analysis method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the code analysis method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Code detection method and device
CN105320591A
Code normativity detection method and device, terminal equipment and storage medium
CN108459962A