Intelligent inverse software programming method based on large model

By standardizing the parsing of multilingual project code and performing semantic analysis on large models, combined with a layered extraction strategy and a target language compiler, the problem of adapting large models to the syntactic features and semantic rules of multiple languages ​​in reverse software engineering was solved. This enabled in-depth decomposition of code functional modules and system integrity, improving the efficiency and accuracy of reverse engineering.

CN121387295APending Publication Date: 2026-01-23西安积石数字技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511394368.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-28
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

Existing large models fail to fully adapt to the syntactic features and semantic rules of multiple programming languages ​​in reverse software engineering, resulting in the reverse-processed code often lacking key logic or structural breaks, making it difficult to maintain functionality and system operability.

Method used

By standardizing the parsing of multilingual project code to generate standardized intermediate representations (IR), semantic analysis using large models is used to construct function call graphs and semantic indexes. Combined with hierarchical extraction strategies and target language compilers, code extraction and verification are performed to ensure the syntactic integrity of the code and the correctness of dependencies.

Benefits of technology

It enables structured analysis and in-depth decomposition of functional modules in multi-programming language project code, improving the accuracy of reverse engineering understanding and the system integrity of the code, and shortening the code review and refactoring cycle in development and teaching scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121387295A_ABST
    Figure CN121387295A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent inverse software programming method based on a large model. The method comprises the steps that standardized analysis is conducted on input multi-language project codes, code entities, static relations and metadata are extracted, a standardized intermediate representation (IR) is generated, semantic analysis is conducted on the code entities through a large model to recognize service function attributes, a function calling graph and semantic indexes are constructed, and a function-code mapping table is generated; performing code extraction according to a hierarchical extraction strategy in combination with large model aided decision making; and calling a target language compiler to execute static grammar check and reference relationship verification, performing dependency missing tracing and correction in combination with the large model until the code passes verification, generating a differentiated code package, and outputting a reverse engineering processing result. According to the method, in a development scene, the code review and reconstruction period can be shortened; in a teaching scene, removal of functional modules on demand is supported to design programming exercises, and the logic complementation ability and the system understanding depth of a learner are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer software, and in particular to an intelligent reverse software programming method based on a large model. BACKGROUND

[0002] In the development and teaching practice of program application, reverse software engineering technology shows vital value. In the education scene, as an efficient teaching and evaluation tool, it guides learners to deeply analyze software structure by reverse disassembling code logic and extracting key fragments, exercises their systematic understanding ability and logic completion ability, and thus realizes the structured mastery of programming knowledge system. In the actual development field, for experienced developers, reverse software engineering technology can be used to analyze complex code architecture, locate core function modules, and significantly improve the efficiency of code review, reconstruction and optimization.

[0003] The current mainstream reverse software engineering scheme has significant technical bottlenecks. Most traditional implementations are only based on surface syntax rules or text patterns, lacking deep consideration of code function integrity and logical coherence. This leads to the fact that the reverse-processed code often cannot run normally due to missing key logic or structure breakage, making it difficult to meet the core needs of practicality and reliability in development and teaching scenarios.

[0004] With the iterative development of artificial intelligence technology, the potential of large models in the field of code processing is increasingly prominent. However, existing large models generally fail to fully adapt to the syntax characteristics and semantic rules of multiple programming languages (such as Java, Python, C++, TypeScript, etc.), especially lacking deep disassembly and precise extraction capabilities for code function modules, making it difficult to ensure that the reverse-processed code maintains system runnability while preserving functionality.

[0005] Therefore, it is necessary to propose a scheme to improve one or more problems in the above-mentioned related technical solutions.

[0006] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present application, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY

[0007] The purpose of the present disclosure is to provide an intelligent reverse software programming method based on a large model, thereby at least overcoming one or more problems caused by the limitations and defects of related technologies to some extent.

[0008] The intelligent reverse software programming method based on a large model provided by the embodiment of the present disclosure comprises the following steps: standardized intermediate representation, the standardized intermediate representation being IR; inputting the IR into a large model, performing semantic analysis on the code entities by the large model to identify business function attributes, constructing a function call graph and a semantic index, and generating a function-code mapping table; performing code extraction according to a hierarchical extraction strategy according to the IR and the function-code mapping table, and combining the large model to assist decision-making; performing static syntax checking and reference relationship verification on the extracted code by calling a target language compiler, and performing dependency missing backtracking and correction in combination with the large model until the code passes the verification; based on the verified code, generating a differentiated code package, outputting the reverse engineering processing result, and providing an engineering integration interface.

[0009] In an example embodiment of the present application, the step of inputting the input multi-language project code, extracting code entities, static relationships and metadata, and generating a standardized intermediate representation, the standardized intermediate representation being IR, includes: performing lexical analysis and syntax analysis on the multi-language project code by using a code analysis tool chain, and constructing an abstract syntax tree and a control flow graph of the project code; extracting code entities, static relationships and metadata from the abstract syntax tree and the control flow graph; integrating the code entities, static relationships and metadata to generate a standardized intermediate representation, the standardized intermediate representation being IR.

[0010] In an example embodiment of the present application, the code entities include the identification, location and declaration signature of modules, classes, functions / methods, code blocks and variables; the static relationships include inheritance relationships, call relationships, dependency relationships and definition-reference relationships; and the metadata includes annotations, parameters, return types, language types and source code summaries.

[0011] In an example embodiment of the present application, the multi-language project code includes at least one static type language project code or dynamic type language project code.

