CN110321138A - A kind of program updates, moving method and device - Google Patents
A kind of program updates, moving method and device Download PDFInfo
- Publication number
- CN110321138A CN110321138A CN201810267305.7A CN201810267305A CN110321138A CN 110321138 A CN110321138 A CN 110321138A CN 201810267305 A CN201810267305 A CN 201810267305A CN 110321138 A CN110321138 A CN 110321138A
- Authority
- CN
- China
- Prior art keywords
- frame
- ast
- file
- original program
- dynamic call
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/51—Source to source
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/75—Structural analysis for program understanding
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the present application provides that a kind of program updates, moving method and device, described program update method include: to obtain original program file;The code file is converted to abstract syntax tree AST by the code file for reading the original program file;The AST is traversed, the static defining based on original program frame in the AST is converted into the static defining based on new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame is the dynamic call object based on new procedures frame;Modified AST is converted into code file.In the embodiment of the present application, AST is converted to by the code file to program file, then the static defining based on original program frame in AST is converted into the static defining based on new procedures frame, and by the dynamic call object dispatching in AST based on original program frame be the dynamic call object based on new procedures frame, automation code file can be updated in the case where program frame upgrades, and there is good universality.
Description
Technical field
This application involves program technic fields, more particularly to a kind of method for updating program, a kind of program renewing device, one
Kind migration of programs method and a kind of migration of programs function device.
Background technique
Program frame is a kind of system of offer programming reusability, and developer can be based on according to business demand in process block
Program file is developed on frame.
With the development of programming, some old program frames are unable to satisfy business development demand, it is therefore desirable to journey
Sequence frame is upgraded.When program frame upgrading, the program file based on original program Development of Framework can not be in new procedures frame
Lower normal operation.
Since program frame upgrades, it is related to the adjustment of the programming models such as grammer, timing, is difficult to be directly compatible with adaptable interface.
Even if compatible, also heavy maintenance load and unpredictable problem is caused to leave new skeleton code.For this upgrading
Mode, it usually needs artificial reconstruction's program file, but the mode low efficiency of artificial reconstruction, universality is not strong, encounters history service
It is time-consuming and laborious when more.
Summary of the invention
In view of the above problems, it proposes the embodiment of the present application and overcomes the above problem or at least partly in order to provide one kind
A kind of method for updating program, a kind of program renewing device, a kind of migration of programs method and a kind of program to solve the above problems is moved
Move function device.
To solve the above-mentioned problems, the embodiment of the present application discloses a kind of method for updating program, comprising:
Obtain original program file;
The code file is converted to abstract syntax tree AST by the code file for reading the original program file;
The AST is traversed, the static defining based on original program frame in the AST is converted to based on new procedures frame
Static defining, and by the dynamic call object dispatching in the AST based on original program frame be dynamic based on new procedures frame
State calls object;
Modified AST is converted into code file.
Preferably, further includes:
The configuration file of the original program file is read, and the configuration file is updated;
In conjunction with the configuration file and the code file, updated program file is obtained.
Preferably, the traversal AST, the static defining based on original program frame in the AST is converted to and is based on
The static defining of new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new
The dynamic call object step of program frame includes:
The AST is traversed, it is regular according to preset static defining rule change and preset dynamic call object dispatching,
The AST is converted;Wherein, the static defining rule change is to be converted to the static defining based on original program frame
The rule of static defining based on new procedures frame;The dynamic call object dispatching rule is will be based on the dynamic of original program frame
It is the rule of the dynamic call object based on new procedures frame that state, which calls object dispatching,.
It is preferably, described regular according to preset static defining rule change and preset dynamic call object dispatching,
The step of converting to the AST include:
, with the matched static defining node of the static defining rule change, it will become by the static defining in the AST
Change rule to be converted.
It is preferably, described regular according to preset static defining rule change and preset dynamic call object dispatching,
The step of AST is converted further include:
Using the compatibility code generated according to the preset dynamic call object dispatching rule, will be based in the AST
The dynamic call object dispatching of original program frame is the dynamic call object based on new procedures frame.
Preferably, described the step of being updated to the configuration file, includes:
According to the frame more new information between the original program frame and the new procedures frame, in more new configuration file with
The frame updates the information of information matches.
The embodiment of the present application also discloses a kind of migration of programs method, comprising:
Original program file is obtained from raw address;
The code file is converted to abstract syntax tree AST by the code file for reading the original program file;
The AST is traversed, the static defining based on original program frame in the AST is converted to based on new procedures frame
Static defining, and by the dynamic call object dispatching in the AST based on original program frame be dynamic based on new procedures frame
State calls object;
Modified AST is converted into code file, and code file is written to destination address.
Preferably, further includes:
It traverses the program directory of the original program file and described program catalogue is copied to the destination address;
The configuration file for reading the original program file, is updated the configuration file, and by updated configuration
The destination address that file is write;
By in the original program file it is not necessary to modify file copy to the destination address;
In conjunction with described program catalogue, the configuration file, the code file and it is described it is not necessary to modify file, as
Updated program file.
Preferably, the traversal AST, the static defining based on original program frame in the AST is converted to and is based on
The static defining of new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new
The dynamic call object step of program frame includes:
The AST is traversed, it is regular according to preset static defining rule change and preset dynamic call object dispatching,
The AST is converted;Wherein, the static defining rule change is to be converted to the static defining based on original program frame
The rule of static defining based on new procedures frame;The dynamic call object dispatching rule is will be based on the dynamic of original program frame
It is the rule of the dynamic call object based on new procedures frame that state, which calls object dispatching,.
It is preferably, described regular according to preset static defining rule change and preset dynamic call object dispatching,
The step of converting to the AST include:
, with the matched static defining node of the static defining rule change, it will become by the static defining in the AST
Change rule to be converted.
It is preferably, described regular according to preset static defining rule change and preset dynamic call object dispatching,
The step of AST is converted further include:
Using the compatibility code generated according to the preset dynamic call object dispatching rule, will be based in the AST
The dynamic call object dispatching of original program frame is the dynamic call object based on new procedures frame.
Preferably, described the step of being updated to the configuration file, includes:
According to the frame more new information between the original program frame and the new procedures frame, in more new configuration file with
The frame updates the information of information matches.
The embodiment of the present application also discloses a kind of program renewing device, comprising:
Program obtains module, for obtaining original program file;
Syntax tree generation module is converted to the code file for reading the code file of the original program file
Abstract syntax tree AST;
Static defining based on original program frame in the AST is converted to base for traversing the AST by modified module
In the static defining of new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame be based on
The dynamic call object of new procedures frame;
Code file generation module, for modified AST to be converted to code file.
Preferably, further includes:
Configuration file update module, for reading the configuration file of the original program file, and to the configuration file into
Row updates;
More new procedures obtain module, for obtaining updated journey in conjunction with the configuration file and the code file
Preface part.
Preferably, the modified module includes:
Rules modification submodule, for traversing the AST, according to preset static defining rule change and preset dynamic
State calls object dispatching rule, converts to the AST;Wherein, the static defining rule change is that will be based on original program
The static defining of frame is converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule is
It is the rule of the dynamic call object based on new procedures frame by the dynamic call object dispatching based on original program frame.
Preferably, the rules modification submodule includes:
Static defining converting unit, for by the AST with the matched static defining of static defining rule change
Node is converted by the static defining rule change.
Preferably, the rules modification submodule further include:
Dynamic call object dispatching unit, for using according to the preset dynamic call object dispatching rule generation
Dynamic call object dispatching in the AST based on original program frame is the dynamic tune based on new procedures frame by compatibility code
Use object.
Preferably, the configuration file update module includes:
Configuration file update submodule, for according to the frame between the original program frame and the new procedures frame more
New information updates the information of information matches in more new configuration file with the frame.
The embodiment of the present application also discloses a kind of migration of programs device, comprising:
Program obtains module, for obtaining original program file from raw address;
Syntax tree generation module is converted to the code file for reading the code file of the original program file
Abstract syntax tree AST;
Static defining based on original program frame in the AST is converted to base for traversing the AST by modified module
In the static defining of new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame be based on
The dynamic call object of new procedures frame;
Code file for modified AST to be converted to code file, and is written to mesh by code file generation module
Mark address.
Preferably, further includes:
Catalogue copies module, for traversing the program directory of the original program file and described program catalogue being copied to institute
State destination address;
Configuration file update module carries out the configuration file for reading the configuration file of the original program file
It updates, and the destination address that updated configuration file is write;
Original copy module, for by the original program file it is not necessary to modify file copy to the target
Location;
More new procedures obtain module, in conjunction with described program catalogue, the configuration file, the code file and institute
State it is not necessary to modify file, as updated program file.
Preferably, the modified module includes:
Rules modification submodule, for traversing the AST, according to preset static defining rule change and preset dynamic
State calls object dispatching rule, converts to the AST;Wherein, the static defining rule change is that will be based on original program
The static defining of frame is converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule is
It is the rule of the dynamic call object based on new procedures frame by the dynamic call object dispatching based on original program frame.
Preferably, the rules modification submodule includes:
Static defining converting unit, for by the AST with the matched static defining of static defining rule change
Node is converted by the static defining rule change.
Preferably, the rules modification submodule further include:
Dynamic call object dispatching unit, for using according to the preset dynamic call object dispatching rule generation
Dynamic call object dispatching in the AST based on original program frame is the dynamic tune based on new procedures frame by compatibility code
Use object.
Preferably, the configuration file update module includes:
Configuration file update submodule, for according to the frame between the original program frame and the new procedures frame more
New information updates the information of information matches in more new configuration file with the frame.
The embodiment of the present application also discloses a kind of device, comprising:
One or more processors;With the one or more machine readable medias for being stored thereon with instruction, when by described one
When a or multiple processors execute, so that described device executes one or more method as described above.
The embodiment of the present application also discloses one or more machine readable medias, is stored thereon with instruction, when by one or
When multiple processors execute, so that device executes one or more method as described above.
The embodiment of the present application includes the following advantages:
In the embodiment of the present application, AST is converted to by the code file to program file, former journey then will be based in AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and will be dynamic based on original program frame in AST
It is the dynamic call object based on new procedures frame that state, which calls object dispatching, can be automated more in the case where program frame upgrades
Fresh code file, and there is good universality.
Detailed description of the invention
Fig. 1 is a kind of step flow chart of method for updating program embodiment one of the application;
Fig. 2 is a kind of step flow chart of method for updating program embodiment two of the application;
Fig. 3 is a kind of step flow chart of migration of programs embodiment of the method one of the application;
Fig. 4 is a kind of step flow chart of migration of programs embodiment of the method two of the application;
Fig. 5 is a kind of structural block diagram of program renewing device embodiment of the application;
Fig. 6 is a kind of structural block diagram of migration of programs Installation practice of the application.
Specific embodiment
In order to make the above objects, features, and advantages of the present application more apparent, with reference to the accompanying drawing and it is specific real
Applying mode, the present application will be further described in detail.
Referring to Fig.1, a kind of step flow chart of method for updating program embodiment one of the application is shown, specifically can wrap
Include following steps:
Step 101, original program file is obtained;
In the embodiment of the present application, the original program file based on original program Development of Framework is stored in the form of engineering.Exploitation
Person can need to create different engineerings according to business.
In general, program file may include: code file, configuration file, program directory, external dependence packet, test code
Deng.
Code file is the code for realizing particular traffic requirements write with programming language.
Configuration file file of required configuration parameter or customer parameter when being logging program operation.For example,
The configuration file of the configuration file of JSON format, XML format.
Program directory has recorded the hierarchical relationship of various files and file that program is included.
Outside relies on the code file that packet is the achievable specific function write in advance by third party developer, imports external
Packet is relied on into oneself program file, so that it may use external class, method and the attribute relied in packet.
Test code is the code for test program performance.After programming is completed, in order to detect the strong of code
Degree, memory usage, speed of service etc. and the code of bespoke.
Step 102, the code file is converted to abstract syntax tree by the code file for reading the original program file
AST;
Abstract syntax tree AST (abstract syntax tree) is the tree-shaped performance shape of the abstract syntax structure of code
Formula.By the way that code file is converted to AST, it the operation such as can more easily be analyzed code file, optimize, change.
Step 103, the AST is traversed, the static defining based on original program frame in the AST is converted to based on new journey
The static defining of sequence frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new procedures
The dynamic call object of frame;
Static defining refers to the definition of the organizational form to code file, the written in code mode, functional based method of component
Deng setting, static defining, which does not need operation program, to be analyzed.
In program frame after upgrading, the static defining needs based on the setting of original program frame are converted to based on new procedures frame
The static defining of frame, such program file will not just malfunction when using static defining.
Dynamic call object refers to the interface and parameter in code run time call.Old program frame provides program
The interface and parameter that file can call.After program frame upgrading, interface and parameter may be rewritten, therefore program text
Part can not normal call to interface and parameter.Therefore, it is necessary to by AST based on the dynamic call object dispatching of original program frame
For the dynamic call object based on new procedures frame, so that program file when needing calling interface or parameter, can call
For interface or parameter based on new procedures frame.
Step 104, modified AST is converted into code file.
After modifying AST, AST is converted back into code file again, completes the update to the code file of program file.
In the embodiment of the present application, AST is converted to by the code file to program file, former journey then will be based in AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and will be dynamic based on original program frame in AST
It is the dynamic call object based on new procedures frame that state, which calls object dispatching, can be automated more in the case where program frame upgrades
Fresh code file, and there is good universality.
When being updated to program, can be updated in the original address of program file.Referring to Fig. 2, show
A kind of step flow chart of method for updating program embodiment two of the application, can specifically include following steps:
Step 201, original program file is obtained;
Obtain the original program file based on original program frame.
Specifically, original program file is stored in the form of engineering, original program file can be obtained in the raw address of engineering.
Step 202, the configuration file of the original program file is read, and the configuration file is updated;
The update mode of configuration file includes modifying, supplementing to configuration file.In practice, not all to match
File is set to require to modify.
Specifically, can be according to the more new information of the frame between original program frame and new procedures frame, more new configuration file
In with frame update information matches information.Frame more new information can indicate to update before original program frame and new procedures frame
Which information.
It on the other hand can also be according to update content modification unrelated with frame more new information, program itself configuration text
Part.For example, version number, the external of a part rely on the information such as packet.
Step 203, the code file is converted to abstract syntax tree by the code file for reading the original program file
AST;
It is the language according to the programming language of code file specifically, the code file is converted to abstract syntax tree AST
Method parses current code file, forms tree-like data structure.
Step 204, the AST is traversed, the static defining based on original program frame in the AST is converted to based on new journey
The static defining of sequence frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new procedures
The dynamic call object of frame;
In the embodiment of the present application, the step 204 may include following sub-step:
Sub-step S11 traverses the AST, according to preset static defining rule change and preset dynamic call pair
As adaptation rule, the AST is converted;Wherein, the static defining rule change be will be based on the quiet of original program frame
State defines the rule for being converted to the static defining based on new procedures frame;The dynamic call object dispatching rule is will be based on original
The dynamic call object dispatching of program frame is the rule of the dynamic call object based on new procedures frame.
Static defining rule change can be fixed by the static defining of analysis original program frame and the static state of new procedures frame
The change of justice is set.
Dynamic call object dispatching rule can be by analyzing the dynamic call object based on original program frame and being based on newly
The change of the dynamic call object of program frame is set.
Specifically, the sub-step S11 may further include following sub-step:
Sub-step S111, with the matched static defining node of the static defining rule change, will be pressed described in the AST
Static defining rule change is converted.
It include multiple static definings in AST, each static defining is properly termed as static defining node.
Static defining rule change has recorded the static defining node converted, when traversing AST, when traversing
When static defining node, judge whether the static defining node matches with static defining rule change, that is, judgement is static fixed
Whether the static defining node is had recorded in adopted rule change, if the static defining node is matched with static defining rule change,
It is then matched according to static defining rule change and the static defining node is converted into the static defining node based on new procedures frame.
Sub-step S112, using the compatibility code generated according to the preset dynamic call object dispatching rule, by institute
Stating the dynamic call object dispatching in AST based on original program frame is the dynamic call object based on new procedures frame.
Since dynamic call object is that static analysis can not find and be adapted to, specific number when operation is even relied on
According to, it is therefore desirable to increase corresponding compatibility code to be adapted to.And the method for analyzing the difference can only be that the artificial interface that compares changes.
Compatibility code design is usually mode adapter, and the effect of compatibility code is to need to call originally by code file
Calling object dispatching is that another calls object.For example, code file can be adjusted in the code file based on original program frame
Some service is realized with interface A.And in new procedures frame, interface A has been modified into interface B.So, when code is run
And when calling interface A, compatibility code will be adapted for calling interface B, so that code file can be used based on new frame
The interface B of frame realizes the service.
Step 205, modified AST is converted into code file.
Step 206, in conjunction with the configuration file and the code file, updated program file is obtained.
In the raw address of engineering, in conjunction with the configuration file of update, updated code file and it is some without update
File, the updated program file based on new procedures frame can be obtained.
In the embodiment of the present application, AST is converted to by the code file to program file, former journey then will be based in AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and will be dynamic based on original program frame in AST
It is the dynamic call object based on new procedures frame that state, which calls object dispatching, can be automated more in the case where program frame upgrades
Fresh code file, and there is good universality.
In practice, upgrading tool can be developed come the programme upgrade method of the realization the embodiment of the present application automated.It is right
In there is the case where multiple requirement of engineering upgrading, a large amount of workload of developer can simplify
Other than it can be updated in program file raw address, program file can also be updated and be migrated,
That is by the storage of updated program file into new address.
Referring to Fig. 3, a kind of step flow chart of migration of programs embodiment of the method one of the application is shown, specifically can wrap
Include following steps:
Step 301, original program file is obtained from raw address;
The original program file based on original program frame is obtained from raw address.
Specifically, original program file is stored in the form of engineering, original program file can be obtained in the raw address of engineering.
Step 302, the code file is converted to abstract syntax tree by the code file for reading the original program file
AST;
Step 303, the AST is traversed, the static defining based on original program frame in the AST is converted to based on new journey
The static defining of sequence frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new procedures
The dynamic call object of frame;
The step 303 may include: the traversal AST, according to preset static defining rule change and preset
Dynamic call object dispatching rule, converts the AST;Wherein, the static defining rule change is that will be based on former journey
The static defining of sequence frame is converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule
For the rule that based on the dynamic call object dispatching of original program frame will be the dynamic call object based on new procedures frame.
Specifically, the AST is traversed, it will be with the matched static defining node of the static defining rule change, by described
Static defining rule change is converted.Using the compatibility generation generated according to the preset dynamic call object dispatching rule
Dynamic call object dispatching in the AST based on original program frame is the dynamic call object based on new procedures frame by code.
Step 304, modified AST is converted into code file, and code file is written to destination address.
Conversion process is the operation in memory, AST tree is converted to code text again, and connect by code file write-in
Mouthful, it is written to destination address.Destination address can be { newly built construction catalogue }/{ relative path where this document }/{ file
Name }.
In the embodiment of the present application, AST is converted to by the code file to program file, former journey then will be based in AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and will be dynamic based on original program frame in AST
It is the dynamic call object based on new procedures frame that state, which calls object dispatching, can be automated more in the case where program frame upgrades
Fresh code file, and there is good universality.
Referring to Fig. 4, a kind of step flow chart of migration of programs embodiment of the method two of the application is shown, specifically can wrap
Include following steps:
Step 401, original program file is obtained from raw address;
The original program file based on original program frame is obtained from raw address.
Specifically, original program file is stored in the form of engineering, original program file can be obtained in the raw address of engineering.
Step 402, traverse the program directory of the original program file and by described program catalogue with being copied to the target
Location;
Program directory has recorded the hierarchical relationship of various files and file that program is included.
Step 403, the configuration file for reading the original program file, is updated the configuration file, and will update
The destination address that configuration file afterwards is write;
The update mode of configuration file includes modifying, supplementing to configuration file.
Step 404, the code file is converted to abstract syntax tree by the code file for reading the original program file
AST;
Step 405, the AST is traversed, the static defining based on original program frame in the AST is converted to based on new journey
The static defining of sequence frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new procedures
The dynamic call object of frame;
The step 405 may include: the traversal AST, according to preset static defining rule change and preset
Dynamic call object dispatching rule, converts the AST;Wherein, the static defining rule change is that will be based on former journey
The static defining of sequence frame is converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule
For the rule that based on the dynamic call object dispatching of original program frame will be the dynamic call object based on new procedures frame.
Specifically, the AST is traversed, it will be with the matched static defining node of the static defining rule change, by described
Static defining rule change is converted.Using the compatibility generation generated according to the preset dynamic call object dispatching rule
Dynamic call object dispatching in the AST based on original program frame is the dynamic call object based on new procedures frame by code.
Step 406, modified AST is converted into code file, and code file is written to destination address.
Conversion process is the operation in memory, AST tree is converted to code text again, and connect by code file write-in
Mouthful, it is written to destination address.Destination address can be { newly built construction catalogue }/{ relative path where this document }/{ file
Name }
Step 407, by the original program file it is not necessary to modify file copy to the destination address;
When being updated to the configuration file, on the one hand, can be according to the original program frame and the new procedures frame
Frame more new information between frame updates the information of information matches in more new configuration file with the frame.It on the other hand, can be with
According to the update content modification configuration file of, program unrelated with frame more new information itself.
Step 408, in conjunction with described program catalogue, the configuration file, the code file and it is described it is not necessary to modify
File, as updated program file.
In the embodiment of the present application, AST is converted to by the code file to program file, former journey then will be based in AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and will be dynamic based on original program frame in AST
It is the dynamic call object based on new procedures frame that state, which calls object dispatching, can be automated more in the case where program frame upgrades
Fresh code file, and there is good universality.
In practice, the migration of programs method of the realization the embodiment of the present application that can develop Migration tools to automate.Only
Raw address and destination address are specified to Migration tools, Migration tools can complete above-mentioned transition process, for there are multiple works
Journey needs the case where migrating, and can simplify a large amount of workload of developer.
It should be noted that for simple description, therefore, it is stated as a series of action groups for embodiment of the method
It closes, but those skilled in the art should understand that, the embodiment of the present application is not limited by the described action sequence, because according to
According to the embodiment of the present application, some steps may be performed in other sequences or simultaneously.Secondly, those skilled in the art also should
Know, the embodiments described in the specification are all preferred embodiments, and related movement not necessarily the application is implemented
Necessary to example.
Referring to Fig. 5, show a kind of structural block diagram of program renewing device embodiment of the application, can specifically include as
Lower module:
Program obtains module 501, for obtaining original program file;
Syntax tree generation module 502 converts the code file for reading the code file of the original program file
For abstract syntax tree AST;
Modified module 503 is converted to the static defining based on original program frame in the AST for traversing the AST
It is base based on the static defining of new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame
In the dynamic call object of new procedures frame;
Code file generation module 504, for modified AST to be converted to code file.
In the embodiment of the present application, the device can also include:
Configuration file update module, for reading the configuration file of the original program file, and to the configuration file into
Row updates;
More new procedures obtain module, for obtaining updated journey in conjunction with the configuration file and the code file
Preface part.
In the embodiment of the present application, the modified module 503 may include:
Rules modification submodule, for traversing the AST, according to preset static defining rule change and preset dynamic
State calls object dispatching rule, converts to the AST;Wherein, the static defining rule change is that will be based on original program
The static defining of frame is converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule is
It is the rule of the dynamic call object based on new procedures frame by the dynamic call object dispatching based on original program frame.
In the embodiment of the present application, the rules modification submodule may include:
Static defining converting unit, for by the AST with the matched static defining of static defining rule change
Node is converted by the static defining rule change.
In the embodiment of the present application, the rules modification submodule can also include:
Dynamic call object dispatching unit, for using according to the preset dynamic call object dispatching rule generation
Dynamic call object dispatching in the AST based on original program frame is the dynamic tune based on new procedures frame by compatibility code
Use object.
In the embodiment of the present application, the configuration file update module may include:
Configuration file update submodule, for according to the frame between the original program frame and the new procedures frame more
New information updates the information of information matches in more new configuration file with the frame.
Referring to Fig. 6, show a kind of structural block diagram of migration of programs Installation practice of the application, can specifically include as
Lower module:
Program obtains module 601, for obtaining original program file from raw address;
Syntax tree generation module 602 converts the code file for reading the code file of the original program file
For abstract syntax tree AST;
Modified module 603 is converted to the static defining based on original program frame in the AST for traversing the AST
It is base based on the static defining of new procedures frame, and by the dynamic call object dispatching in the AST based on original program frame
In the dynamic call object of new procedures frame;
Code file generation module 604 for modified AST to be converted to code file, and code file is written
To destination address.
In the embodiment of the present application, the device can also include:
Catalogue copies module, for traversing the program directory of the original program file and described program catalogue being copied to institute
State destination address;
Configuration file update module carries out the configuration file for reading the configuration file of the original program file
It updates, and the destination address that updated configuration file is write;
Original copy module, for by the original program file it is not necessary to modify file copy to the target
Location;
More new procedures obtain module, in conjunction with described program catalogue, the configuration file, the code file and institute
State it is not necessary to modify file, as updated program file.
In the embodiment of the present application, the modified module 603 may include:
Rules modification submodule, for traversing the AST, according to preset static defining rule change and preset dynamic
State calls object dispatching rule, converts to the AST;Wherein, the static defining rule change is that will be based on original program
The static defining of frame is converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule is
It is the rule of the dynamic call object based on new procedures frame by the dynamic call object dispatching based on original program frame.
In the embodiment of the present application, the rules modification submodule may include:
Static defining converting unit, for by the AST with the matched static defining of static defining rule change
Node is converted by the static defining rule change.
In the embodiment of the present application, the rules modification submodule can also include:
Dynamic call object dispatching unit, for using according to the preset dynamic call object dispatching rule generation
Dynamic call object dispatching in the AST based on original program frame is the dynamic tune based on new procedures frame by compatibility code
Use object.
In the embodiment of the present application, the configuration file update module may include:
Configuration file update submodule, for according to the frame between the original program frame and the new procedures frame more
New information updates the information of information matches in more new configuration file with the frame.
For device embodiment, since it is basically similar to the method embodiment, related so being described relatively simple
Place illustrates referring to the part of embodiment of the method.
The embodiment of the present application also provides a kind of devices, comprising:
One or more processors;With
One or more machine readable medias of instruction are stored thereon with, are executed when by one or more of processors
When, so that described device executes method described in the embodiment of the present application.
The embodiment of the present application also provides one or more machine readable medias, are stored thereon with instruction, when by one or
When multiple processors execute, so that device executes method described in the embodiment of the present application.
All the embodiments in this specification are described in a progressive manner, the highlights of each of the examples are with
The difference of other embodiments, the same or similar parts between the embodiments can be referred to each other.
It should be understood by those skilled in the art that, the embodiments of the present application may be provided as method, apparatus or calculating
Machine program product.Therefore, the embodiment of the present application can be used complete hardware embodiment, complete software embodiment or combine software and
The form of the embodiment of hardware aspect.Moreover, the embodiment of the present application can be used one or more wherein include computer can
With in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program code
The form of the computer program product of implementation.
The embodiment of the present application is referring to according to the method for the embodiment of the present application, terminal device (system) and computer program
The flowchart and/or the block diagram of product describes.It should be understood that flowchart and/or the block diagram can be realized by computer program instructions
In each flow and/or block and flowchart and/or the block diagram in process and/or box combination.It can provide these
Computer program instructions are set to general purpose computer, special purpose computer, Embedded Processor or other programmable data processing terminals
Standby processor is to generate a machine, so that being held by the processor of computer or other programmable data processing terminal devices
Capable instruction generates for realizing in one or more flows of the flowchart and/or one or more blocks of the block diagram
The device of specified function.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing terminal devices
In computer-readable memory operate in a specific manner, so that instruction stored in the computer readable memory generates packet
The manufacture of command device is included, which realizes in one side of one or more flows of the flowchart and/or block diagram
The function of being specified in frame or multiple boxes.
These computer program instructions can also be loaded into computer or other programmable data processing terminal devices, so that
Series of operation steps are executed on computer or other programmable terminal equipments to generate computer implemented processing, thus
The instruction executed on computer or other programmable terminal equipments is provided for realizing in one or more flows of the flowchart
And/or in one or more blocks of the block diagram specify function the step of.
Although preferred embodiments of the embodiments of the present application have been described, once a person skilled in the art knows bases
This creative concept, then additional changes and modifications can be made to these embodiments.So the following claims are intended to be interpreted as
Including preferred embodiment and all change and modification within the scope of the embodiments of the present application.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that process, method, article or terminal device including a series of elements not only wrap
Those elements are included, but also including other elements that are not explicitly listed, or further includes for this process, method, article
Or the element that terminal device is intrinsic.In the absence of more restrictions, being wanted by what sentence "including a ..." limited
Element, it is not excluded that there is also other identical elements in process, method, article or the terminal device for including the element.
Above to a kind of method for updating program provided herein, a kind of program renewing device, a kind of migration of programs side
Method and a kind of migration of programs function device, are described in detail, used herein principle and reality of the specific case to the application
The mode of applying is expounded, the description of the example is only used to help understand the method for the present application and its core ideas;Together
When, for those of ordinary skill in the art, according to the thought of the application, have in specific embodiments and applications
Change place, in conclusion the contents of this specification should not be construed as limiting the present application.
Claims (26)
1. a kind of method for updating program characterized by comprising
Obtain original program file;
The code file is converted to abstract syntax tree AST by the code file for reading the original program file;
The AST is traversed, the static defining based on original program frame in the AST is converted into the static state based on new procedures frame
Definition, and by the dynamic call object dispatching in the AST based on original program frame be the dynamic tune based on new procedures frame
Use object;
Modified AST is converted into code file.
2. the method according to claim 1, wherein further include:
The configuration file of the original program file is read, and the configuration file is updated;
In conjunction with the configuration file and the code file, updated program file is obtained.
3. the method according to claim 1, wherein the traversal AST, will be based on former journey in the AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and original program frame will be based in the AST
Dynamic call object dispatching be the dynamic call object step based on new procedures frame include:
The AST is traversed, according to preset static defining rule change and preset dynamic call object dispatching rule, to institute
AST is stated to be converted;Wherein, the static defining rule change is to be converted to the static defining based on original program frame to be based on
The rule of the static defining of new procedures frame;The dynamic call object dispatching rule is will be based on the dynamic tune of original program frame
It is the rule of the dynamic call object based on new procedures frame with object dispatching.
4. according to the method described in claim 3, it is characterized in that, described according to preset static defining rule change and pre-
If dynamic call object dispatching rule, the step of converting to the AST includes:
, with the matched static defining node of the static defining rule change, it will change by the static defining and advise in the AST
Then converted.
5. according to the method described in claim 4, it is characterized in that, described according to preset static defining rule change and pre-
If dynamic call object dispatching rule, the step of conversion to the AST further include:
Using the compatibility code generated according to the preset dynamic call object dispatching rule, former journey will be based in the AST
The dynamic call object dispatching of sequence frame is the dynamic call object based on new procedures frame.
6. according to the method described in claim 2, it is characterized in that, the step of being updated to configuration file packet
It includes:
According to the frame more new information between the original program frame and the new procedures frame, in more new configuration file with it is described
The information of frame update information matches.
7. a kind of migration of programs method characterized by comprising
Original program file is obtained from raw address;
The code file is converted to abstract syntax tree AST by the code file for reading the original program file;
The AST is traversed, the static defining based on original program frame in the AST is converted into the static state based on new procedures frame
Definition, and by the dynamic call object dispatching in the AST based on original program frame be the dynamic tune based on new procedures frame
Use object;
Modified AST is converted into code file, and code file is written to destination address.
8. the method according to the description of claim 7 is characterized in that further include:
It traverses the program directory of the original program file and described program catalogue is copied to the destination address;
The configuration file for reading the original program file, is updated the configuration file, and by updated configuration file
The destination address write;
By in the original program file it is not necessary to modify file copy to the destination address;
In conjunction with described program catalogue, the configuration file, the code file and it is described it is not necessary to modify file, as update
Program file afterwards.
9. the method according to the description of claim 7 is characterized in that the traversal AST, will be based on former journey in the AST
The static defining of sequence frame is converted to the static defining based on new procedures frame, and original program frame will be based in the AST
Dynamic call object dispatching be the dynamic call object step based on new procedures frame include:
The AST is traversed, according to preset static defining rule change and preset dynamic call object dispatching rule, to institute
AST is stated to be converted;Wherein, the static defining rule change is to be converted to the static defining based on original program frame to be based on
The rule of the static defining of new procedures frame;The dynamic call object dispatching rule is will be based on the dynamic tune of original program frame
It is the rule of the dynamic call object based on new procedures frame with object dispatching.
10. according to the method described in claim 9, it is characterized in that, it is described according to preset static defining rule change and
Preset dynamic call object dispatching rule, the step of converting to the AST include:
, with the matched static defining node of the static defining rule change, it will change by the static defining and advise in the AST
Then converted.
11. according to the method described in claim 10, it is characterized in that, it is described according to preset static defining rule change and
Preset dynamic call object dispatching rule, the step of conversion to the AST further include:
Using the compatibility code generated according to the preset dynamic call object dispatching rule, former journey will be based in the AST
The dynamic call object dispatching of sequence frame is the dynamic call object based on new procedures frame.
12. according to the method described in claim 8, it is characterized in that, the step of being updated to configuration file packet
It includes:
According to the frame more new information between the original program frame and the new procedures frame, in more new configuration file with it is described
The information of frame update information matches.
13. a kind of program renewing device characterized by comprising
Program obtains module, for obtaining original program file;
Syntax tree generation module is converted to the code file abstract for reading the code file of the original program file
Syntax tree AST;
Modified module is converted to the static defining based on original program frame in the AST based on new for traversing the AST
The static defining of program frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new journey
The dynamic call object of sequence frame;
Code file generation module, for modified AST to be converted to code file.
14. device according to claim 13, which is characterized in that further include:
Configuration file update module carries out more for reading the configuration file of the original program file, and to the configuration file
Newly;
More new procedures obtain module, for obtaining updated program text in conjunction with the configuration file and the code file
Part.
15. device according to claim 13, which is characterized in that the modified module includes:
Rules modification submodule, for traversing the AST, according to preset static defining rule change and preset dynamic tune
With object dispatching rule, the AST is converted;Wherein, the static defining rule change is that will be based on original program frame
Static defining be converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule is by base
In the rule that the dynamic call object dispatching of original program frame is the dynamic call object based on new procedures frame.
16. device according to claim 15, which is characterized in that the rules modification submodule includes:
Static defining converting unit, for by the AST with the matched static defining node of the static defining rule change,
It is converted by the static defining rule change.
17. device according to claim 16, which is characterized in that the rules modification submodule further include:
Dynamic call object dispatching unit, for using the compatibility generated according to the preset dynamic call object dispatching rule
Dynamic call object dispatching in the AST based on original program frame is the dynamic call pair based on new procedures frame by code
As.
18. device according to claim 14, which is characterized in that the configuration file update module includes:
Configuration file updates submodule, for updating letter according to the frame between the original program frame and the new procedures frame
It ceases, updates the information of information matches in more new configuration file with the frame.
19. a kind of migration of programs device characterized by comprising
Program obtains module, for obtaining original program file from raw address;
Syntax tree generation module is converted to the code file abstract for reading the code file of the original program file
Syntax tree AST;
Modified module is converted to the static defining based on original program frame in the AST based on new for traversing the AST
The static defining of program frame, and by the dynamic call object dispatching in the AST based on original program frame for based on new journey
The dynamic call object of sequence frame;
Code file generation module, for modified AST to be converted to code file, and with being written to target by code file
Location.
20. device according to claim 19, which is characterized in that further include:
Catalogue copies module, for traversing the program directory of the original program file and described program catalogue being copied to the mesh
Mark address;
Configuration file update module is updated the configuration file for reading the configuration file of the original program file,
And the destination address for writing updated configuration file;
Original copies module, for by the original program file it is not necessary to modify file copy to the destination address;
More new procedures obtain module, in conjunction with described program catalogue, the configuration file, the code file and the nothing
The file that need to be modified, as updated program file.
21. device according to claim 19, which is characterized in that the modified module includes:
Rules modification submodule, for traversing the AST, according to preset static defining rule change and preset dynamic tune
With object dispatching rule, the AST is converted;Wherein, the static defining rule change is that will be based on original program frame
Static defining be converted to the rule of the static defining based on new procedures frame;The dynamic call object dispatching rule is by base
In the rule that the dynamic call object dispatching of original program frame is the dynamic call object based on new procedures frame.
22. device according to claim 21, which is characterized in that the rules modification submodule includes:
Static defining converting unit, for by the AST with the matched static defining node of the static defining rule change,
It is converted by the static defining rule change.
23. device according to claim 22, which is characterized in that the rules modification submodule further include:
Dynamic call object dispatching unit, for using the compatibility generated according to the preset dynamic call object dispatching rule
Dynamic call object dispatching in the AST based on original program frame is the dynamic call pair based on new procedures frame by code
As.
24. device according to claim 20, which is characterized in that the configuration file update module includes:
Configuration file updates submodule, for updating letter according to the frame between the original program frame and the new procedures frame
It ceases, updates the information of information matches in more new configuration file with the frame.
25. a kind of device characterized by comprising
One or more processors;With
One or more machine readable medias of instruction are stored thereon with, when being executed by one or more of processors, are made
The methods for obtaining the one or more that described device is executed as described in claim 1-6 or 7-12.
26. one or more machine readable medias, are stored thereon with instruction, when executed by one or more processors, so that
Device executes one or more methods as described in claim 1-6 or 7-12.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810267305.7A CN110321138B (en) | 2018-03-28 | 2018-03-28 | Program updating and migration method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810267305.7A CN110321138B (en) | 2018-03-28 | 2018-03-28 | Program updating and migration method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110321138A true CN110321138A (en) | 2019-10-11 |
CN110321138B CN110321138B (en) | 2023-08-01 |
Family
ID=68110401
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810267305.7A Active CN110321138B (en) | 2018-03-28 | 2018-03-28 | Program updating and migration method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110321138B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111752571A (en) * | 2020-06-29 | 2020-10-09 | 广州华多网络科技有限公司 | Program upgrading method, device, equipment and storage medium |
CN112711439A (en) * | 2021-01-19 | 2021-04-27 | 天津飞腾信息技术有限公司 | Automatic updating method for converting ASIC codes into FPGA codes |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140282373A1 (en) * | 2013-03-15 | 2014-09-18 | Trinity Millennium Group, Inc. | Automated business rule harvesting with abstract syntax tree transformation |
CN104391730A (en) * | 2014-08-03 | 2015-03-04 | 浙江网新恒天软件有限公司 | Software source code language translation system and method |
CN106970820A (en) * | 2017-04-26 | 2017-07-21 | 腾讯科技(深圳)有限公司 | Code storage method and code storage |
-
2018
- 2018-03-28 CN CN201810267305.7A patent/CN110321138B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140282373A1 (en) * | 2013-03-15 | 2014-09-18 | Trinity Millennium Group, Inc. | Automated business rule harvesting with abstract syntax tree transformation |
CN104391730A (en) * | 2014-08-03 | 2015-03-04 | 浙江网新恒天软件有限公司 | Software source code language translation system and method |
CN106970820A (en) * | 2017-04-26 | 2017-07-21 | 腾讯科技(深圳)有限公司 | Code storage method and code storage |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111752571A (en) * | 2020-06-29 | 2020-10-09 | 广州华多网络科技有限公司 | Program upgrading method, device, equipment and storage medium |
CN112711439A (en) * | 2021-01-19 | 2021-04-27 | 天津飞腾信息技术有限公司 | Automatic updating method for converting ASIC codes into FPGA codes |
Also Published As
Publication number | Publication date |
---|---|
CN110321138B (en) | 2023-08-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10558642B2 (en) | Mechanism for deprecating object oriented data | |
US10353913B2 (en) | Automating extract, transform, and load job testing | |
CN107122368B (en) | Data verification method and device and electronic equipment | |
US8769494B2 (en) | Globally sound and consistent configuration management for distributed datacenter components | |
US10402173B2 (en) | Systems and methods for arbitrary software logic modeling | |
CN102542382A (en) | Method and device for managing business rule | |
US9619212B2 (en) | Providing code, code generator and software development environment | |
CN104461531A (en) | Implementing method for self-defined functions of reporting system | |
CN114912391A (en) | Automatic generation method, device, equipment and medium of register design and verification model | |
JP2014235749A (en) | Live upgrade | |
CN110321138A (en) | A kind of program updates, moving method and device | |
CN111984300B (en) | Code copying method and device, electronic equipment and computer readable storage medium | |
CN112947896A (en) | Directed graph-based component dependence analysis method | |
CN112818176A (en) | Data processing method, device, equipment and storage medium | |
US11977473B2 (en) | Providing a pseudo language for manipulating complex variables of an orchestration flow | |
CN110399386A (en) | A kind of SQL UPDATE method and control system based on Presto | |
US20190317877A1 (en) | Application state monitoring | |
CN109621406A (en) | A kind of generation method and device of configuration file | |
CN115344966A (en) | CAD assembly body part replacement method and system | |
KR20150060174A (en) | Method of Automatic generation of source for business process automation | |
Burger et al. | Difference-based Conformance Checking for Ecore Metamodels | |
CN114089965A (en) | Program development project management method and device based on monolithic code warehouse Monorepo | |
US10796031B1 (en) | Method and system of preparing engineering data for industrial control systems | |
CN112559444A (en) | SQL (structured query language) file migration method and device, storage medium and equipment | |
CN111008018A (en) | CAN signal unpacking processing method and system |
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 | ||
REG | Reference to a national code |
Ref country code: HK Ref legal event code: DE Ref document number: 40014980 Country of ref document: HK |
|
GR01 | Patent grant | ||
GR01 | Patent grant |