Compile-Time AST Hooking for Faster Program Function Updates
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for updating application program functions after code development are time-consuming and inefficient, requiring manual modification of program source code, which is wasteful and prone to errors.
Innovation Solution
A hook method and apparatus for compile time that modifies specified objects in a target program source code by converting it into an abstract syntax tree, determining and modifying nodes using predetermined locating information and processing schemes in a hook code file, generating an updated abstract syntax tree, and compiling to a target program.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If manual modification of program source code is used to update functions, then functional requirements can be met, but time consumption increases and efficiency decreases
Solution Approach 1:
The patent applies preliminary action by pre-defining hook code files with object processing schemes before compilation. These hook code files contain predetermined locating information and processing rules that automatically modify the abstract syntax tree during compilation, eliminating the need for manual post-compilation modifications and enabling efficient function updates.
Solution Approach 2:
The patent introduces an intermediary mechanism - the hook code file - that acts as a mediator between the original source code and the compiled program. The hook code file contains locating information and object processing schemes that automatically modify the abstract syntax tree during compilation, serving as an intermediate layer that enables function updates without direct manual intervention.
2Adaptability or versatility
If manual modification of program source code is used to update functions, then functional requirements can be met, but system resource usage increases
Solution Approach 1:
The patent implements self-service by enabling the compilation system to automatically modify its own abstract syntax tree using hook code files during the compilation process itself. The system modifies specified objects in the abstract syntax tree based on predetermined processing schemes, eliminating the need for external manual intervention and reducing overall system resource consumption.
3Adaptability or versatility
If manual modification of program source code is used to update functions, then functional requirements can be met, but operation complexity increases
Solution Approach 1:
The patent introduces an intermediary mechanism - the hook code file - that acts as a mediator between the original source code and the compiled program. The hook code file contains locating information and object processing schemes that automatically modify the abstract syntax tree during compilation, serving as an intermediate layer that enables function updates without direct manual intervention.
4Productivity
If automatic hook method is used to modify abstract syntax tree, then function updating efficiency improves, but device complexity increases
Solution Approach 1:
The patent applies segmentation by dividing the compilation system into distinct functional modules: a code parsing module that converts source code to abstract syntax tree, a hook processing module that applies object processing schemes, and a code generation module that produces the final compiled program. This modular segmentation manages complexity while enabling efficient automatic function updates.
Data Source
AI summary
Provided are a hook method and apparatus for compile time, a device, and a storage medium. The method includes: first, receiving a hook code file and a target program source code (S101), the hook code file including a correspondence between predetermined locating information and a predetermined object processing scheme; converting the target program source code into an abstract syntax tree, and then determining a node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file (S102); modifying the node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file by using the predetermined object processing scheme corresponding to the predetermined locating information in the hook code file, to obtain an updated abstract syntax tree (S103); and finally, generating a target program based on the updated abstract syntax tree (S104).