[0012] In an example embodiment of the present application, the step of inputting the IR into a large model, performing semantic analysis on the code entities by the large model to identify business function attributes, constructing a function call graph and a semantic index, and generating a function-code mapping table includes: inputting the IR into a large model, performing semantic analysis on the code entities and static relationships in the IR by the large model, identifying the business function attributes corresponding to each code entity, and constructing a function call graph; The multi-modal embedding technology is used to convert the business function attribute description and the corresponding code entity into a high-dimensional vector and construct a semantic index. A function-code mapping table is generated based on the semantic index and the code entity attribute in the IR.

[0013] In an example embodiment of the present application, the multi-modal embedding technology includes a text encoder and a structure encoder; the function call graph represents business function modules as nodes and the calling relationship and data flow between the business function modules as edges, and the business function modules can be recursively disassembled to function-level granularity.

[0014] In an example embodiment of the present application, the function-code mapping table labels the corresponding code range, hard dependency and soft dependency of each business function module, the code range includes class, function, code block, the hard dependency is a function call chain, and the soft dependency is a configuration file and a resource path.

[0015] In an example embodiment of the present application, the step of performing code extraction according to the hierarchical extraction strategy based on the IR and the function-code mapping table in combination with the large model assisted decision-making includes: According to the function extraction requirement, the target code entity matching the function extraction requirement is identified based on the IR and the function-code mapping table; The hierarchical extraction strategy of L1-level extraction or L2-level extraction is performed on the target code entity, and the large model assisted decision-making is combined.

[0016] In an example embodiment of the present application, the step of performing the hierarchical extraction strategy of L1-level extraction or L2-level extraction on the target code entity and combining the large model assisted decision-making includes: L1-level extraction is performed, the framework structure of the target code entity is located based on the target code entity position and the start and end line numbers in the IR, the framework structure includes class signature and function signature, the framework structure is retained, the implementation of the target code entity is removed, the large model is called to generate a hollow code conforming to the target language syntax, and the hollow code is inserted into the framework structure; L2-level extraction is performed, the complete dependency chain of the target code entity is analyzed based on the dependency relationship of the target code entity in the IR and the hard dependency in the function-code mapping table, the code corresponding to the target code entity and the complete dependency chain is removed, the large model is called to give a repair suggestion / complete the hollow code, the syntax is checked by a target language compiler or a static checker, invalid import statements in the remaining code are deleted, type declarations are adjusted, and the syntax integrity is repaired.

[0017] In an example embodiment of the present application, the steps of calling the target language compiler to perform static syntax checking and reference relationship verification on the extracted code, and combining the large model to perform dependency missing backtracking and correction until the code passes the verification include: Calling the target language compiler to perform static syntax checking on the extracted code, and based on the IR, scanning the code entity reference relationship in the extracted code to verify whether the associated reference of the removed module is synchronized cleared; If the static syntax checking or the associated reference verification fails, based on the dependency relationship in the function call graph and the IR, the dependency missing point is tracked back; According to the tracked back dependency missing point, the large model assisted decision is re-executed, the extraction range is adjusted or the large model generated stub code, and the code extraction and the calling of the target language compiler to perform static syntax checking and reference relationship verification are performed again until the extracted code passes the verification.

[0018] The intelligent reverse software programming method based on a large model provided in the present application has the following advantages. On the one hand, by generating a standardized intermediate representation, the structured parsing of the project code of multiple programming languages is realized, a unified data basis is provided for subsequent function disassembly, the technology has multi-language adaptation capability, and the limitation of single language processing in the traditional scheme is broken. On the other hand, by means of semantic analysis and function call graph based on a large model, the deep disassembly and accurate mapping of the code function module are realized, the function module recognition is more in line with the business logic, and the understanding accuracy of the code function by the reverse engineering is improved. On the other hand, by means of the hierarchical extraction strategy combined with the large model assisted decision, it is ensured that the code processed by the reverse processing passes the syntax checking and dependency verification, the system complete operation is maintained, and the unusable problem caused by the logic missing in the traditional scheme is avoided. In the development scene, the code review and reconstruction cycle can be shortened. In the teaching scene, the function module can be removed as needed to design programming exercises, and the learning ability of the learners in logic completion and the depth of system understanding are improved. BRIEF DESCRIPTION OF DRAWINGS

[0019] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0020] Fig. 1 The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings. Fig. 2 The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings. DETAILED DESCRIPTION

[0021] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations can be implemented in any

[0022] In addition, the drawings are to be considered in all respects as illustrative and not restrictive; reference being made not to the drawings exclusively for explaining the ideas of the example implementations. The features described can be combined in any suitable way in one or more implementations.

[0023] The present example implementation provides an intelligent reverse software programming method based on large models, as shown in Figs. 1-2 The method can include the following steps: Step S101: Standardized parsing of the input multi-language project code, extracting code entities, static relationships and metadata, generating a standardized intermediate representation, which is IR.

[0024] Step S102: Inputting the IR into a large model, performing semantic analysis on the code entities through the large model to identify business function attributes, constructing a function call graph and semantic index, and generating a function-code mapping table.

[0025] Step S103: According to the IR and the function-code mapping table, combined with the decision of the large model, performing code extraction according to the hierarchical extraction strategy.

[0026] Step S104: For the extracted code, calling the target language compiler to perform static syntax checking and reference relationship verification, combined with the large model to perform dependency missing tracing and correction, until the code passes the verification.

[0027] Step S105: Based on the verified code, generating a differentiated code package, outputting the reverse engineering processing result, and providing an engineering integration interface.

