[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN110244954B - Compiling method and equipment for application program - Google Patents

Compiling method and equipment for application program Download PDF

Info

Publication number
CN110244954B
CN110244954B CN201910430221.5A CN201910430221A CN110244954B CN 110244954 B CN110244954 B CN 110244954B CN 201910430221 A CN201910430221 A CN 201910430221A CN 110244954 B CN110244954 B CN 110244954B
Authority
CN
China
Prior art keywords
variable
program
compiling
variable value
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910430221.5A
Other languages
Chinese (zh)
Other versions
CN110244954A (en
Inventor
杨彪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Saiante Technology Service Co Ltd
Original Assignee
Shenzhen Saiante Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Saiante Technology Service Co Ltd filed Critical Shenzhen Saiante Technology Service Co Ltd
Priority to CN201910430221.5A priority Critical patent/CN110244954B/en
Publication of CN110244954A publication Critical patent/CN110244954A/en
Application granted granted Critical
Publication of CN110244954B publication Critical patent/CN110244954B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention is suitable for the technical field of application programs, and provides a compiling method and equipment of an application program, wherein the compiling method and equipment comprise the following steps: if a compiling instruction of the application program is received, acquiring a program file of the application program; analyzing the program file, and extracting program variables contained in the application program; based on the variable names of the program variables, marking variable language segments containing the program variables in the program file, and determining the variable types of the program variables according to the variable language segments; selecting a program variable with a variable type as a set type as a target variable, and respectively determining the variable value of each target variable in a program file; and judging whether the variable value is in the variable value range of the target variable, and if the variable value is not in the variable value range, outputting a compiling abnormity report. The invention improves the detection efficiency of the abnormal variable value and the success rate of program compilation.

Description

Compiling method and equipment for application program
Technical Field
The invention belongs to the technical field of application programs, and particularly relates to a compiling method and equipment of an application program.
Background
The types and the number of the application programs serving as main carriers for responding to user requests are increasing rapidly, and with the continuous progress of application program technologies, the program functions included in the application programs are increasing continuously, and a large number of arrays or sets and the like are often configured in one program to realize data interaction among different modules, so that the realization of the program functions is facilitated. In the existing compiling technology of the application program, after the application program is created, the application program is compiled, whether a program bug exists in the application program is judged, however, because the application program contains a large number of program variables, if the value of a certain program variable is abnormal, a developer needs to manually adjust the program variable, and before the logic bug of the application program is determined, the value of the variable needs to be repeatedly confirmed, so that the compiling efficiency of the application program is reduced, and the compiling difficulty is increased.
Disclosure of Invention
In view of this, embodiments of the present invention provide a compiling method and device for an application program, so as to solve the problems that, in the existing compiling technology for an application program, developers need to perform manual adjustment, and before determining a logic bug of the application program, the variable value needs to be repeatedly confirmed, so that the compiling efficiency of the application program is reduced, and the compiling difficulty is increased.
A first aspect of an embodiment of the present invention provides a method for compiling an application program, including:
if a compiling instruction of an application program is received, acquiring a program file of the application program;
analyzing the program file, and extracting program variables contained in the application program;
based on the variable names of the program variables, marking variable language segments containing the program variables in the program file, and determining the variable types of the program variables according to the variable language segments;
selecting the program variables with the variable types as set types as target variables, and respectively determining the variable values of the target variables in the program files;
judging whether the variable value is in the variable value range of the target variable, and if the variable value is not in the variable value range, outputting a compiling abnormity report; the compiling exception report comprises the variable values which are not in the variable value range and exception language sections of the variable values in the program file.
A second aspect of an embodiment of the present invention provides an application compiling apparatus, including:
the device comprises a program file acquisition unit, a processing unit and a processing unit, wherein the program file acquisition unit is used for acquiring a program file of an application program if a compiling instruction of the application program is received;
a program variable extracting unit, configured to analyze the program file and extract a program variable included in the application program;
a variable type determining unit, configured to mark, based on a variable name of each program variable, a variable field including each program variable in the program file, and determine a variable type of the program variable according to the variable field;
the target variable selecting unit is used for selecting the program variables of which the variable types are set types as target variables and respectively determining the variable values of the target variables in the program files;
a compiling exception report output unit, configured to determine whether each variable value is within a variable value range of the target variable, and output a compiling exception report if the variable value is not within the variable value range; the compiling exception report comprises the variable values which are not in the variable value range and exception language sections of the variable values in the program file.
A third aspect of embodiments of the present invention provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the first aspect when executing the computer program.
A fourth aspect of embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, performs the steps of the first aspect.
The application program compiling method and the application program compiling device provided by the embodiment of the invention have the following beneficial effects:
the embodiment of the invention extracts the program variables from the program file of the application program when receiving the compiling instruction of the application program, selects the set type target variables which can cause the situations of program value out-of-range or null value taking and the like according to the variable types of all the program variables, obtains the variable values of all the target variables in the program file, compares the variable values with the variable value range, thereby judging whether the variable values are legal or not, generates the compiling exception report for the program file configured with illegal variable values, and marks the abnormal variable values and the abnormal language sections where the abnormal variable values are positioned, thereby facilitating developers to quickly position exception positions and repair the exception situations of the program file. Compared with the existing compiling method of the application program, whether the values of all program variables are abnormal or not is not required to be manually detected by a developer before compiling, but the set type target variables can be automatically extracted through the terminal equipment, and the abnormal variable values are identified according to the comparison between the variable value range of the target variables and the values in the program file, so that the detection efficiency of the abnormal variable values is improved, and the success rate of program compiling is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of an implementation of a method for compiling an application program according to a first embodiment of the present invention;
fig. 2 is a flowchart illustrating an implementation details of a compiling method S105 for an application according to a second embodiment of the present invention;
fig. 3 is a flowchart illustrating a specific implementation of a method for compiling an application program according to a third embodiment of the present invention;
fig. 4 is a flowchart of a specific implementation of a compiling method for an application program according to a fourth embodiment of the present invention;
fig. 5 is a flowchart illustrating an implementation details of the compiling method S102 for an application according to a fifth embodiment of the present invention;
fig. 6 is a block diagram illustrating an architecture of a compiling apparatus for an application according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a terminal device according to another embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the invention extracts the program variables from the program file of the application program when receiving the compiling instruction of the application program, selects the set type target variables with the situations of out-of-range program value or null value taking and the like according to the variable types of the program variables, obtains the variable values of the target variables in the program file, compares the variable values with the variable value range to judge whether the variable values are legal or not, generates the compiling abnormity report for the program file with the configured illegal variable values, and marks the abnormal variable values and the abnormal language sections where the abnormal variable values are located, thereby facilitating developers to quickly locate the abnormal positions and repair the abnormal situations of the program file.
In the embodiment of the invention, the execution subject of the process is the terminal equipment. The terminal devices include but are not limited to: the application program compiling method includes the steps of enabling devices such as servers, computers, smart phones and tablet computers to execute compiling operation of the application programs. Fig. 1 shows a flowchart of an implementation of a method for compiling an application program according to a first embodiment of the present invention, which is described in detail as follows:
in S101, if a compiling instruction of an application program is received, a program file of the application program is acquired.
In this embodiment, when a developer finishes writing a program file of an application program and needs to compile the program file, the developer may generate a compiling instruction of the application program and send the compiling instruction to the terminal device. In this case, after receiving a compiling instruction sent by a developer, a terminal device does not immediately perform a compiling operation on a program file, but first performs a validity detection on a value of a program variable included in the program file, and executes a compiling process only when it is determined that each program variable in the program file has no abnormal value, so that a success rate of the compiling operation can be improved.
In this embodiment, the compiling instruction carries a program identifier of the application program, where the program identifier may be information used for marking the application program, such as a program name, a unique identifier, or a program version number of the application program. The terminal device may download the program file associated with the program identifier from a program database or a distribution platform storing the program file of the application program according to the program identifier, and perform an abnormality detection procedure of the program variable on the program file.
Optionally, in this embodiment, the developer may add all the applications that need to be compiled into one compiling response task pool, where each application is configured with a corresponding compiling priority. The compiling priority can be determined according to information such as the program type of the application program and the expected release time. The terminal device may determine the compilation triggering condition of each application program based on each compilation priority and the number of threads that can be used for performing value detection of the program variable. And if the current moment is detected to meet the compiling triggering condition of any application program, generating a compiling instruction of the application program, and executing subsequent related operations. The terminal equipment can establish a plurality of program variable detection processes, the number of the program variable detection processes can be determined according to the number of processors of the terminal equipment, and each program variable detection process can process the program variable detection of different application programs in parallel, so that when the compiling tasks in a compiling response task pool are more, the compiling operation response of each application program can be quickly carried out.
In S102, the program file is analyzed, and the program variables included in the application program are extracted.
In this embodiment, after acquiring the program file, the terminal device needs to parse the program file, where the program file includes source code data of all function modules and threads of the application program, and the source code data includes definition language segments and related language segments, such as reference language segments, of program variables existing in the program file. The terminal equipment can extract the program variables contained in the application program from the source code data obtained by analysis through a preset variable extraction algorithm.
Optionally, the manner of extracting the program variable by the terminal device may be: the terminal equipment acquires a compiling language corresponding to the program file, acquires a function library corresponding to the compiling language, and records a standard language field and a function trigger keyword of each function in the function library.
In S103, based on the variable name of each program variable, a variable field including each program variable is marked in the program file, and the variable type of the program variable is determined according to the variable field.
In this embodiment, after determining a program variable of a program file in the program file, a terminal device performs full-text search in the program file according to a variable name of the program variable, marks a field including the program variable in the program file, analyzes the field as a variable field of the program variable, and thereby determines a variable type of the program variable.
Preferably, in this embodiment, the terminal device uses a variable field in which the program variable appears in the program file for the first time as the definition field of the program variable. The terminal equipment analyzes the definition language segment, determines a configuration keyword for performing type configuration on the program variable, and determines the variable type of the program variable based on the configuration keyword.
Optionally, if an interface of another application program is called in the program file, that is, the interface is not defined in the program file, the terminal device may obtain the program file of the calling application program according to the call link, and repeat the above operation to determine the variable type of the called program variable. Optionally, the terminal device may further obtain all parameter values of the program variable in the program file, and determine the variable type of the program variable based on the parameter type of each parameter value.
In S104, the program variable whose variable type is the set type is selected as a target variable, and the variable values of the target variables in the program file are respectively determined.
In this embodiment, because the set-type program variables may have conditions such as array boundary crossing and null value fetching from the dictionary, which causes application program crash and reduces application program stability, the terminal device needs to select the program variable with the variable type being the set type from the program variables as the target variable and perform exception detection on the value of the target variable. Wherein the set-type program variables include: array types, dictionary types, matrix types, etc. may contain variable types of more than one parameter value.
In this embodiment, the terminal device determines whether each variable field includes an assignment field of the target variable according to the variable field of the target variable, and determines a variable value assigned to the target variable based on the assignment field of the target variable. The variable value comprises variable values of each stage of the first assignment, the middle assignment and the assignment of the output stage of the target variable, so that the condition that the value of the target variable is abnormal in the whole calling process is avoided, and the probability of the collapse of the application program is increased.
In S105, determining whether each variable value is within a variable value range of the target variable, and if the variable value is not within the variable value range, outputting a compiling exception report; the compiling exception report comprises the variable values which are not in the variable value range and exception language sections of the variable values in the program file.
In this embodiment, the terminal device obtains a variable value range associated with a target variable according to the variable type of the variable. And comparing all variable values of the target variable in the program file with the variable value range one by one, judging whether the variable value is in the variable value range, if so, identifying the variable value as a legal variable value, otherwise, identifying the variable value as an abnormal variable value if the variable value is out of the variable value range. And if all the variable values of the target variable are in the variable value range, identifying the target variable as a legal program variable, and if all the target variables of the program variable are legal program variables, performing a compiling process on the program file.
In this embodiment, if it is detected that the variable value of one target variable is outside the variable value range, the variable value is identified as an abnormal variable value, and a compiled exception report is generated. The compiled exception report includes all target variables with exception variable values and exception language sections in which the exception variable values are located. The developer or the terminal device can adjust the abnormal speech segment, thereby eliminating the abnormal situation of the application program, and after the abnormal speech segment is adjusted, the program file can be compiled.
Optionally, in this embodiment, if the two target variables are mutually exclusive variables, the two target variables are respectively used to manage data or storage addresses of different areas, and ranges of value ranges of the two target variables are mutually exclusive and disjoint.
It can be seen from the above that, in the compiling method for the application program provided in the embodiment of the present invention, when the compiling instruction of the application program is received, the program variable is extracted from the program file of the application program, the set type target variable that may cause the situations of out-of-bounds or null values of the program value is selected according to the variable type of each program variable, the variable value of each target variable in the program file is obtained, and the variable value is compared with the variable value range, so as to determine whether the variable value is legal, a compiling exception report is generated for the program file configured with the illegal variable value, and the abnormal variable value and the exception field where the abnormal variable value is located are marked, so that developers can quickly locate an exception location and repair the exception situation of the program file. Compared with the existing compiling method of the application program, whether the values of all program variables are abnormal or not is not required to be manually detected by a developer before compiling, but the set type target variables can be automatically extracted through the terminal equipment, and the abnormal variable values are identified according to the comparison between the variable value range of the target variables and the values in the program file, so that the detection efficiency of the abnormal variable values is improved, and the success rate of program compiling is improved.
Fig. 2 shows a flowchart of a specific implementation of the compiling method S105 for the application program according to the second embodiment of the present invention. Referring to fig. 2, with respect to the embodiment shown in fig. 1, the compiling method S105 of the application program provided in this embodiment includes: S1051-S1054 are described in detail as follows:
further, the determining whether the variable value is within the variable value range of the target variable, and if the variable value is not within the variable value range, outputting a compiling exception report, including:
in S1051, a test script is configured for each variable value, and a plurality of concurrent test threads matching the number of scripts are created based on the number of scripts of the test script.
In this embodiment, in order to improve the abnormality detection efficiency and accuracy of the variable value, the terminal device may further determine whether the variable value is out of range or in conflict after determining that the variable value is within the variable value range. The specific implementation process is as follows: and the terminal equipment extracts the script template related to the application program from the script library and adjusts the script template according to the variable value so as to generate the test script with the variable value matched.
In this embodiment, the terminal device creates multiple concurrent test threads with the matching script number direction according to the script number of the test script, and each concurrent test thread is used for executing one test script. Optionally, if the number of the concurrent test threads is greater than the maximum number of the created threads, the concurrent test threads with the same maximum number of the created threads are created, in this case, the terminal device may store all the test scripts in the task pool, each concurrent test thread may extract the test script from the task pool to perform a test operation, and if a certain concurrent test thread completes a test task, the unprocessed test script is extracted from the task pool again.
In 1052, each concurrent test thread is invoked to obtain a response time for the program file to run the test script.
In this embodiment, the terminal device records the test start time when the test script starts to run, so that the response time of the test script can be continuously obtained in the test process. If the test script of a certain variable value finishes responding within the time threshold, that is, the response time is less than or equal to the preset time threshold, the variable value is identified as a legal variable value, otherwise, if the concurrent test thread detects that the response time is greater than the preset time threshold and no test result is output, the related operation of S1053 is executed.
In S1053, if it is detected that any one of the response times exceeds a preset time threshold, an exception record is generated regarding a variable value corresponding to the test script.
In this embodiment, if the terminal device detects that the response time of the test script corresponding to a certain variable value exceeds the preset time threshold, it indicates that there is an abnormal situation such as stuck or even breakdown when the application program executes the test script, and the test result of the test script cannot be normally output. Based on the above, the terminal device obtains the target variable to which the variable value belongs, extracts the abnormal field from the program file based on the variable name of the target variable and the variable value, and generates the abnormal record according to the abnormal field and the abnormal variable value.
In S1054, a compiling exception report of the program file is generated according to all the exception records.
In this embodiment, after the terminal device performs the above operations on the variable values of all the target variables, all the exception records that are abnormal may be encapsulated, so as to generate a compiled exception report of the program file, which is convenient for a developer to uniformly repair all the exception conditions. Optionally, the terminal device may import the test script into the program file, run the program file, and obtain a running time for the program file to execute the program file, where the running time may be obtained by a Runtime list, and the terminal device may configure multiple concurrent threads, process each test script at the same time, and reduce a running condition of each test script to the Runtime list. And when the running time of the test script exceeds a preset abnormal time threshold and the test result is not output, identifying that the index value corresponding to the test script is not in the range of the allowable value of the target variable. At this time, runtime will output an error message, and the terminal device will intercept the error message and not output it directly, but process all the error messages uniformly. The terminal equipment does not go through a system crash prompt, but returns programs based on Runtime and outputs variable exception reports related to the target variables, and all the target exception reports are collected uniformly, so that a user can clean all the abnormal target variables in the terminal equipment at one time conveniently.
In the embodiment of the invention, the validity of the test script of each variable value is tested by creating a plurality of concurrent test threads, so that the detection efficiency of the abnormal variable value can be improved, the identification accuracy of the abnormal variable value can be improved by detecting the response time of the application program responding to the test script, and the occurrence probability of program crash is reduced.
Fig. 3 is a flowchart illustrating a specific implementation of a method for compiling an application program according to a third embodiment of the present invention. Referring to fig. 3, with respect to the embodiment shown in fig. 1, before the determining whether each of the variable values is within the variable value range of the target variable, and if the variable value is not within the variable value range, outputting a compiling exception report, the compiling method of the application program according to this embodiment further includes: s301 to S304 are detailed as follows:
in S301, a candidate value range of the program variable is determined according to the variable type, and a node extraction step length matching the candidate region range is configured.
In this embodiment, in order to improve the accuracy of the variable value range, the terminal device may determine the variable value range of the target variable according to the variable type, and also needs to check the validity of the variable value range, for example, a certain variable type is an integer number, that is, the value range is-32768-32767, and since the program variable is specifically used to indicate the current number of people, but a negative value cannot be taken, if a negative value occurs, the program logic processing is abnormal, and therefore, the value range determined according to the variable type may be inaccurate. Based on this, the terminal device takes the value range related to the variable type as a candidate value range, and selects a node extraction step length matched with the interval length according to the interval length of the candidate value range, specifically, if the interval length is longer, the node extraction step length is larger; and the shorter the interval length is, the shorter the node extraction step length is, so that the number of variable nodes selected in the candidate value range of different interval lengths can be ensured to be similar or the same.
In S302, a plurality of variable value nodes are selected from the candidate value range according to the node extraction step size.
In this embodiment, the terminal device may select a plurality of variable value nodes at intervals within the candidate value range according to the node extraction step length, specifically, a first node of the terminal device is a boundary node of the candidate value range, and selects a next variable value node according to the boundary node as a reference and the node extraction step length as a step length, and the process of selecting the variable node is ended until the next value node reaches or exceeds another boundary node of the candidate value range.
In S303, the operating parameters of the program file when the target variable takes the variable value node are recorded.
In this embodiment, the terminal device may set the parameter value of each target variable as a variable value node, run the program file, obtain an operation parameter of the terminal device when running the application program, and use the operation parameter as an operation parameter associated with the variable value node. The operating parameters include, but are not limited to: content occupancy, cache occupancy, response time, and the like.
In S304, if the operating parameter is within a preset rated operating parameter range, the variable value node is identified as an effective value node, and a variable value range of the target variable is generated according to all the effective value nodes.
In this embodiment, if the terminal device detects that the operating parameter of a certain variable value node is outside the rated operating parameter range, the variable value node is identified as an invalid value node, the value area where the node is located is not within the range of the target variable, and for the operating parameter of the variable value node is within the rated operating parameter range, the variable value node is identified as an effective value node, and the variable value range of the target variable is re-arched according to all the effective value nodes, so that the accuracy of the variable value range can be improved.
In the embodiment of the invention, a plurality of variable value nodes are selected in the candidate value range, and the operation parameters of each variable value node are obtained, so that the effective interval in the candidate value range can be identified, and the accuracy of the variable value range is improved.
Fig. 4 is a flowchart illustrating a specific implementation of a compiling method for an application program according to a fourth embodiment of the present invention. Referring to fig. 4, with respect to the embodiment shown in fig. 1 to 3, after the determining whether each of the variable values is within the variable value range of the target variable, and if the variable value is not within the variable value range, outputting a compiling exception report, the method for compiling an application program according to this embodiment further includes: s401 to S403 are specifically described as follows:
in S401, an effective variable value having the smallest difference from the variable value is selected from the variable value range as an adjustment variable value.
In this embodiment, the terminal device can not only manually adjust the abnormal value by a developer, but also automatically repair the abnormal value of the target variable by the terminal device. After identifying the variable value outside the variable value range, the terminal device selects the effective variable value with the minimum difference value with the variable value in the variable value range as the adjusting variable value, and the difference value between the effective variable value and the adjusting variable value is small, so that the similarity between the two parameters is high, and the effective variable value can be used as the adjusting variable value for automatic adjustment.
In S402, the variable values in the program file are replaced with the adjustment variable values.
In this embodiment, the terminal device may replace all the language segments of the abnormal variable value of the target variable in the program file with the adjustment variable value, so as to ensure that all the target variables in the program file are legal variable values.
In S403, a compiling operation is performed on the adjusted program file.
In this embodiment, after the terminal device performs the above-mentioned exception repairing operation on all the exception variables, the adjusted program file does not include the program variable with an abnormal value, and at this time, the program file may be compiled.
In the embodiment of the invention, the effective variable with smaller difference degree with the abnormal variable value is selected as the adjusting variable value in the variable value range, and the parameter value replacement operation is carried out on the program file, so that the purpose of automatically repairing the abnormality can be realized.
Fig. 5 is a flowchart illustrating a specific implementation of the compiling method S102 for the application program according to a fifth embodiment of the present invention. Referring to fig. 5, with respect to the embodiment described in fig. 1 to fig. 3, the compiling method S102 for the application program provided in this embodiment includes: s1021 to S1022 are specifically described as follows:
further, the analyzing the program file and extracting the program variable included in the application program includes:
in S1021, according to a preset definition keyword for program variable definition, a parameter definition field including the definition keyword is queried in the program file.
In this embodiment, the terminal device may obtain the function corpus associated with the application program, and extract a definition keyword for program variable definition from the function corpus, that is, parameter definition may be performed on the program variable in the program file by using the definition keyword, and the terminal device may perform full-text search in the program file according to the definition keyword, and extract a corpus including the definition keyword as a parameter definition corpus.
In S1022, the program variable is extracted from the parameter definition corpus.
In this embodiment, the terminal device may obtain, based on the definition keyword as a reference, a variable defined by the definition keyword according to a syntax result defined by the parameter in the program file, where the variable is a program variable included in the program file.
In the embodiment of the invention, the program variable is determined in the program file by identifying the definition keyword, so that the identification efficiency of the program variable can be improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not limit the implementation process of the embodiments of the present invention in any way.
Fig. 6 is a block diagram illustrating a compiling apparatus for an application program according to an embodiment of the present invention, where the compiling apparatus for an application program includes units for performing the steps in the corresponding embodiment of fig. 1. Please refer to fig. 1 and fig. 1 for the corresponding description of the embodiment. For convenience of explanation, only the portions related to the present embodiment are shown.
Referring to fig. 6, the apparatus for compiling an application program includes:
a program file acquiring unit 61, configured to acquire a program file of an application program if a compiling instruction of the application program is received;
a program variable extracting unit 62, configured to analyze the program file and extract a program variable included in the application program;
a variable type determining unit 63, configured to mark, in the program file, a variable field including each program variable based on a variable name of each program variable, and determine a variable type of the program variable according to the variable field;
a target variable selecting unit 64, configured to select the program variable with the variable type being the set type as a target variable, and determine a variable value of each target variable in the program file;
a compiling abnormity report output unit 65, configured to determine whether each variable value is within a variable value range of the target variable, and output a compiling abnormity report if the variable value is not within the variable value range; the compiling exception report comprises the variable values which are not in the variable value range and exception language sections of the variable values in the program file.
Optionally, the compiling exception report output unit 65 includes:
a concurrent test thread creating unit, configured to configure a test script for each variable value, and create a plurality of concurrent test threads matching the number of scripts based on the number of scripts of the test script;
a response time obtaining unit, configured to respectively invoke each concurrent test thread to obtain response time for the program file to run the test script;
an exception record output unit, configured to generate an exception record regarding a variable value corresponding to the test script if it is detected that any one of the response times exceeds a preset time threshold;
and the exception record packaging unit is used for generating a compiling exception report of the program file according to all exception records.
Optionally, the compiling device of the application further includes:
a node extraction step length determining unit, configured to determine a candidate value range of the program variable according to the variable type, and configure a node extraction step length matching the candidate region range;
a variable value node obtaining unit, configured to extract a step size from the nodes, and select a plurality of variable value nodes in the candidate value range;
the operation parameter recording unit is used for recording the operation parameters of the program file when the target variable is used for measuring the variable value node;
and the variable value range determining unit is used for identifying the variable value nodes as effective value nodes if the operating parameters are within a preset rated operating parameter range, and generating the variable value range of the target variable according to all the effective value nodes.
Optionally, the compiling device of the application further includes:
an adjusting variable value determining unit, configured to select, from the variable value range, an effective variable value having a smallest difference with the variable value as an adjusting variable value;
an adjustment variable value replacing unit for replacing the variable value in the program file with the adjustment variable value;
and the compiling execution unit is used for compiling the adjusted program file.
Optionally, the program variable extracting unit 62 includes:
a parameter definition phrase identifying unit, configured to query, according to a preset definition keyword for program variable definition, a parameter definition phrase including the definition keyword in the program file;
and the program variable identification unit is used for extracting the program variable from the parameter definition language segment.
Therefore, the compiling device of the application program provided by the embodiment of the invention can automatically extract the set type target variable through the terminal device without manually detecting whether the values of all program variables are abnormal before compiling by a developer, and can identify the abnormal variable value by comparing the variable value range of the target variable with the values in the program file, thereby improving the detection efficiency of the abnormal variable value and the success rate of the program compiling.
Fig. 7 is a schematic diagram of a terminal device according to another embodiment of the present invention. As shown in fig. 7, the terminal device 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72, such as a compiler of an application program, stored in said memory 71 and executable on said processor 70. The processor 70, when executing the computer program 72, implements the steps in the compiling method embodiments of the respective application programs, such as S101 to S105 shown in fig. 1. Alternatively, the processor 70, when executing the computer program 72, implements the functions of the units in the device embodiments described above, such as the functions of the modules 61 to 65 shown in fig. 6.
Illustratively, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present invention. The unit or units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into a program file acquisition unit, a program variable extraction unit, a variable type determination unit, a target variable selection unit, and a compiling abnormality report output unit, and the specific functions of the units are as described above.
The terminal device 7 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of a terminal device 7 and does not constitute a limitation of the terminal device 7 and may comprise more or less components than shown, or some components may be combined, or different components, for example the terminal device may further comprise input output devices, network access devices, buses, etc.
The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used for storing the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above-mentioned embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (8)

1. A method for compiling an application program, comprising:
if a compiling instruction of an application program is received, acquiring a program file of the application program;
analyzing the program file, and extracting program variables contained in the application program;
based on the variable names of the program variables, marking variable language segments containing the program variables in the program file, and determining the variable types of the program variables according to the variable language segments;
selecting the program variables of which the variable types are set types as target variables, and respectively determining the variable values of the target variables in the program file;
judging whether each variable value is in the variable value range of the target variable, and if the variable value is not in the variable value range, outputting a compiling abnormity report; the compiling exception report comprises the variable value which is not in the variable value range and the exception field of the variable value in the program file;
the determining whether each variable value is within a variable value range of the target variable, and if the variable value is not within the variable value range, outputting a compiling exception report, including:
configuring a test script for each variable value, and creating a plurality of concurrent test threads matched with the number of the scripts based on the number of the scripts of the test script;
respectively calling each concurrent test thread to acquire the response time of the program file for running the test script;
if any response time is detected to exceed a preset time threshold, generating an abnormal record about a variable value corresponding to the test script;
and generating a compiling exception report of the program file according to all exception records.
2. The compiling method according to claim 1, wherein before the determining whether each of the variable values is within a variable value range of the target variable, and if the variable value is not within the variable value range, outputting a compiling abnormality report, further comprising:
determining a candidate value range of the program variable according to the variable type, and configuring a node extraction step length matched with the candidate value range;
selecting a plurality of variable value-taking nodes in the candidate value-taking range according to the node extraction step length;
recording the operation parameters of the program file when the target variable is taken as the variable value node;
and if the operating parameters are within a preset rated operating parameter range, identifying the variable value nodes as effective value nodes, and generating the variable value range of the target variable according to all the effective value nodes.
3. The compiling method according to any one of claims 1 to 2, wherein after the determining whether each of the variable values is within the variable value range of the target variable and outputting a compiling abnormality report if the variable value is not within the variable value range, further comprising:
selecting an effective variable value with the minimum difference value with the variable value from the variable value range as an adjusting variable value;
replacing the variable values in the program file with the adjustment variable values;
and compiling the adjusted program file.
4. The compiling method according to any one of claims 1-2, wherein the parsing the program file and extracting the program variables contained in the application program comprises:
according to a preset definition keyword for program variable definition, inquiring a parameter definition language segment containing the definition keyword in the program file;
and extracting the program variable from the parameter definition language segment.
5. An apparatus for compiling an application program, comprising:
the device comprises a program file acquisition unit, a program file processing unit and a compiling unit, wherein the program file acquisition unit is used for acquiring a program file of an application program if a compiling instruction of the application program is received;
a program variable extracting unit, configured to parse the program file and extract a program variable included in the application program;
a variable type determining unit, configured to mark, based on a variable name of each program variable, a variable field including each program variable in the program file, and determine a variable type of the program variable according to the variable field;
the target variable selecting unit is used for selecting the program variables of which the variable types are set types as target variables and respectively determining the variable values of the target variables in the program files;
a compiling exception report output unit, configured to determine whether each variable value is within a variable value range of the target variable, and output a compiling exception report if the variable value is not within the variable value range; the compiling exception report comprises the variable value which is not in the variable value range and the exception field of the variable value in the program file;
the compiling exception report output unit comprises:
a concurrent test thread creating unit, configured to configure a test script for each variable value, and create a plurality of concurrent test threads matching the number of scripts based on the number of scripts of the test script;
a response time obtaining unit, configured to respectively invoke each concurrent test thread to obtain response time for the program file to run the test script;
an exception record output unit, configured to generate an exception record regarding a variable value corresponding to the test script if it is detected that any one of the response times exceeds a preset time threshold;
and the exception record packaging unit is used for generating a compiling exception report of the program file according to all exception records.
6. The compiling device according to claim 5, wherein the compiling device of the application program further comprises:
a node extraction step length determining unit, configured to determine a candidate value range of the program variable according to the variable type, and configure a node extraction step length matching the candidate value range;
a variable value node obtaining unit, configured to extract a step size from the nodes, and select a plurality of variable value nodes in the candidate value range;
the operation parameter recording unit is used for recording the operation parameters of the program file when the target variable is taken as the variable value node;
and the variable value range determining unit is used for identifying the variable value nodes as effective value nodes if the operating parameters are within a preset rated operating parameter range, and generating the variable value range of the target variable according to all the effective value nodes.
7. A terminal device, characterized in that the terminal device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, the processor executing the computer program with the steps of the method according to any of claims 1 to 4.
8. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of a method according to any one of claims 1 to 4.
CN201910430221.5A 2019-05-22 2019-05-22 Compiling method and equipment for application program Active CN110244954B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910430221.5A CN110244954B (en) 2019-05-22 2019-05-22 Compiling method and equipment for application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910430221.5A CN110244954B (en) 2019-05-22 2019-05-22 Compiling method and equipment for application program

Publications (2)

Publication Number Publication Date
CN110244954A CN110244954A (en) 2019-09-17
CN110244954B true CN110244954B (en) 2022-12-09

Family

ID=67884782

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910430221.5A Active CN110244954B (en) 2019-05-22 2019-05-22 Compiling method and equipment for application program

Country Status (1)

Country Link
CN (1) CN110244954B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111562910B (en) * 2020-05-08 2023-06-02 上海泛微网络科技股份有限公司 Packaging method and related equipment
CN114047917A (en) * 2021-07-30 2022-02-15 中国科学院信息工程研究所 Compiling related file identification method and device based on machine learning

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005215830A (en) * 2004-01-28 2005-08-11 Internatl Business Mach Corp <Ibm> Compiler, compile method, compile program, and recording medium
CN106155755A (en) * 2015-06-03 2016-11-23 上海红神信息技术有限公司 Program compiling method and compiler
CN107015813A (en) * 2017-04-19 2017-08-04 网易(杭州)网络有限公司 Method, device and electronic equipment that code is repaired

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9117028B2 (en) * 2011-12-15 2015-08-25 The Boeing Company Automated framework for dynamically creating test scripts for software testing

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005215830A (en) * 2004-01-28 2005-08-11 Internatl Business Mach Corp <Ibm> Compiler, compile method, compile program, and recording medium
CN106155755A (en) * 2015-06-03 2016-11-23 上海红神信息技术有限公司 Program compiling method and compiler
CN107015813A (en) * 2017-04-19 2017-08-04 网易(杭州)网络有限公司 Method, device and electronic equipment that code is repaired

Also Published As

Publication number Publication date
CN110244954A (en) 2019-09-17

Similar Documents

Publication Publication Date Title
US11048798B2 (en) Method for detecting libraries in program binaries
US10019240B2 (en) Method and apparatus for detecting code change
CN110941528B (en) Log buried point setting method, device and system based on fault
CN109800258B (en) Data file deployment method, device, computer equipment and storage medium
CN110704297B (en) Code review method, device, computer equipment and storage medium
US20180278635A1 (en) Apparatus, method, and computer program for detecting malware in software defined network
US20180060224A1 (en) Distinguishing Public and Private Code in Testing Environments
CN111967017A (en) Method and device for generating dependency relationship, terminal equipment and storage medium
US10296326B2 (en) Method and system for identifying open-source software package based on binary files
CN112988595A (en) Dynamic synchronization test method, device, equipment and storage medium
CN111884876A (en) Method, device, equipment and medium for detecting protocol type of network protocol
CN110244954B (en) Compiling method and equipment for application program
US11237943B2 (en) Generating inputs for computer-program testing
US10782942B1 (en) Rapid onboarding of data from diverse data sources into standardized objects with parser and unit test generation
KR101628602B1 (en) Similarity judge method and appratus for judging similarity of program
CN113626823A (en) Reachability analysis-based inter-component interaction threat detection method and device
CN118151946A (en) Lock use detection method and device, storage medium and electronic device
Lavoie et al. A case study of TTCN-3 test scripts clone analysis in an industrial telecommunication setting
CN117493169A (en) Method, device, equipment and medium for detecting API (application program interface) behavior incompatibility among Java dependency library versions
CN114691197A (en) Code analysis method and device, electronic equipment and storage medium
CN109213748B (en) Database script file updating method, server and medium
CN113408250B (en) Project file processing method and device
KR101673151B1 (en) Method and Apparatus for Analyzing Relationship Change of Program Source and DB Schema
CN107818100B (en) SQL statement execution method and device
KR20150111610A (en) Method for evaluating software similarity using stack and apparatus therefor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210125

Address after: 518000 Room 201, building A, No. 1, Qian Wan Road, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong (Shenzhen Qianhai business secretary Co., Ltd.)

Applicant after: Shenzhen saiante Technology Service Co.,Ltd.

Address before: 1-34 / F, Qianhai free trade building, 3048 Xinghai Avenue, Mawan, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong 518000

Applicant before: Ping An International Smart City Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant