CN109976991A - A kind for the treatment of method and apparatus of program code - Google Patents

A kind for the treatment of method and apparatus of program code Download PDF

Info

Publication number
CN109976991A
CN109976991A CN201711447799.9A CN201711447799A CN109976991A CN 109976991 A CN109976991 A CN 109976991A CN 201711447799 A CN201711447799 A CN 201711447799A CN 109976991 A CN109976991 A CN 109976991A
Authority
CN
China
Prior art keywords
program code
code
data block
code data
saved
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.)
Pending
Application number
CN201711447799.9A
Other languages
Chinese (zh)
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.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology 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 Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201711447799.9A priority Critical patent/CN109976991A/en
Publication of CN109976991A publication Critical patent/CN109976991A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a kind of processing method of program code, device, electronic equipment and computer readable storage mediums.This method comprises: obtaining the abstract syntax tree of program code;According to abstract syntax tree, the code data block that class is specified in program code is isolated;It is saved after each code data block isolated is named respectively;To each code data block saved, it is compared with the one or more code data blocks saved, determines that this in program code specifies the identical code data block of content of class.By the technical program, the identical code data block of content in program code can be determined, to eliminate the redundancy in program code, reduce the error rate of program code operation, enhance user experience.

Description

A kind for the treatment of method and apparatus of program code
Technical field
The present invention relates to field of computer technology, and in particular to a kind of processing method of program code, device, electronic equipment And computer readable storage medium.
Background technique
In the program code development phase of an application program or a system, for the normal operation of program code, A code block for realizing specified function can be added in the program code in exploitation, to be called.A but journey The exploitation of sequence code may handle multiple developers, and because the line number of program code is more, specify function when needing to realize Can when, each developer can not traverse the whole of completed program code, but oneself write again a code block so as to Realize corresponding function.In this way, it is multiple to realize that the code block of the same function might have, causes in a program code The redundancy of program code.
Summary of the invention
In view of the above problems, it proposes on the present invention overcomes the above problem or at least be partially solved in order to provide one kind State processing method, device, electronic equipment and the computer readable storage medium of the program code of problem.
According to an aspect of the invention, there is provided a kind of processing method of program code, wherein this method comprises:
Obtain the abstract syntax tree of program code;
According to the abstract syntax tree, the code data block that class is specified in said program code is isolated;
It is saved after each code data block isolated is named respectively;
To each code data block saved, it is compared with the one or more code data blocks saved, really Determine the identical code data block of content that this in said program code specifies class.
Optionally, each code data block that will be isolated is named respectively includes:
Each code data block isolated is named with class, method name and parameter information.
Optionally, described to each code data block saved, by itself and one or more code data blocks for being saved It is compared and includes:
Using Karp-Rabin string matching algorithm, to each code data block saved, by its with saved one A or multiple code data blocks are compared.
Optionally,
The code data block of the specified class refers to the code data block of method class.
Optionally, this method further comprises:
An identification code is respectively set for each code data block in said program code;
When said program code is run, according to the operation progress of said program code, by the identification code of each code data block It is output in said program code running log;
When said program code, which is run, to malfunction, according to the identification code in said program code running log, determine The position of said program code operation error.
Optionally, this method further comprises:
One identification switch is set;
When said program code is run, according to the operation progress of said program code, by the identification code of each code data block It is output in said program code running log and includes:
When said program code is run, the state that the identification switch is presently in is judged;
When the state that the identification switch is currently at out, according to the operation progress of said program code, by each code The identification code of data block is output in said program code running log.
Optionally, this method further comprises:
Web page editing interface is provided;
According to the web page editing interface webpage pattern editing parameter, the webpage pattern editor joins based on the received Number generates the pattern program code of webpage.
Optionally, the webpage pattern editing parameter includes one or more of:
The font of text, font size, font color, the size of page elements, the position of page elements, page elements Shape.
According to another aspect of the present invention, a kind of processing unit of program code is provided, wherein the device includes:
Acquiring unit, suitable for obtaining the abstract syntax tree of program code;
Separative unit is suitable for isolating the code data that class is specified in said program code according to the abstract syntax tree Block;
Storage unit, suitable for being saved after being named each code data block isolated respectively;
Comparing unit, suitable for each code data block saved, by itself and one or more code datas for being saved Block is compared, and determines that this in said program code specifies the identical code data block of content of class.
Optionally,
The storage unit, suitable for each code data block isolated to be named with class, method name and parameter information.
Optionally,
The comparing unit is suitable for using Karp-Rabin string matching algorithm, to each code data block saved, It is compared with the one or more code data blocks saved.
Optionally,
The code data block of the specified class refers to the code data block of method class.
Optionally, which further comprises:
An identification code is respectively set in setting unit, each code data block being suitable in said program code;
Output unit, when being suitable for said program code operation, according to the operation progress of said program code, by each code number It is output in said program code running log according to the identification code of block;
Error Location determination unit is suitable for running day according to said program code when said program code runs and malfunctions The identification code in will determines the position of said program code operation error.
Optionally,
The setting unit is suitable for one identification switch of setting;
The output unit judges the state that the identification switch is presently in when being suitable for said program code operation;When When the state that the identification switch is currently at out, according to the operation progress of said program code, by the mark of each code data block Know code to be output in said program code running log.
Optionally, which further comprises:
Interface provides unit, is adapted to provide for web page editing interface;
Code generating unit is suitable for according to the web page editing interface webpage pattern editing parameter, based on the received The webpage pattern editing parameter generates the pattern program code of webpage.
Optionally, the webpage pattern editing parameter includes one or more of:
The font of text, font size, font color, the size of page elements, the position of page elements, page elements Shape.
According to another aspect of the invention, a kind of electronic equipment is provided, wherein the electronic equipment includes:
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the place when executed Device is managed to execute according to method above-mentioned.
In accordance with a further aspect of the present invention, a kind of computer readable storage medium is provided, wherein described computer-readable Storage medium stores one or more programs, and one or more of programs when being executed by a processor, realize method above-mentioned.
According to the technique and scheme of the present invention, the abstract syntax tree of program code is obtained;According to abstract syntax tree, journey is isolated The code data block of class is specified in sequence code;It is saved after each code data block isolated is named respectively;To being saved Each code data block, it is compared with the one or more code data blocks saved, determines that this in program code refers to Determine the identical code data block of content of class.By the technical program, the identical code of content in program code can be determined Data block reduces the error rate of program code operation to eliminate the redundancy in program code, enhances user experience.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention, And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage can It is clearer and more comprehensible, the followings are specific embodiments of the present invention.
Detailed description of the invention
By reading the following detailed description of the preferred embodiment, various other advantages and benefits are common for this field Technical staff will become clear.The drawings are only for the purpose of illustrating a preferred embodiment, and is not considered as to the present invention Limitation.And throughout the drawings, the same reference numbers will be used to refer to the same parts.In the accompanying drawings:
Fig. 1 shows the flow diagram of the processing method of program code according to an embodiment of the invention;
Fig. 2 shows the structural schematic diagrams of the processing unit of program code according to an embodiment of the invention;
Fig. 3 shows the structural schematic diagram of electronic equipment according to an embodiment of the invention;
Fig. 4 shows the structural schematic diagram of computer readable storage medium according to an embodiment of the invention.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here It is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure It is fully disclosed to those skilled in the art.
Fig. 1 shows the flow diagram of the processing method of program code according to an embodiment of the invention.Such as Fig. 1 institute Show, this method comprises:
Step S110 obtains the abstract syntax tree of program code.
In the present embodiment, which is one section of specified code, which can be a certain application program Whole program codes or realize specific function program code, be also possible to the program code of some system, herein Specific restriction is not done.
In the present embodiment, the abstract syntax tree for obtaining program code can be by the application program of calling abstract syntax tree Programming interface (Application Programming Interface, abbreviation API) is obtained.Here abstract syntax tree It is exactly the analytic tree after the parsing to this section of program code, each code data block of the program code can be carried out in the analytic tree Parsing.
Step S120 isolates the code data block that class is specified in program code according to abstract syntax tree.
Here class is then the object having in program code with attribute, only has the object with attribute, realizes Function be likely to be it is identical, be likely to the case where will appear redundant code, therefore in order to eliminate the redundancy of program code, need The identical program code of content in specified class is determined.For example, referring to the method for realizing specific function in program code The code data block of function class.
Step S130 is saved after being named each code data block isolated respectively.
As long as the code data block for the specified class for including in the program code be not one, in order to by each code data block into Row difference, needs to be named each code data block isolated, and the filename as each code data block is saved, this In order need to be unique identification, just can be carried out the differentiation of each code data block.
For example, each code data block is numbered, each number represents a code data block;Or according to each code The cryptographic Hash of data block is named.
Step S140, to each code data block saved, by its with one or more code data blocks for being saved into Row compares, and determines that this in program code specifies the identical code data block of content of class.
In the present embodiment, the content of each code data block saved is compared two-by-two, for example, word can be passed through The mode that symbol string compares.Content is identical, it is determined that the two of comparison is the identical code data block of content of the instruction class.If It needs to eliminate the redundancy of the program code, then the identical code data block of the content can be retained one, other adaptability Deletion.
For example, the quantity of code data block saved is 100, when being compared, by the content of the 1st code data block with The content of other 99 code data blocks is compared, by the content of the 2nd code data block and other 98 code data blocks Content be compared, and so on.
As it can be seen that the identical code data block of content in program code can be determined, to eliminate by the technical program Redundancy in program code reduces the error rate of program code operation, enhances user experience.
In one embodiment of the invention, each code data block isolated being named respectively in step S130 It include: that each code data block that will be isolated is named with class, method name and parameter information.
In simple terms, the class of code data block here is with the object with attribute, and method name is then in one kind An object carry out operation, parameter information be an object has specifically been carried out which type of operation.In the present embodiment, Using class+method name+parameter information form of each code data block as the title of the file of each code data block.
In one embodiment of the invention, in step S140 to each code data block saved, by its with protected It includes: using Karp-Rabin string matching algorithm, to what is saved that the one or more code data blocks deposited, which are compared, It is compared each code data block with the one or more code data blocks saved.
In order to improve the efficiency of comparison, implemented in the present embodiment using Karp-Rabin string matching algorithm.Karp- Rabin string matching algorithm is that each corresponding character is compared, and character is pre-processed, that is, to each character Corresponding system number and modulo operation are carried out, calculates its functional value similar to by certain function, what is compared is the letter of each character Numerical value.
In one embodiment of the invention, the code data block of the specified class in the various embodiments described above refers to method class Code data block.
Here the code data block of method class is the code data block of method function class.
After the completion of program code exploitation, need to run the program code, if operation error, is also repaired It is multiple, accordingly, it is determined that the position of operation error is critically important.
Under normal conditions, it in order to avoid the program code of exploitation is carried out decompiling by other people, needs to carry out program code Obscure, but the program code after obscuring can not show the position of error in running log when running error.? In one embodiment of the present of invention, method shown in FIG. 1 further comprises: setting respectively for each code data block in program code Set an identification code;When program code is run, according to the operation progress of program code, the identification code of each code data block is output to In program code running log;When program code, which is run, to malfunction, according to the identification code in program code running log, journey is determined The position of sequence code operation error.
The identification code can be debug identification code, identify when to each code data block setting debug in program code Afterwards, when program is run, the identification code of each code data block is output in program code running log;Once program code is transported When row error, according to the identification code for going out fault in program code running log, the position of program code operation error is determined.
For example, 1,2,3,4,5 are individually identified as to five code data blocks in program code, when Cheng Xun runs to first When a code data block, 1 can be exported in program code running log, it, can be in journey when running to second code data block 2 are exported in sequence code running log, if after code runs to the 4th code data block error, according in running log, should go out Wrong position is to be assured that the position of program code error is exactly to identify between the mark 4 and mark 5 of word output in this way In code data block between 4 and mark 5.
Further, method shown in FIG. 1 further comprises: one identification switch of setting;When program code is run, according to journey The operation progress of sequence code, it includes: program code that the identification code of each code data block, which is output in program code running log, When operation, the state that identification switch is presently in is judged;When the state that identification switch is currently at out, according to program code The identification code of each code data block is output in program code running log by operation progress.
In the present embodiment, in order to not influence the efficiency and globality of program code operation, an identification switch is set, such as Debug switch just exports each code data block when program code is run only when debug switch is in the state opened Mark, if do not exported in debug switch in the state closed.For example, when program code is run, it can be by identification switch It is set to off, when finding program code operation error, for the ease of determining the position of error, will can indicate switch setting again To open, the fast position for reading to navigate to error.
In one embodiment of the invention, method shown in FIG. 1 further comprises: providing web page editing interface;According to Web page editing interface webpage pattern editing parameter, webpage pattern editing parameter generates the pattern program of webpage based on the received Code.
In the present embodiment, above-mentioned program code can be the program code of the web page editing of user's progress, but right For the user for infrequently editing webpage, when carrying out web page editing, the setting to the editing parameter of the pattern of webpage is to compare Difficult.In the present embodiment, the interface of a web page editing is provided, user can be by the interface to the parameter of webpage pattern It is set, automatically generates corresponding pattern program code, such as CSS program code.Have great convenience for the user, enhances use The usage experience at family.
Specifically, above-mentioned webpage pattern editing parameter includes one or more of: the font of text, font size, Font color, the size of page elements, the position of page elements, page elements shape.
In the present embodiment, the edition interface of font style is provided, so that user is to the font, font size, word of text The editor of body color.In the present embodiment, user can change the frame of page elements by the position of dragging setting web page element Size setting page elements size, and according to the interface of offer select page elements shape.Here page elements It can be understood as the various pieces in the page, for example, placing the part of video, place the part etc. of advertisement.
Fig. 2 shows the structural schematic diagrams of the processing unit of program code according to an embodiment of the invention.Such as Fig. 2 institute Show, the processing unit 200 of the program code includes:
Acquiring unit 210, suitable for obtaining the abstract syntax tree of program code.
In the present embodiment, which is one section of specified code, which can be a certain application program Whole program codes or realize specific function program code, be also possible to the program code of some system, herein Specific restriction is not done.
In the present embodiment, the abstract syntax tree for obtaining program code can be by the application program of calling abstract syntax tree Programming interface (Application Programming Interface, abbreviation API) is obtained.Here abstract syntax tree It is exactly the analytic tree after the parsing to this section of program code, each code data block of the program code can be carried out in the analytic tree Parsing.
Separative unit 220 is suitable for isolating the code data block that class is specified in program code according to abstract syntax tree.
Here class is then the object having in program code with attribute, only has the object with attribute, realizes Function be likely to be it is identical, be likely to the case where will appear redundant code, therefore in order to eliminate the redundancy of program code, need The identical program code of content in specified class is determined.For example, referring to the method for realizing specific function in program code The code data block of function class.
Storage unit 230, suitable for being saved after being named each code data block isolated respectively.
As long as the code data block for the specified class for including in the program code be not one, in order to by each code data block into Row difference, needs to be named each code data block isolated, and the filename as each code data block is saved, this In order need to be unique identification, just can be carried out the differentiation of each code data block.
For example, each code data block is numbered, each number represents a code data block;Or according to each code The cryptographic Hash of data block is named.
Comparing unit 240, suitable for each code data block saved, by itself and one or more code numbers for being saved It is compared according to block, determines that this in program code specifies the identical code data block of content of class.
In the present embodiment, the content of each code data block saved is compared two-by-two, for example, word can be passed through The mode that symbol string compares.Content is identical, it is determined that the two of comparison is the identical code data block of content of the instruction class.If It needs to eliminate the redundancy of the program code, then the identical code data block of the content can be retained one, other adaptability Deletion.
For example, the quantity of code data block saved is 100, when being compared, by the content of the 1st code data block with The content of other 99 code data blocks is compared, by the content of the 2nd code data block and other 98 code data blocks Content be compared, and so on.
As it can be seen that the identical code data block of content in program code can be determined, to eliminate by the technical program Redundancy in program code reduces the error rate of program code operation, enhances user experience.
In one embodiment of the invention, storage unit 230, suitable for by each code data block isolated with class, side Religious name and parameter information are named.
In simple terms, the class of code data block here is with the object with attribute, and method name is then in one kind An object carry out operation, parameter information be an object has specifically been carried out which type of operation.In the present embodiment, Using class+method name+parameter information form of each code data block as the title of the file of each code data block.
In one embodiment of the invention, comparing unit 240 are suitable for using Karp-Rabin string matching algorithm, To each code data block saved, it is compared with the one or more code data blocks saved.
In order to improve the efficiency of comparison, implemented in the present embodiment using Karp-Rabin string matching algorithm.Karp- Rabin string matching algorithm is that each corresponding character is compared, and character is pre-processed, that is, to each character Corresponding system number and modulo operation are carried out, calculates its functional value similar to by certain function, what is compared is the letter of each character Numerical value.
In one embodiment of the invention, the code data block of the specified class in the various embodiments described above refers to method class Code data block.
Here the code data block of method class is the code data block of method function class.
After the completion of program code exploitation, need to run the program code, if operation error, is also repaired It is multiple, accordingly, it is determined that the position of operation error is critically important.
Under normal conditions, it in order to avoid the program code of exploitation is carried out decompiling by other people, needs to carry out program code Obscure, but the program code after obscuring can not show the position of error in running log when running error.? In one embodiment of the present of invention, device shown in Fig. 2 further comprises:
An identification code is respectively set in setting unit, each code data block being suitable in program code.
Output unit, when being suitable for program code operation, according to the operation progress of program code, by the mark of each code data block Know code to be output in program code running log.
Error Location determination unit is suitable for when program code runs and malfunctions, according to the mark in program code running log Know code, determines the position of program code operation error.
The identification code can be debug identification code, identify when to each code data block setting debug in program code Afterwards, when program is run, the identification code of each code data block is output in program code running log;Once program code is transported When row error, according to the identification code for going out fault in program code running log, the position of program code operation error is determined.
For example, 1,2,3,4,5 are individually identified as to five code data blocks in program code, when Cheng Xun runs to first When a code data block, 1 can be exported in program code running log, it, can be in journey when running to second code data block 2 are exported in sequence code running log, if after code runs to the 4th code data block error, according in running log, should go out Wrong position is to be assured that the position of program code error is exactly to identify between the mark 4 and mark 5 of word output in this way In code data block between 4 and mark 5.
Further, above-mentioned setting unit is suitable for one identification switch of setting.
Above-mentioned output unit judges the state that identification switch is presently in when being suitable for program code operation;When mark is opened When closing the state being currently at out, according to the operation progress of program code, the identification code of each code data block is output to program In code running log.
In the present embodiment, in order to not influence the efficiency and globality of program code operation, an identification switch is set, such as Debug switch just exports each code data block when program code is run only when debug switch is in the state opened Mark, if do not exported in debug switch in the state closed.For example, when program code is run, it can be by identification switch It is set to off, when finding program code operation error, for the ease of determining the position of error, will can indicate switch setting again To open, the fast position for reading to navigate to error.
In one embodiment of the invention, device shown in Fig. 2 further comprises:
Interface provides unit, is adapted to provide for web page editing interface.
Code generating unit is suitable for according to web page editing interface webpage pattern editing parameter, based on the received webpage The pattern program code of pattern editing parameter generation webpage.
In the present embodiment, above-mentioned program code can be the program code of the web page editing of user's progress, but right For the user for infrequently editing webpage, when carrying out web page editing, the setting to the editing parameter of the pattern of webpage is to compare Difficult.In the present embodiment, the interface of a web page editing is provided, user can be by the interface to the parameter of webpage pattern It is set, automatically generates corresponding pattern program code, such as CSS program code.Have great convenience for the user, enhances use The usage experience at family.
Specifically, above-mentioned webpage pattern editing parameter includes one or more of: the font of text, font size, Font color, the size of page elements, the position of page elements, page elements shape.
In the present embodiment, the edition interface of font style is provided, so that user is to the font, font size, word of text The editor of body color.In the present embodiment, user can change the frame of page elements by the position of dragging setting web page element Size setting page elements size, and according to the interface of offer select page elements shape.Here page elements It can be understood as the various pieces in the page, for example, placing the part of video, place the part etc. of advertisement.
The present invention also provides a kind of electronic equipment, wherein the electronic equipment includes:
Processor;And
It is arranged to the memory of storage computer executable instructions, executable instruction executes processor when executed The processing method of program code according to figure 1 and its each embodiment.
Fig. 3 shows the illustrative view of functional configuration of electronic equipment according to an embodiment of the invention.As shown in figure 3, should Electronic equipment 300 includes:
Processor 310;And it is arranged to the memory 320 of storage computer executable instructions (program code), it is depositing In reservoir 320, there is the memory space 330 of storage program code, for executing the program code of steps of a method in accordance with the invention 340 are stored in memory space 330, and it is according to figure 1 and its each which when executed execute processor 310 The processing method of program code in embodiment.
Fig. 4 shows a kind of structural schematic diagram of computer readable storage medium according to an embodiment of the invention.Such as Shown in Fig. 4, which stores one or more programs (program code) 410, one or more programs (program code) 410 when being executed by a processor, realizes the processing side of the program code in shown in FIG. 1 and its each embodiment Method.
It should be noted that each embodiment of electronic equipment shown in Fig. 3 and computer readable storage medium shown in Fig. 4 It is corresponding identical as each embodiment of method shown in FIG. 1, it has been described in detail above, details are not described herein.
In conclusion according to the technique and scheme of the present invention, obtaining the abstract syntax tree of program code;According to abstract syntax Tree isolates the code data block that class is specified in program code;It is protected after each code data block isolated is named respectively It deposits;To each code data block saved, it is compared with the one or more code data blocks saved, determines program This in code specifies the identical code data block of content of class.By the technical program, the content in program code can be determined Identical code data block reduces the error rate of program code operation to eliminate the redundancy in program code, enhances user's body It tests.
It should be understood that
Algorithm and display be not inherently related to any certain computer, virtual bench or other equipment provided herein. Various fexible units can also be used together with teachings based herein.As described above, it constructs required by this kind of device Structure be obvious.In addition, the present invention is also not directed to any particular programming language.It should be understood that can use various Programming language realizes summary of the invention described herein, and the description done above to language-specific is to disclose this hair Bright preferred forms.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that implementation of the invention Example can be practiced without these specific details.In some instances, well known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this specification.
Similarly, it should be understood that in order to simplify the disclosure and help to understand one or more of the various inventive aspects, Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes In example, figure or descriptions thereof.However, the disclosed method should not be interpreted as reflecting the following intention: i.e. required to protect Shield the present invention claims features more more than feature expressly recited in each claim.More precisely, as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itself All as a separate embodiment of the present invention.
Those skilled in the art will understand that can be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more devices different from this embodiment.It can be the module or list in embodiment Member or component are combined into a module or unit or component, and furthermore they can be divided into multiple submodule or subelement or Sub-component.Other than such feature and/or at least some of process or unit exclude each other, it can use any Combination is to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so disclosed All process or units of what method or apparatus are combined.Unless expressly stated otherwise, this specification is (including adjoint power Benefit require, abstract and attached drawing) disclosed in each feature can carry out generation with an alternative feature that provides the same, equivalent, or similar purpose It replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments In included certain features rather than other feature, but the combination of the feature of different embodiments mean it is of the invention Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed Meaning one of can in any combination mode come using.
Various component embodiments of the invention can be implemented in hardware, or to run on one or more processors Software module realize, or be implemented in a combination thereof.It will be understood by those of skill in the art that can be used in practice Microprocessor or digital signal processor (DSP) realize processing unit, the electricity of program code according to an embodiment of the present invention The some or all functions of some or all components in sub- equipment and computer readable storage medium.The present invention can be with Some or all device or device programs for executing method as described herein are embodied as (for example, computer Program and computer program product).It is such to realize that program of the invention can store on a computer-readable medium, Huo Zheke With in the form of one or more signals.Such signal can be downloaded from an internet website to obtain, or in carrier It provides, or is provided in any other form on signal.
For example, Fig. 3 shows the structural schematic diagram of electronic equipment according to an embodiment of the invention.The electronic equipment 300 conventionally comprise processor 310 and are arranged to the memory 320 of storage computer executable instructions (program code).It deposits Reservoir 320 can be such as flash memory, EEPROM (electrically erasable programmable read-only memory), EPROM, hard disk or ROM etc Electronic memory.Memory 320 has storage for executing any method and step in shown in FIG. 1 and each embodiment The memory space 330 of program code 340.For example, the memory space 330 for program code may include being respectively used to realization Each program code 340 of various steps in the method in face.These program codes can be from one or more computer journey It reads or is written in sequence product in this one or more computer program product.These computer program products include all Such as hard disk, the program code carrier of compact-disc (CD), storage card or floppy disk etc.Such computer program product is usually Such as the computer readable storage medium 400 of Fig. 4.The computer readable storage medium 400 can have the electronic equipment with Fig. 3 In 320 similar arrangement of memory memory paragraph, memory space etc..Program code can for example be compressed in a suitable form. In general, storage unit is stored with the program code 410 for executing steps of a method in accordance with the invention, it can by such as 310 Etc processor read program code, when these program codes are run by electronic equipment, cause the electronic equipment execute Each step in method described above.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and ability Field technique personnel can be designed alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference symbol between parentheses should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not Element or step listed in the claims.Word "a" or "an" located in front of the element does not exclude the presence of multiple such Element.The present invention can be by means of including the hardware of several different elements and being come by means of properly programmed computer real It is existing.In the unit claims listing several devices, several in these devices can be through the same hardware branch To embody.The use of word first, second, and third does not indicate any sequence.These words can be explained and be run after fame Claim.
The invention discloses A1, a kind of processing method of program code, wherein this method comprises:
Obtain the abstract syntax tree of program code;
According to the abstract syntax tree, the code data block that class is specified in said program code is isolated;
It is saved after each code data block isolated is named respectively;
To each code data block saved, it is compared with the one or more code data blocks saved, really Determine the identical code data block of content that this in said program code specifies class.
A2, method as described in a1, wherein each code data block that will be isolated is named respectively includes:
Each code data block isolated is named with class, method name and parameter information.
A3, method as described in a1, wherein it is described to each code data block saved, by itself and saved one Or multiple code data blocks are compared and include:
Using Karp-Rabin string matching algorithm, to each code data block saved, by its with saved one A or multiple code data blocks are compared.
A4, method as described in a1, wherein
The code data block of the specified class refers to the code data block of method class.
A5, method as described in a1, wherein this method further comprises:
An identification code is respectively set for each code data block in said program code;
When said program code is run, according to the operation progress of said program code, by the identification code of each code data block It is output in said program code running log;
When said program code, which is run, to malfunction, according to the identification code in said program code running log, determine The position of said program code operation error.
A6, method as described in a5, wherein this method further comprises:
One identification switch is set;
When said program code is run, according to the operation progress of said program code, by the identification code of each code data block It is output in said program code running log and includes:
When said program code is run, the state that the identification switch is presently in is judged;
When the state that the identification switch is currently at out, according to the operation progress of said program code, by each code The identification code of data block is output in said program code running log.
A7, method as described in a1, wherein this method further comprises:
Web page editing interface is provided;
According to the web page editing interface webpage pattern editing parameter, the webpage pattern editor joins based on the received Number generates the pattern program code of webpage.
A8, the method as described in A7, wherein the webpage pattern editing parameter includes one or more of:
The font of text, font size, font color, the size of page elements, the position of page elements, page elements Shape.
The invention also discloses B9, a kind of processing unit of program code, wherein the device includes:
Acquiring unit, suitable for obtaining the abstract syntax tree of program code;
Separative unit is suitable for isolating the code data that class is specified in said program code according to the abstract syntax tree Block;
Storage unit, suitable for being saved after being named each code data block isolated respectively;
Comparing unit, suitable for each code data block saved, by itself and one or more code datas for being saved Block is compared, and determines that this in said program code specifies the identical code data block of content of class.
B10, the device as described in B9, wherein
The storage unit, suitable for each code data block isolated to be named with class, method name and parameter information.
B11, the device as described in B9, wherein
The comparing unit is suitable for using Karp-Rabin string matching algorithm, to each code data block saved, It is compared with the one or more code data blocks saved.
B12, the device as described in B9, wherein
The code data block of the specified class refers to the code data block of method class.
B13, the device as described in B9, wherein the device further comprises:
An identification code is respectively set in setting unit, each code data block being suitable in said program code;
Output unit, when being suitable for said program code operation, according to the operation progress of said program code, by each code number It is output in said program code running log according to the identification code of block;
Error Location determination unit is suitable for running day according to said program code when said program code runs and malfunctions The identification code in will determines the position of said program code operation error.
B14, the device as described in B13, wherein
The setting unit is suitable for one identification switch of setting;
The output unit judges the state that the identification switch is presently in when being suitable for said program code operation;When When the state that the identification switch is currently at out, according to the operation progress of said program code, by the mark of each code data block Know code to be output in said program code running log.
B15, the device as described in B9, wherein the device further comprises:
Interface provides unit, is adapted to provide for web page editing interface;
Code generating unit is suitable for according to the web page editing interface webpage pattern editing parameter, based on the received The webpage pattern editing parameter generates the pattern program code of webpage.
B16, the device as described in B15, wherein the webpage pattern editing parameter includes one or more of:
The font of text, font size, font color, the size of page elements, the position of page elements, page elements Shape.
The invention also discloses C17, a kind of electronic equipment, wherein the electronic equipment includes:
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the place when executed It manages device and executes the method according to any one of A1~A8.
The invention also discloses D18, a kind of computer readable storage medium, wherein the computer readable storage medium One or more programs are stored, one or more of programs when being executed by a processor, are realized described in any one of A1~A8 Method.