[0028] The intelligent reverse software programming method based on a large model proposed in the embodiment of the application has the following advantages. On the one hand, by generating a standardized intermediate representation, the structured parsing of the multi-programming language project code is implemented, a unified data basis is provided for subsequent function disassembly, the technology has multi-language adaptation capability, and the limitation of single language processing in the traditional scheme is broken. On the other hand, by means of semantic analysis and function call graph based on a large model, the deep disassembly and accurate mapping of the code function module are implemented, the function module recognition is more in line with the business logic, and the understanding accuracy of the code function by the reverse engineering is improved. In addition, by means of the hierarchical extraction strategy combined with the decision-making assistance of a large model, it is ensured that the code processed by reverse processing passes the syntax check and dependency verification, the system complete operation is maintained, and the unusable problem caused by the logic loss in the traditional scheme is avoided. In the development scene, the code review and reconstruction cycle can be shortened. In the teaching scene, the function module can be removed on demand to design programming exercises, and the learning ability of the learners in logic completion and the depth of system understanding are improved.

[0029] As shown in the following Figs. 1-2 A more detailed description of the intelligent reverse software programming method based on a large model proposed in the present example embodiment will be given.

[0030] Step S101: Standardized parsing of the input multi-language project code, extracting code entities, static relationships and metadata, generating a standardized intermediate representation, which is IR.

[0031] Specifically, step S101 includes steps S1001-S1003.

[0032] Step S1001: Using a code parsing tool chain to perform lexical analysis and syntax analysis on the multi-language project code, and constructing an abstract syntax tree and a control flow graph of the project code.

[0033] The syntax of the multi-language project code is deconstructed by the code parsing tool chain, the syntax barriers of different languages are broken, and a syntax analyzer based on Tree-sitter is used as the core tool. Tree-sitter supports the syntax rules of multiple mainstream programming languages such as Java, TypeScript and Python, can adapt to the keywords and sentence structures of different languages, and avoids missing parsing due to differences in language characteristics.

[0034] First, lexical analysis is performed, and the input multi-language project code is split into the smallest syntax units (referred to as lexical units), such as variable names, keywords, operators and punctuation marks, and the type of each unit is marked.

[0035] Then, syntax analysis is performed, and based on the syntax rules of each language, the lexical units are organized according to the logical relationship to construct two core structures, an abstract syntax tree and a control flow graph.

[0036] Abstract Syntax Tree (AST), which presents the syntax level of the code in a tree structure, for example, a Python function will form a "function definition node" in the AST, which contains "function name node", "parameter node" and other child nodes, which intuitively reflects the syntax composition of the code.

[0037] Control Flow Graph (CFG), which represents the execution statements of the code (such as if judgment, for loop) with nodes and the execution order between statements (such as the execution path when the if condition is true, the execution path when the condition is not true) with edges, reflecting the logical execution flow of the code.

[0038] Step S1002: Extracting code entities, static relationships and metadata from the abstract syntax tree and the control flow graph.

[0039] Based on the constructed AST and CFG, three types of core information critical to the subsequent process are extracted, ensuring that the IR can fully reflect the structure and association of the code. The specific extraction content is as follows: Code entity extraction, code entity covers the core unit with independent function or meaning in the code, including module, class, function / method, code block, variable identification, location and declaration signature.

[0040] Static relationship extraction, extracting the fixed relationship between code entities, not involving dynamic runtime logic, including: inheritance relationship, inheritance relationship between classes; call relationship, call relationship between functions or methods; dependency relationship, entity dependency on other entities; definition-reference relationship.

[0041] Metadata extraction, extracting supplementary information to help understand the function of the entity, including: comments, explanatory comments of the entity; parameters, input parameters of functions or methods; return type, output result type, language type and source code summary of functions or methods.

[0042] Step S1003: Integrating the code entities, static relationships and metadata to generate a standardized intermediate representation, which is the IR.

[0043] Integrate the three types of core information of extracted code entities, static relationships and metadata according to the preset structured format to generate a standardized intermediate representation (IR), ensuring that the IR has the characteristics of uniform format and reusability. The specific integration rules are as follows: Use machine-parsable structured format to define uniform field names and data types for code entities, relationships of different languages, for example: Both Java and Python functions use "entity_type: "function"" to represent entity type. Both TypeScript and Java dependencies are represented as a list of dependencies: ["verifyPassword", "userDB"].

[0044] The association mapping of the three types of information is established to ensure that the IR can directly reflect the correspondence between entities, relationships, and metadata, for example: The login function entity is associated with its calling relationship (calling verifyPassword), metadata (parameters username / password, return value bool), and location information (src / auth.py lines 10-25). The UserAuth class entity is associated with its inheritance relationship (inheritance from BaseUser), dependency relationship (dependency on userDB), and source code content (complete definition code of the class).

[0045] The multi-language project code includes at least one static typed language project code or dynamic typed language project code. For example, the multi-language project code includes at least one of Java code, TypeScript code, and Python code.

[0046] Due to the large differences in syntax rules, traditional solutions are difficult to handle uniformly. IR parses different language codes into structured data in a unified format, integrates code entities, static relationships, and metadata, and eliminates parsing obstacles caused by language syntax differences. Regardless of the language of the input code, subsequent steps such as function decomposition and code extraction only need to be based on the unified fields of IR, such as entity location and dependency relationship, without the need to design processing logic for each language separately, achieving one-stop parsing and adaptation of multi-language code.

[0047] Step S102: input the IR into the large model, and perform semantic analysis on the code entities by the large model to identify business function attributes, build a function call graph and semantic index, and generate a function-code mapping table.

[0048] Specifically, step S102 includes steps S2001-S2003.

