Compile-Time AST Hooking for Faster Program Function Updates

Resolve Bottlenecks,
Find Innovative Solutions
Generate 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

VSEngineering 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

Engineering Contradiction:
Improvefunctional requirementsVSAvoidtime consumption
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

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.

Inventive Principle:
Principle #10Preliminary action

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.

Inventive Principle:
Principle #24Intermediary (Mediator)

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

Engineering Contradiction:
Improvefunctional requirementsVSAvoidsystem resource usage
Core Design Contradiction:
Adaptability or versatilityVSLoss of energy

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.

Inventive Principle:
Principle #25Self-service

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

Engineering Contradiction:
Improvefunctional requirementsVSAvoidoperation complexity
Core Design Contradiction:
Adaptability or versatilityVSEase of operation

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.

Inventive Principle:
Principle #24Intermediary (Mediator)

4Productivity

If automatic hook method is used to modify abstract syntax tree, then function updating efficiency improves, but device complexity increases

Engineering Contradiction:
Improvefunction updating efficiencyVSAvoidcompilation system complexity
Core Design Contradiction:
ProductivityVSDevice complexity

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.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS12554472B2Hook method and apparatus for compile time, device, and storage medium
Publication Date: 2026.02.17 DOUYIN VISION CO LTD
  • US12554472B2 patent drawing
  • US12554472B2 patent drawing

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).