Hook method and apparatus for compile time, device, and storage medium

US12554472B2 · US · B2

Patent metadata
FieldValue
Publication numberUS-12554472-B2
Application numberUS-202218275577-A
CountryUS
Kind codeB2
Filing dateJan 24, 2022
Priority dateFeb 5, 2021
Publication dateFeb 17, 2026
Grant dateFeb 17, 2026

How to read this patent

A practical reading order for non-experts. Skip the full description unless you need deep technical detail.

  1. Title

    What the patent document calls the invention.

  2. Abstract

    A short plain-language summary of the technical disclosure.

  3. Assignees and inventors

    Who owns or filed the patent and who is credited as inventor.

  4. Key dates

    Filing, priority, publication, and grant dates set the timeline.

  5. First independent claim

    The legal scope of protection — read this for what is actually claimed.

  6. CPC / IPC classifications

    Technology tags used to group this patent with similar filings.

  7. Citations and related patents

    Prior art links and similar publications in this corpus.

Abstract

Official abstract text for this publication.

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 (S 101 ), 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 (S 102 ); 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 (S 103 ); and finally, generating a target program based on the updated abstract syntax tree (S 104 ).

First claim

Opening claim text (preview).

What is claimed is: 1 . A hook method for compile time, comprising: receiving a hook code file and a target program source code, wherein the hook code file comprises a correspondence between predetermined locating information and a predetermined object processing scheme, and the predetermined locating information is used for identifying an object in the target program source code; converting the target program source code into an abstract syntax tree, and determining a node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file, wherein the node in the abstract syntax tree is in correspondence with the object in the target program source code; modifying the node in the abstract syntax tree corresponding to the predetermined locating information 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; and generating a target program based on the updated abstract syntax tree, wherein the method further comprises, prior to said receiving the hook code file and the target program source code: marking locating information of a target object in the target program source code as the predetermined locating information based on a predetermined marking mechanism, wherein the predetermined locating information comprises file position information, a class name, and a method name, wherein the target program source code is a Dart program source code, said determining the node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file comprises: determining nodes in the abstract syntax tree corresponding to the file position information in the predetermined locating information as first nodes based on the predetermined locating information in the hook code file; determining nodes corresponding to the class name in the predetermined locating information from the first nodes as second nodes; and determining a node corresponding to the method name in the predetermined locating information from the second nodes as a third node; and said modifying the node in the abstract syntax tree corresponding to the predetermined locating information by using the predetermined object processing scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree comprises: modifying the third node in the abstract syntax tree by using the predetermined object processing scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree. 2 . The method according to claim 1 , wherein the predetermined object processing scheme comprises an object replacement scheme or an object modification scheme; and said modifying the node in the abstract syntax tree corresponding to the predetermined locating information by using the predetermined object processing scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree comprises: replacing the node in the abstract syntax tree corresponding to the predetermined locating information with a specified object in the object replacement scheme by using the object replacement scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree; or modifying a logic content in the node in the abstract syntax tree corresponding to the predetermined locating information by using the object modification scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree. 3 . The method according to claim 1 , further comprising, prior to said receiving the hook code file and the target program source code: receiving source code parameter information inputted by a user, and adding the source code parameter information to a predetermined file template; and receiving an object processing scheme written into the predetermined file template to obtain the hook code file. 4 . A non-transitory computer-readable storage medium, having instructions stored therein, wherein the instructions, when executed on a terminal device, cause the terminal device to: receive a hook code file and a target program source code, wherein the hook code file comprises a correspondence between predetermined locating information and a predetermined object processing scheme, and the predetermined locating information is used for identifying an object in the target program source code; convert the target program source code into an abstract syntax tree, and determine a node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file, wherein the node in the abstract syntax tree is in correspondence with the object in the target program source code; modify the node in the abstract syntax tree corresponding to the predetermined locating information 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; and generate a target program based on the updated abstract syntax tree, wherein the instructions, when executed on the terminal device, further cause the terminal device to, prior to said receiving the hook code file and the target program source code: mark locating information of a target object in the target program source code as the predetermined locating information based on a predetermined marking mechanism, wherein the predetermined locating information comprises file position information, a class name, and a method name, wherein the target program source code is a Dart program source code, said determining the node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file comprises: determining nodes in the abstract syntax tree corresponding to the file position information in the predetermined locating information as first nodes based on the predetermined locating information in the hook code file; determining nodes corresponding to the class name in the predetermined locating information from the first nodes as second nodes; and determining a node corresponding to the method name in the predetermined locating information from the second nodes as a third node; and said modifying the node in the abstract syntax tree corresponding to the predetermined locating information by using the predetermined object processing scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree comprises: modifying the third node in the abstract syntax tree by using the predetermined object processing scheme corresponding to the predetermined locating information in the hook code file, to obtain the updated abstract syntax tree. 5 . A device, comprising: a memory; a processor; and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the computer program, implements: receiving a hook code file and a target program source code, wherein the hook code file comprises a correspondence between predetermined locating information and a predetermined object processing scheme, and the predetermined locating information is used for identifying an object in the target program source code; converting the target program source code into an abstract syntax tree, and determining a node in the abstract syntax tree corresponding to the predetermined locating information in the hook code file, wherein the node in the abstract syntax tree is in correspondence with the object in the target pro

Assignees

Inventors

Classifications

  • G06F8/427Primary

    Parsing · CPC title

  • Compilation · CPC title

  • Energy efficient computing, e.g. low power processors, power management or thermal management · CPC title

  • Software maintenance or management · CPC title

  • G06F8/447Primary

    Target code generation · CPC title

Patent family

Related publications grouped by family.

External sources

Frequently asked questions

Answers are generated from the same data shown on this page.

What does patent US12554472B2 cover?
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 (S 101 ), 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, a…
Who is the assignee on this patent?
Beijing Bytedance Network Tech Co Ltd
What technology area does this patent fall under?
Primary CPC classification G06F8/427. Mapped technology areas include Physics.
When was this patent published?
Publication date Tue Feb 17 2026 00:00:00 GMT+0000 (Coordinated Universal Time) (B2). Legal status and post-grant events are not shown on this page.
What related patents are in patentsdb?
We list 6 related publications on this page (citations in our corpus or others sharing the same primary CPC).