[0049] Step S2001: input the IR into the large model, and perform semantic analysis on the code entities and static relationships in the IR by the large model to identify the business function attributes corresponding to each code entity and generate a function call graph.

[0050] Through semantic understanding of the structured data in the IR by the large model, the code structure layer is deepened to the business function layer, the business meaning corresponding to the code entities is identified, and the functional association relationship is built, Input the IR in the large model adaptation format into the designated large model to ensure that the large model can read the entity attributes, static relationships, and metadata.

[0051] The preprocessing stage performs semantic enhancement on the IR data, such as integrating scattered function call relationships and class inheritance relationships into entity association fragments, and annotating the metadata. For example, associating a user login verification function with the entity source code provides context support for large model semantic analysis.

[0052] The large model performs functional semantic labeling on each code entity in the IR based on the code domain training knowledge. For class entities, the name, source code, and annotations of the class are combined to identify the corresponding business function attributes. For function entities, the function parameters, return values, call relationships, and annotations are combined to identify the corresponding business function attributes. For module / variable entities, the module purpose and variable associated entities are combined to identify the auxiliary business function attributes.

[0053] The large model generates a function call graph based on the identified business function attributes and the static relationships in the IR. The function call graph is constrained by the static relationships of the IR and supplemented by the semantic relationships of the large model. When there is a conflict between the semantic relationships and the static relationships, the system performs consistency verification and marks the source of the conflict, and if necessary, it reverts to the IR constraint path to ensure the verifiability and traceability of the function call graph. The function call graph structure is defined with business function modules as nodes and function call relationships and data flow as directed edges. It supports recursive decomposition of business function modules, which can be decomposed from top-level modules to bottom-level function-level functions, ensuring that the function call graph can reflect both the overall business logic and the specific code entity corresponding to the fine-grained function.

[0054] The termination conditions of the function recursive decomposition include any one or more of the following: the call depth reaches the preset maximum depth, the total number of expanded entities reaches the preset node budget, the cumulative code size exceeds the preset threshold, the cyclomatic complexity exceeds the preset threshold, the entity in-degree or out-degree exceeds the preset threshold, it crosses the preset module or language boundary, it appears circular dependency or repeated access, the time or resource consumption of a single analysis exceeds the upper limit; any condition triggers the current branch to stop further decomposition and is replaced by an abstract node, which records the entity name, declaration signature, core responsibility, and key dependencies to maintain the coherence of the function call graph; the above thresholds are configurable parameters and are recorded with session configuration to ensure result reproducibility; the function call graph is constrained by the static relationships of the IR and supplemented by the semantic relationships of the large model, and when there is a conflict between the two, consistency verification is performed and marked or reverted.

[0055] Step S2002: Use multi-modal embedding technology to convert the business function attribute description and the corresponding code entity into high-dimensional vectors and build a semantic index.

[0056] By multi-modal embedding technology, the business function description and code entity are converted into computable high-dimensional vectors, and a semantic association index of function-code is constructed to solve the problem of fast matching of function requirements and code entities.

[0057] A dual-encoder architecture is adopted, which includes a text encoder and a structure encoder. The text encoder is used to process unstructured function descriptions, and the structure encoder is used to process structured code entity information. Both of them work together to realize multi-dimensional semantic representation. The text encoder selects a pre-trained model that supports natural language and code text, which can convert business function descriptions and code entity annotations into text vectors. The structure encoder selects an encoder that supports tree / graph structure, which can convert the static relationships of code entities in IR into structure vectors.

[0058] For each business function module, the natural language description of the function and the metadata annotation of the corresponding code entity are input into the text encoder to generate a text vector of a predetermined dimension. The static relationships of the corresponding code entity are extracted from the IR and a local relationship graph is constructed, which is input into the structure encoder to generate a structure vector of the same dimension. The text vector and the structure vector are fused into a function-code fusion vector by element weighted summation.

[0059] All function-code fusion vectors are stored in a vector database, and an index mapping relationship is established. Each fusion vector is associated with the corresponding business function attribute and code entity information, ensuring that when the function extraction requirement is input later, the matching function module and code entity can be quickly located by vector similarity calculation.

[0060] Step S2003: generating a function-code mapping table based on the semantic index and the code entity attributes in the IR.

[0061] Based on the document technology logic, the function-code mapping table needs to include 3 types of core fields, and each field needs to be extracted from the IR or the results of the previous steps to ensure data accuracy. The function identification field records the unique information of the business function module, including function ID, function name, function level, and function description. The code association field records the code range corresponding to the function, which is extracted based on the entity location information in the IR, including associated code entity type, entity name, file path, start and end line number, and source code fragment. The dependency association field records the hard and soft dependencies required for function running, which is extracted based on the static relationships in the IR and the large model analysis results, including hard dependency and soft dependency.

[0062] The function identification field is extracted from the function call graph, and the code association field and the dependency association field are extracted from the IR. The data is associated by taking the function ID as the key, and filled into the corresponding fields of the mapping table. The large model is called to perform logical consistency verification on the filled mapping table, for example, to verify whether the module with a function description of password verification is associated with the verifyPassword() function (instead of irrelevant functions), and whether the call chain in the hard dependency is consistent with the static call relationship in the IR. If there is inconsistency (such as function and code mismatch), the mapping table data is revised based on the IR.

[0063] Step S103: According to the IR and the function-code mapping table, combined with the large model assisted decision-making, the code extraction is performed according to the hierarchical extraction strategy.

[0064] Specifically, step S103 includes step S3001-step S3002.