Claims (10)

1. a kind of processing method of program code, wherein this method comprises:
Obtain the abstract syntax tree of program code;
According to the abstract syntax tree, the code data block that class is specified in said program code is isolated;
It is saved after each code data block isolated is named respectively;
To each code data block saved, it is compared with the one or more code data blocks saved, determines institute State the identical code data block of content that this in program code specifies class.
2. the method for claim 1, wherein each code data block that will be isolated is named respectively includes:
Each code data block isolated is named with class, method name and parameter information.
3. the method for claim 1, wherein described to each code data block saved, by its with saved one A or multiple code data blocks, which are compared, includes:
Using Karp-Rabin string matching algorithm, to each code data block saved, by it with one saved or Multiple code data blocks are compared.
4. the method for claim 1, wherein
The code data block of the specified class refers to the code data block of method class.
5. the method for claim 1, wherein this method further comprises:
An identification code is respectively set for each code data block in said program code;
When said program code is run, according to the operation progress of said program code, the identification code of each code data block is exported Into said program code running log;
When said program code, which is run, to malfunction, according to the identification code in said program code running log, determine described in The position of program code operation error.
6. method as claimed in claim 5, wherein this method further comprises:
One identification switch is set;
When said program code is run, according to the operation progress of said program code, the identification code of each code data block is exported Include: into said program code running log
When said program code is run, the state that the identification switch is presently in is judged;
When the state that the identification switch is currently at out, according to the operation progress of said program code, by each code data The identification code of block is output in said program code running log.
7. the method for claim 1, wherein this method further comprises:
Web page editing interface is provided;
According to the web page editing interface webpage pattern editing parameter, the webpage pattern editing parameter is raw based on the received At the pattern program code of webpage.
8. a kind of processing unit of program code, wherein the device includes:
Acquiring unit, suitable for obtaining the abstract syntax tree of program code;
Separative unit is suitable for isolating the code data block that class is specified in said program code according to the abstract syntax tree;
Storage unit, suitable for being saved after being named each code data block isolated respectively;
Comparing unit, suitable for each code data block saved, by its with one or more code data blocks for being saved into Row compares, and determines that this in said program code specifies the identical code data block of content of class.
9. a kind of electronic equipment, wherein the electronic equipment includes:
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the processor when executed Execute method according to any one of claims 1 to 7.
10. a kind of computer readable storage medium, wherein the computer-readable recording medium storage one or more program, One or more of programs when being executed by a processor, realize method according to any one of claims 1 to 7.
CN201711447799.9A 2017-12-27 2017-12-27 A kind for the treatment of method and apparatus of program code Pending CN109976991A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711447799.9A CN109976991A (en) 2017-12-27 2017-12-27 A kind for the treatment of method and apparatus of program code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711447799.9A CN109976991A (en) 2017-12-27 2017-12-27 A kind for the treatment of method and apparatus of program code

Publications (1)

Publication Number Publication Date
CN109976991A true CN109976991A (en) 2019-07-05

Family

ID=67071729

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711447799.9A Pending CN109976991A (en) 2017-12-27 2017-12-27 A kind for the treatment of method and apparatus of program code

Country Status (1)

Country Link
CN (1) CN109976991A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111552638A (en) * 2020-04-23 2020-08-18 北京奇艺世纪科技有限公司 Code detection method and device
WO2021197273A1 (en) * 2020-04-03 2021-10-07 深圳前海微众银行股份有限公司 Redundant code removing method, apparatus and device, and computer readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976318A (en) * 2010-11-15 2011-02-16 北京理工大学 Detection method of code similarity based on digital fingerprints
US8683454B1 (en) * 2012-06-20 2014-03-25 Xilinx, Inc. Reducing redundancy in source code
CN105426711A (en) * 2015-11-18 2016-03-23 北京理工大学 Similarity detection method of computer software source code
CN106547653A (en) * 2015-09-21 2017-03-29 龙芯中科技术有限公司 Computer system fault condition detection method, apparatus and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976318A (en) * 2010-11-15 2011-02-16 北京理工大学 Detection method of code similarity based on digital fingerprints
US8683454B1 (en) * 2012-06-20 2014-03-25 Xilinx, Inc. Reducing redundancy in source code
CN106547653A (en) * 2015-09-21 2017-03-29 龙芯中科技术有限公司 Computer system fault condition detection method, apparatus and system
CN105426711A (en) * 2015-11-18 2016-03-23 北京理工大学 Similarity detection method of computer software source code

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
吴冲: "基于抽象语法树的重复代码检测", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021197273A1 (en) * 2020-04-03 2021-10-07 深圳前海微众银行股份有限公司 Redundant code removing method, apparatus and device, and computer readable storage medium
CN111552638A (en) * 2020-04-23 2020-08-18 北京奇艺世纪科技有限公司 Code detection method and device
CN111552638B (en) * 2020-04-23 2023-08-18 北京奇艺世纪科技有限公司 Code detection method and device