[0065] Step S3001: According to the function extraction requirement, based on the IR and the function-code mapping table, the target code entity matching the function extraction requirement is identified.

[0066] The function extraction requirement input by the user is received, the large model is called to perform semantic standardization on the requirement, and the natural language requirement is decomposed into three key elements of function type, extraction target and precision requirement to form a structured requirement description. Based on the function module matching of the semantic index, the standardized requirement description is input into the constructed semantic index, and the most relevant business function module is matched through vector similarity calculation (such as cosine similarity). Taking the matched function ID as an index, the function-code mapping table is queried to extract the code entity information associated with the function module: including code entity type (class / function / code block), entity name (such as login() function, UserAuth class), file path (such as src / auth.py), start and end line numbers (such as lines 10-25) and hard dependency chain (such as login()→verifyPassword()→checkDB()); combined with the IR, the accuracy of the code entity is verified, for example, through the entity position and static dependency relationship in the IR to confirm whether the start and end line numbers in the mapping table match the actual code and whether the hard dependency chain is consistent with the call relationship in the IR, to avoid positioning errors caused by mapping table errors, and finally determine the target code entity set to be extracted.

[0067] Step S3002: The hierarchical extraction strategy of L1 level extraction or L2 level extraction is performed on the target code entity, and the large model assisted decision-making is combined.

[0068] The execution of the layered extraction strategy is subject to the user's selection of L1 or L2; the system generates L1 / L2 pre-judgment suggestions and risk prompts based on at least one of the dependency chain depth, the number of dependencies, the importance of dependencies, the call heat, and the cycle complexity for the user to refer to; when the user's selection is inconsistent with the pre-judgment suggestion or the indicators are close to the threshold, the system inputs the IR segment of the target entity and the extraction target into the large model, and outputs the decision basis and risk prompt from the large model for the user to confirm, and finally takes the user-confirmed strategy as the execution strategy, and records the threshold configuration, model suggestion, and user confirmation with the session archive to ensure reproducibility and auditability.

[0069] In an optional embodiment, the system first calculates configurable quantitative indicators for the target code entity, such as dependency chain depth ≥ 3, number of dependencies > 5, hit core dependency, call heat ≥ 50, cycle complexity > 10, etc., generates L1 / L2 pre-judgment suggestions and corresponding risk prompts, and presents "suggested strategy and reason" in GUI / CLI. After viewing the suggestions, the user actively selects L1 or L2; when the user's selection is inconsistent with the pre-judgment or the indicators are close to the threshold, such as depth = 2 / 3 critical, number = 2 / 5 critical, the system submits the IR segment of the entity (including type, signature, location, static relationship, and annotation summary) and the user's extraction target to the large model, requests "L1 / L2 decision, reason, and risk", and displays the model's opinion together, and the user finally confirms the execution strategy. When executing L1, the class / function framework is retained according to the location and signature in the IR and the empty shell code conforming to the target language syntax is generated; when executing L2, the complete dependency chain is removed from bottom to top according to the IR static relationship, and invalid imports and invalid references are cleaned up in combination with static analysis tools and large model suggestions to ensure correct syntax and references. The entire process records the threshold snapshot, model suggestion, and user confirmation action with the session archive for result reproduction and audit.

[0070] If the dependency chain complexity is low and the extraction target is to retain the framework, the decision is simple extraction, and L1-level extraction is executed; If the dependency chain complexity is high and the extraction target is to completely delete the function, the decision is complex extraction, and L2-level extraction is executed; The decision result needs to be accompanied by the decision basis, and the user's requirement is to retain the framework, so L1-level extraction is executed for easy subsequent tracing and adjustment.

[0071] According to the extraction strategy decided by the large model, the code extraction operation is completed relying on the IR and the large model, ensuring that the extracted code is syntax-compliant and the remaining code has no invalid references.

[0072] Performing L1-level extraction, locating the framework structure of the target code entity based on the target code entity position and start-stop line numbers in the IR, the framework structure including class signature, function signature, preserving the framework structure, removing the implementation body of the target code entity, calling the large model to generate empty shell code conforming to the target language syntax, and inserting the empty shell code into the framework structure.

[0073] Specifically, L1-level extraction is suitable for scenarios where only the code structure needs to be preserved and the complete function is not required. Based on the start-stop line numbers and entity types of the target code entity in the IR, the framework structure is located. For class entities, the class signature and member function signature are preserved. For function entities, the function signature is preserved and the specific implementation code in the function body is deleted. The large model is called to input the language type, entity type, and framework structure fragment of the target code entity. The large model generates empty shell code conforming to the language syntax specification. The generated empty shell code is inserted into the preserved framework structure to replace the original implementation body, ensuring that the syntax of the extracted code is complete (e.g., functions will not cause compilation errors due to missing function bodies).

[0074]

[0075] Performing L2-level extraction, based on the target code entity dependency relationship in the IR and the hard dependency in the function-code mapping table, analyzing the complete dependency chain of the target code entity, removing the code corresponding to the target code entity and its complete dependency chain, calling the large model to give repair suggestions / completion of empty shell code, and performing syntax checking by the target language compiler or static checker, deleting invalid import statements in the remaining code, adjusting type declarations, and repairing syntax integrity.

[0076] Specifically, L2-level extraction is suitable for scenarios where a functional module is completely removed to avoid residual code affecting system operation. The complete hard dependency chain of the target code entity is extracted from the function-code mapping table, and the static call relationship in the IR is combined to confirm that there are no missing dependent entities. In order from downstream to upstream, batch delete the code corresponding to each dependent entity, and based on the file path, start-stop line numbers, and located code fragments in the IR, delete the remaining normal code of the file after deletion.

[0077] Calling the large model to perform syntax scanning on all associated files after deleting the dependent entities, identifying two types of core problems: ​Invalid import statement: after deleting the UserAuth class, the from auth import UserAuth import statement in user_center.py is left over; Invalid reference: after deleting the login() function, the login(username, password) call code in user_center.py is left over; Large model based on language syntax rules to automatically repair, delete invalid import statements, and safely handle invalid references, such as adding comments / / removed login function, replace with new implementation or delete the entire invalid call code block to avoid compilation errors.

[0078] Based on the entity reference relationship in IR, scan all project files to verify whether there are unremoved target entity association references; if there are missing references, repeat the syntax repair process until there are no associated reference residues.

[0079] Step S104: For the extracted code, call the target language compiler to perform static syntax checking and reference relationship verification, combine the large model to perform dependency missing backtracking and correction until the code passes the verification.

[0080] Specifically, step S104 includes steps S4001-S4003.

[0081] Step S4001: Call the target language compiler to perform static syntax checking on the extracted code, scan the code entity reference relationship in the extracted code based on IR, and verify whether the associated references of the removed module are synchronized.

[0082] Through professional compiler, the extracted code is screened for syntax compliance, and explicit syntax errors caused by extraction operation are quickly located, laying a foundation for subsequent deep verification. According to the language type of the extracted code, the corresponding target language compiler is called. The target language compiler is determined by the language. Python has no traditional compiler, usually uses interpreter / static type checking tool (mypy / pyright) and lint / AST verification, Java code calls javac compiler, Python code calls mypy static type checker, and TypeScript code calls tsc compiler.

[0083] The compiler is configured in strict syntax checking mode, all syntax checking rules are enabled, and explicit errors such as missing function body, invalid syntax symbols, type mismatch, undefined variables, etc. can be detected.

[0084] Batch input the extracted code into the compiler to perform static syntax compilation; the compiler generates structured error logs, which include error type, error location, and error description.

[0085] The script automatically classifies error logs, distinguishing between errors directly caused by extraction operations and original code errors. Extraction-related errors, such as missing function bodies due to incomplete shell code after L1 extraction, and import statement references to non-existent classes due to not deleting invalid imports after L2 extraction; original errors, such as variables not initialized in the code itself before extraction, are not handled at this time, only marked for later retention, ensuring that this step focuses only on problems caused by extraction operations.

[0086] Relying on the code entity reference relationship data in IR, implicit reference residue detection is performed on the extracted code to solve the problem of invalid references that may be missed by the compiler and dependencies that have not been cleared.

[0087] Extract the full code entity reference table from IR, which records the reference relationship of all code entities before extraction, including the reference party, the referenced party, and the reference location; combined with the extraction record, generate a removed entity list to clearly identify the referenced objects that need to be verified.

[0088] Build IR reference relationship-extracted code comparison logic, traverse all files of the extracted code, scan the code entity references, and compare them with the full code entity reference table in IR and the removed entity list.

[0089] Reference residue, there are still references to removed entities in the extracted code, such as the login function still calling the verifyPassword function after the L2 extraction deletes the verifyPassword function; Dependency loss, the referenced entity in the extracted code has not been removed, but the removed entity that the entity depends on causes it to not run normally, such as the user_info function depending on the user state returned by the login function, which causes the user_info function to indirectly depend on the login function due to the extraction operation.

[0090] Generate a reference relationship verification report, which needs to include the problem type, problem location, associated removed entity, and impact scope, for example: reference residue: user_center.py line 30 calls the login function, affecting the user entry function of the user_center module.

[0091] Step S4002: If the static syntax check or associated reference verification fails, trace back the dependency loss point based on the function call graph and the dependency relationship in IR.

[0092] Through the business logic of the large model combined with the function call graph, trace back the root cause of the problem and generate an accurate correction plan to ensure that the corrected code passes the verification. Integrate the extraction-related error logs, reference relationship verification report, function call graph, and extraction strategy record into a problem description data package.

[0093] Input the problem description data package in the large model adaptation format, and attach the modified constraints. For example, L1 level extraction needs to retain the framework structure and only modify the syntax errors, and L2 level extraction needs to completely remove the associated references of the removed entities without adding irrelevant code.

[0094] Step S4003: According to the traced dependent missing points, re-execute the large model assisted decision, adjust the extraction range or generate a stub code by the large model, and execute the code extraction and call the target language compiler to perform static syntax checking and reference relationship verification again until the extracted code passes the verification.

[0095] The large model attributes the problem based on the code domain knowledge and the business logic of the function call graph. For syntax errors, such as missing function body, it is attributed to the fact that the L1 level extraction did not generate compliant empty shell code, and invalid import is attributed to the fact that the L2 level extraction did not synchronize the deletion of associated import statements. For reference residue / dependent missing, combined with the upstream and downstream functional association of the removed entities in the function call graph, it traces whether the reference is missed during extraction or the dependent chain analysis is incomplete.

[0096] The large model generates a precise modification scheme based on the attribution result. The scheme needs to distinguish between extraction strategies. L1 level extraction modification, only fixes syntax errors, does not change the framework structure, such as modifying the missing function body to an empty shell code that conforms to the language specification, and supplements temporary default types for type mismatches. L2 level extraction modification, completely removes associated references, such as deleting invalid import statements, marking code blocks that reference removed entities as obsolete, and generating stub code to simulate removed functions for dependent missing. Automatically execute the modification scheme, call the code editing script, and batch modify the extracted code according to the modification scheme generated by the large model. If the modification scheme involves functional logic adjustment, add explicit comments in the code to facilitate subsequent manual optimization.