Similar Documents

Publication Publication Date Title
US20210334093A1 (en) Automating Identification of Code Snippets for Library Suggestion Models
CN105446775B (en) The configuration metaplasia of game installation kit is at method and device
US20240126543A1 (en) Library Model Addition
US9134966B2 (en) Management of mixed programming languages for a simulation environment
CN106095620B (en) A kind of development approach of built-in Linux partition holding
EP3679469A1 (en) Automating identification of test cases for library suggestion models
US20190079753A1 (en) Automating Generation of Library Suggestion Engine Models
CN102402451B (en) Compile-time bounds checking for user-defined types
US20040025083A1 (en) Generating test code for software
GB2508643A (en) Method for Performing a Regression Test after Modifying Source Code File
CN108139891A (en) Include suggesting for the missing of external file
CN104346206B (en) A kind of method and system of unloaded software rejuvenation installation
CN105446725A (en) Method and system for model driven development
WO2017025940A1 (en) Static analysis and reconstruction of deep link handling in compiled applications
CN104503778A (en) Installation method and installation device for applications
CN108846264A (en) Code reinforcement means, device, intelligent terminal and computer readable storage medium
US9129137B2 (en) Method, computer program and device for providing security for intermediate programming code for its execution by a virtual machine
CN109976991A (en) A kind for the treatment of method and apparatus of program code
US8196093B2 (en) Apparatus and method for componentizing legacy system
US20150120682A1 (en) Automated recognition of patterns in a log file having unknown grammar
US20140229915A1 (en) Debugger with previous version feature
CN108460254A (en) Firmware guard method and device
EP3818437B1 (en) Binary software composition analysis
CN103049302B (en) The method of the strcpy standard library function assembly code optimized by Program Generating
US10120664B2 (en) Incremental build generation

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190705

RJ01 Rejection of invention patent application after publication