[0097] After modification, repeat the static syntax checking and reference relationship verification. If there are still problems, re-integrate the problem data into the large model and adjust the modification scheme. Until both verifications are error-free, output the extracted code that passes the verification.

[0098] If the execution of code extraction and the call to the target language compiler to perform static syntax checking and reference relationship verification fails after reaching the upper limit in multiple iterations or a set time period, output a failure report and manual review suggestions.

[0099] Step S105: Based on the verified code, generate a differentiated code package, output the reverse engineering processing result, and provide an engineering integration interface.

[0100] Specifically, collect all the extracted code files that have passed verification, archive them according to the original project's directory structure, ensure that the directory hierarchy of the code package is consistent with the original project, and reduce the adaptation cost in subsequent use.

[0101] Versioning the sorted code files, adding reverse processing identifiers in the header comments of each file, including processing time, extraction strategy, and processor / system identifier, to facilitate tracing the code source and processing method.

[0102] Automatic generation of verification reports, extracting key data from the verification process to generate structured verification reports, which should include: Static checking results: compiler verification conclusions for target languages, such as javac compilation passing without syntax errors; error repair records, such as fixing 2 invalid import statements and 1 type mismatch issue.

[0103] Dynamic test coverage: performing unit tests on core function modules of the extracted code, such as the preserved UserAuth class framework; recording test coverage, such as 85% core function test coverage; and explaining un-covered points, such as the empty shell code block not covered by testing.

[0104] Runtime log summary: if a simple runtime verification has been performed, such as starting the project main program to check if it crashes; then extract the runtime key logs, such as the project starting successfully without dependency missing error; and mark the running environment, such as Python3.9, JDK17.

[0105] Verification reports are output in both machine-readable and human-readable formats, the machine-readable format facilitates subsequent integration into automated tools, and the human-readable format facilitates quick review by developers / teachers.

[0106] Detailed record of function change log, based on extraction operation record and correction record, generate function change log, clear the specific changes brought by reverse processing, the log should include: Extraction function details: business function modules handled, extraction strategy, and involved code files and scope; Dependency adjustment details: deleted dependency entities, added temporary code, and preserved core dependencies; Risk warning: potential limitations of the extracted code, such as L1-level extracted empty shell code that needs to be supplemented for complete operation, and L2-level extracted deleted function modules that need to be reversed if they need to be restored, to help users avoid usage risks.

[0107] Compression and naming of code packages, package the sorted code files, verification reports, and change logs according to the root directory-submodule structure; use standardized naming formats, such as project name_reverse processing_extraction strategy_date.zip, to ensure that the core information of the achievement package can be quickly identified through the file name.

[0108] By constructing a command line and graphical interface dual-mode engineering interface, the use threshold of reverse results is reduced, and flexible use in different scenarios is supported.

[0109] The function definition of the CLI tool is based on a scripting language, which supports triggering the complete reverse engineering process through command line parameters or only calling the result output function. The CLI tool supports parameter verification and error feedback. If the input parameters are invalid, an explicit error prompt is output. Real-time logs are generated during execution, such as "Verification report is being generated…60% complete", which improves the user experience.

[0110] The integration of the IDE plug-in provides a graphical operation interface, project import, and automatic identification of project language types by selecting the original project path through folder browsing. The extraction strategy is visualized by selecting it through a drop-down menu, and the reverse engineering process is triggered by clicking the Start Processing button. The results preview and export allow real-time preview of key fragments of the extracted code and verification report summaries in the plug-in interface, and support one-click download of the differentiated code package through the Export Results Package button. The IDE plug-in adapts to the native functions of the IDE, such as supporting direct annotation of reverse-processed files in the project structure tree of the IDE, which facilitates quick identification during development.

[0111] Ensure the consistency of the core logic of the CLI tool and the IDE plug-in. The reverse engineering processing modules called by both are exactly the same, avoiding differences in processing results due to different interfaces. Adapt to different operating systems. The CLI tool is implemented through cross-platform scripts, and the IDE plug-in is packaged separately for different system versions of the IDE, ensuring that the interface is available on all platforms.

[0112] By integrating with mainstream CI / CD tools, the reverse engineering results can be automatically verified, versioned, and continuously delivered, and integrated into the existing development process.

[0113] Configure Git hooks in the Git repository of the original project to implement the linkage management of reverse processing results and code versions. When the developer submits code to the repository, the hook automatically triggers the change log update function to synchronize the reverse processing changes involved in this submission to CHANGELOG.md. When the code is pushed to the remote repository, the hook automatically calls the CI / CD integration script to trigger the automatic verification and push of the differentiated code package, ensuring that the reverse results and code versions are updated synchronously, and avoiding the use problems caused by inconsistent versions.

[0114] The differentiated code package is convenient for code review and refactoring, and the integration of engineering interface and CI / CD can shorten the development cycle and avoid the inefficiency and errors caused by manual processing; for teaching scenarios, structured verification reports and change logs can assist teaching, such as showing students the complete logic of code extraction, and the graphical operation of the IDE plug-in reduces the use threshold of teaching personnel and supports on-demand generation of code completion exercises; there is no direct reuse link in the subsequent stage, but the differentiated code package and engineering interface generated thereby can serve as the basis for subsequent project iteration and function expansion.

[0115] In addition, the terms "first", "second", "third", etc. are used only for the purpose of description, and should not be understood as indicating or implying relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined with "first", "second", etc. can explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise explicitly specified.

[0116] In the description of the present application, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example" or "some examples" means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present application, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in the present application.

[0117] Other embodiments of the present application will be apparent to those skilled in the art upon consideration of the specification and practice of the application disclosed. The present application is intended to cover any variations, uses or adaptive changes of the present application following the general principles of the present application and including common knowledge or conventional technical means in the art not disclosed by the present application.

Claims

1. A large model-based intelligent reverse software programming method, characterized in that, The method comprises the following steps: standardized parsing of input multi-language project code, extraction of code entities, static relationships and metadata, generation of a standardized intermediate representation, which is IR; inputting the IR into a large model, semantic analysis of the code entities by the large model to identify business function attributes, construction of a function call graph and a semantic index, and generation of a function-code mapping table; code extraction according to a hierarchical extraction strategy based on the IR and the function-code mapping table, combined with decision-making assistance of the large model; static syntax checking and reference relationship verification of the extracted code by calling a target language compiler, combined with dependence missing backtracking and correction by the large model until the code passes the verification; generation of a differential code package based on the verified code, output of the reverse engineering processing result, and provision of an engineering integration interface.

2. The large model-based intelligent reverse software programming method according to claim 1, characterized in that, The step of standardized parsing of input multi-language project code, extraction of code entities, static relationships and metadata, and generation of a standardized intermediate representation, which is IR, comprises: lexical analysis and syntax analysis of the multi-language project code by using a code parsing tool chain, construction of an abstract syntax tree and a control flow graph of the project code; extraction of code entities, static relationships and metadata from the abstract syntax tree and the control flow graph; integration of the code entities, static relationships and metadata, and generation of a standardized intermediate representation, which is IR.

3. The large model-based intelligent reverse software programming method of claim 2, wherein, The code entities include the identification, location and declaration signature of modules, classes, functions / methods and code blocks; the static relationships include inheritance relationships, call relationships, dependency relationships and definition-reference relationships; and the metadata includes annotations, parameters, return types, language types and source code summaries.

4. The large model-based intelligent reverse software programming method of claim 1, wherein, The multi-language project code at least includes language project code of a static type or language project code of a dynamic type.

5. The large model-based intelligent reverse software programming method according to claim 1, characterized in that, The step of inputting the IR into a large model, semantic analysis of the code entities by the large model to identify business function attributes, construction of a function call graph and a semantic index, and generation of a function-code mapping table comprises: inputting the IR into the large model, semantic analysis of the code entities and static relationships in the IR by the large model, identification of the business function attributes corresponding to each code entity, and construction of a function call graph; conversion of the business function attribute descriptions and the corresponding code entities into high-dimensional vectors and construction of a semantic index by using a multi-modal embedding technology; generation of a function-code mapping table based on the semantic index and the code entity attributes in the IR.

6. The large model-based intelligent reverse software programming method according to claim 5, characterized in that, The multi-modal embedding technology includes a text encoder and a structure encoder; the function call graph represents business function modules by nodes and call relationships and data flow directions between the business function modules by edges, and the business function modules can be recursively disassembled to function-level granularity.

7. The large model-based intelligent reverse software programming method according to claim 5, characterized in that, The function-code mapping table labels the code range, hard dependency and soft dependency corresponding to each business function module, the code range includes classes, functions and code blocks, the hard dependency is a function call chain, and the soft dependency is a configuration file and a resource path.

8. The large model based intelligent reverse software programming method according to claim 1, wherein, The step of performing code extraction according to the hierarchical extraction strategy in combination with the large model assisted decision-making according to the IR and the function-code mapping table comprises: According to the function extraction requirement, based on the IR and the function-code mapping table, the target code entity matching the function extraction requirement is identified; The hierarchical extraction strategy of L1 level extraction or L2 level extraction is performed on the target code entity, and the large model assisted decision-making is combined.

9. The large model-based intelligent reverse software programming method according to claim 8, characterized in that, The step of performing the hierarchical extraction strategy of L1 level extraction or L2 level extraction on the target code entity and combining the large model assisted decision-making comprises: Perform L1 level extraction, locate the framework structure of the target code entity based on the target code entity position and the start and end line numbers in the IR, the framework structure includes class signature, function signature, reserve the framework structure, remove the implementation of the target code entity, call the large model to generate the empty shell code conforming to the target language syntax, and insert the empty shell code into the framework structure; Perform L2 level extraction, analyze the complete dependency chain of the target code entity based on the target code entity dependency relationship in the IR and the hard dependency in the function-code mapping table, remove the code corresponding to the target code entity and its complete dependency chain, call the large model to give repair suggestions / completion of the empty shell code, and perform syntax checking by the target language compiler or static checker, delete invalid import statements in the remaining code, adjust type declaration, and repair syntax integrity.

10. The large model based intelligent reverse software programming method according to claim 1, wherein, The step of calling the target language compiler to perform static syntax checking and reference relationship verification on the extracted code, combining the large model to trace and correct the missing dependencies, until the code passes the verification comprises: Call the target language compiler to perform static syntax checking on the extracted code, scan the code entity reference relationship in the extracted code based on the IR, and verify whether the associated reference of the removed module is synchronized cleared; If the static syntax checking or the associated reference verification fails, trace the missing dependency point based on the function call graph and the dependency relationship in the IR; According to the traced missing dependency point, re-execute the large model assisted decision-making, adjust the extraction range or generate the stub code by the large model, and perform code extraction again, and call the target language compiler to perform static syntax checking and reference relationship verification, until the extracted code passes the verification.