Data processing method and apparatus, device, and storage medium
By generating custom domain-specific language structure information through the compiler and using the virtual machine to parse symbolic information, the problem of Dart being unable to JIT run in Flutter is solved, execution efficiency is improved, and compilation and execution are decoupled.
Patent Information
- Application Number
- PCT/CN2024/142529
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-20
- Filing Date
- 2024-12-25
- Publication Date
- 2025-09-25
AI Technical Summary
Dart in Flutter cannot be directly parsed at runtime (JIT), resulting in reduced execution efficiency and limited application scenarios of native Dart in Flutter.
The source code of the initial programming language is compiled into custom domain-specific language structure information through the compiler, and the compilation result resources are loaded and parsed using the virtual machine. The symbol information is stored in the target scope, and the symbol information is called through the scope entry identifier to realize the runtime parsing of the initial programming language.
It implements JIT operation of the original programming language, improves execution efficiency, and decouples compilation and operation.
Smart Images

Figure CN2024142529_25092025_PF_FP_ABST
Abstract
Description
Data processing method, device, equipment and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 20, 2024, with application number 202410323218.4 and application name “Data processing method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of information technology, and in particular to a data processing method, apparatus, device, and storage medium. Background Art
[0003] Dart in Flutter is compiled ahead of time (AOT), meaning it must be compiled into machine code before running. Therefore, Dart in Flutter cannot be directly parsed just in time (JIT). Furthermore, while native Dart supports JIT, its application scenarios are limited and cannot be used in Flutter. Furthermore, during execution, Dart must be compiled before running, which reduces execution efficiency. Summary of the Invention
[0004] The present application provides a data processing method, apparatus, device, and storage medium for solving the technical problem in the prior art that Dart cannot be parsed when directly running Flutter, thereby reducing execution efficiency.
[0005] In a first aspect, the present application provides a data processing method, comprising:
[0006] Compiling the source code of the initial programming language through a compiler to obtain a compilation result resource, wherein the compilation result resource includes custom domain characteristic language structure information;
[0007] Loading and parsing the compilation result resource through a virtual machine to obtain symbol information in the compilation result resource, and storing the symbol information in a target scope;
[0008] The virtual machine uses a target query strategy to call the symbol information from the target scope according to the scope entry identifier, and runs the called symbol information to complete the runtime parsing of the initial programming language.
[0009] In a possible design, compiling the source code of the initial programming language by a compiler to obtain a compilation result resource includes:
[0010] The compiler compiles the source code of the initial programming language using a single source code file as a unit, and stores compiler node information of the source code of the initial programming language in the custom domain-specific language structure to obtain the compilation result resource.
[0011] In a possible design, the user-defined domain-specific language structure information includes syntax information of the source code file, and the syntax information includes package references, variables, functions, classes, and type aliases.
[0012] In a possible design, loading and parsing the compilation result resource by a virtual machine to obtain symbol information in the compilation result resource includes:
[0013] The symbol information is obtained and loaded according to the custom domain feature language structure information, wherein the symbol information is the accessible syntax information, and the symbol information includes mandatory symbol information and optional symbol information. The mandatory symbol information includes the import content in the package reference, and the optional symbol information includes the export content and part content in the package reference.
[0014] In one possible design, calling the symbol information from the target scope by the virtual machine using a corresponding query strategy according to a scope entry identifier includes:
[0015] The virtual machine determines a target call entry according to the scope entry identifier, and calls the symbol information from the target scope through the target call entry;
[0016] The target call entry includes at least one of a class call entry, a mixin call entry, an extension call entry, a static call entry, an anonymous function call entry, an internal function call entry, and an original call entry.
[0017] In a possible design, the symbol information called by the execution includes:
[0018] The virtual machine obtains a set of various function execution processes in the symbol information, and sets a preset evaluation method to identify the execution process of the expression, statement, function and class corresponding to the symbol information.
[0019] In one possible design, the setting of the preset evaluation method to identify the execution process of the expression, statement, function, and class corresponding to the symbol information includes:
[0020] Setting a method name for the class corresponding to the symbolic information by the virtual machine, and identifying an execution process of the class in the symbolic information with an evaluation method of the function in the symbolic information, wherein the method name is used to identify member function information in the symbolic information being called;
[0021] The method for evaluating the function corresponding to the symbolic information by the virtual machine is to use the target scope, the positional parameter list, and the named parameter icon as parameters, and sequentially execute different expressions or statements under the function;
[0022] The method for evaluating the expression and the statement corresponding to the symbolic information by the virtual machine is to use the target scope as a parameter.
[0023] In one possible design, the function execution process includes:
[0024] The virtual machine constructs a new context scope according to the target call entry, and points the upper layer of the new context scope to the scope corresponding to the current source code file;
[0025] Obtain function parameters and store the function parameters in the new context scope, execute the method body and obtain the result of the function execution process, wherein the execution method body includes the process of executing each expression and statement under the function.
[0026] In a possible design, if the target call entry corresponds to a class function call, before obtaining function parameters and storing the function parameters in the new context scope, the method further includes:
[0027] Generate current variables and store the current variables in the new context scope.
[0028] In one possible design, the compiler includes an abstract syntax tree; and the initial programming language includes a pre-runtime compiled programming language.
[0029] In a second aspect, the present application provides a data processing device, comprising:
[0030] A compilation module, configured to compile the source code of the initial programming language through a compiler to obtain compilation result resources, wherein the compilation result resources include custom domain feature language structure information;
[0031] A loading and parsing module, configured to load and parse the compilation result resource through a virtual machine to obtain symbol information in the compilation result resource, and store the symbol information in a target scope;
[0032] The running module is used to call the symbol information from the target scope by using the virtual machine according to the scope entry identifier and adopting a corresponding query strategy, and run the called symbol information to complete the runtime parsing of the initial programming language.
[0033] In one possible design, the compiling module is specifically configured to:
[0034] The compiler compiles the source code of the initial programming language using a single source code file as a unit, and stores compiler node information of the source code of the initial programming language in the custom domain-specific language structure to obtain the compilation result resource.
[0035] In a possible design, the user-defined domain-specific language structure information includes syntax information of the source code file, and the syntax information includes package references, variables, functions, classes, and type aliases.
[0036] In one possible design, the loading and parsing module is specifically used to:
[0037] The symbol information is obtained and loaded according to the custom domain feature language structure information, wherein the symbol information is the accessible syntax information, and the symbol information includes mandatory symbol information and optional symbol information. The mandatory symbol information includes the import content in the package reference, and the optional symbol information includes the export content and part content in the package reference.
[0038] In one possible design, the operation module is specifically used to:
[0039] Determining a target call entry according to the scope entry identifier by the virtual machine, and calling the symbol information from the target scope through the target call entry;
[0040] The target call entry includes at least one of a class call entry, a mixin call entry, an extension call entry, a static call entry, an anonymous function call entry, an internal function call entry, and an original call entry.
[0041] In a possible design, the operation module is further used to:
[0042] A set of various function execution processes in the symbol information is obtained through the virtual machine, and a preset evaluation method is set to identify the execution process of the expression, statement, function and class corresponding to the symbol information.
[0043] In a possible design, the operation module is further used to:
[0044] Setting a method name for the class corresponding to the symbolic information by the virtual machine, and identifying an execution process of the class in the symbolic information with an evaluation method of the function in the symbolic information, wherein the method name is used to identify member function information in the symbolic information being called;
[0045] The method for evaluating the function corresponding to the symbolic information by the virtual machine is to use the target scope, the positional parameter list, and the named parameter icon as parameters, and sequentially execute different expressions or statements under the function;
[0046] The method for evaluating the expression and the statement corresponding to the symbolic information by the virtual machine is to use the target scope as a parameter.
[0047] In a possible design, the operation module is further used to:
[0048] Constructing a new context scope according to the target call entry by the virtual machine, and pointing the upper layer of the new context scope to the scope corresponding to the current source code file;
[0049] Obtain function parameters and store the function parameters in the new context scope, execute the method body and obtain the result of the function execution process, wherein the execution method body includes the process of executing each expression and statement under the function.
[0050] In a possible design, the operation module is further used to:
[0051] Generate current variables and store the current variables in the new context scope.
[0052] In one possible design, the compiler includes an abstract syntax tree; and the initial programming language includes a pre-runtime compiled programming language.
[0053] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0054] The memory stores computer-executable instructions;
[0055] The processor executes the computer-executable instructions stored in the memory to implement any possible data processing method provided in the first aspect.
[0056] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement any possible data processing method provided in the first aspect.
[0057] In a fifth aspect, the present application provides a computer program product, comprising computer-executable instructions, which, when executed by a processor, are used to implement any possible data processing method provided in the first aspect.
[0058] The present application provides a data processing method, apparatus, device and storage medium, which first compiles the source code of the initial programming language through a compiler to obtain a compilation result resource, wherein the compilation result resource includes a domain characteristic language of custom domain characteristic language structure information. The compilation result resource is then loaded and parsed by a virtual machine to obtain the symbolic information in the compilation result resource, and the symbolic information is stored in a target scope. The virtual machine then uses a target query strategy to call the symbolic information from the target scope according to the scope entry identifier, and runs the called symbolic information to complete the runtime parsing of the initial programming language. The data processing method provided in the present application generates a domain characteristic language of custom domain characteristic language structure information after compiling the source code through a compiler, and uses a virtual machine to parse the domain characteristic language and run it, thereby realizing the function of runtime parsing of the initial programming language, and decoupling compilation from operation, effectively increasing the execution efficiency of runtime parsing of the initial programming language. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0060] FIG1 is a schematic diagram of an application scenario provided by an embodiment of the present application;
[0061] FIG2 is a flow chart of a data processing method provided in an embodiment of the present application;
[0062] FIG3 is a schematic diagram of DSL structure information provided in an embodiment of the present application;
[0063] FIG4 is a schematic diagram of a scope hierarchy structure provided in an embodiment of the present application;
[0064] FIG5 is a schematic diagram of a process for calling symbolic information provided by an embodiment of the present application;
[0065] FIG6 is a schematic diagram of the execution process of a function in a virtual machine provided in an embodiment of the present application;
[0066] FIG7 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;
[0067] FIG8 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of methods and apparatus consistent with certain aspects of the present application, as detailed in the appended claims.
[0069] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the numbers used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0070] Dart in Flutter runs AOT, meaning it must be compiled into machine code before running. Therefore, Dart in Flutter cannot be JIT-ed. Furthermore, while native Dart supports JIT, its application scenarios are limited and cannot be used in Flutter. Furthermore, Dart must be compiled before running, reducing execution efficiency.
[0071] In response to the above-mentioned problems existing in the prior art, the present application provides a data processing method, apparatus, device and storage medium. The inventive concept of the data processing method provided by the present application is: the source code of the initial programming language is compiled by a compiler to generate a custom domain feature language, wherein the custom domain feature language has its structural information customized, which can restore the original grammatical features to the maximum extent, and facilitate candidate operation and error log collection and analysis. Furthermore, based on the feature of supporting JIT operation in Dart VM, the compilation result resources generated by the compiler are parsed and run by the virtual machine, and the compilation result resources include the custom domain feature language structural information, thereby achieving the effect of JIT operation of the initial programming language. Among them, in the virtual machine, the symbol information parsed from the compilation result resources is stored in the target scope. At runtime, by setting the scope entry identifier, different query strategies can be used to call the symbol information from the target scope, which can quickly realize the search of each symbol information, thereby improving the execution efficiency and decoupling the compilation and operation.
[0072] FIG1 is a schematic diagram of an application scenario provided by an embodiment of the present application. As shown in FIG1 , a Flutter toolkit is running on an electronic device 100 for developing a financial mobile application that can be run on a mobile terminal 300. Since Dart in Flutter cannot be JIT-run, the electronic device 200 is configured to execute the data processing method provided by an embodiment of the present application. First, the source code is compiled by a compiler to generate a custom domain feature language, and a compilation result resource is obtained. Then, the compilation result resource is parsed and run using a virtual machine, thereby realizing the function of runtime parsing of the initial programming language, and decoupling compilation from operation, effectively increasing the execution efficiency of runtime parsing of the initial programming language. Among them, a compiler and a virtual machine are running in the electronic device 200. In some embodiments, the compiler can be, for example, an Abstract Syntax Tree (AST).
[0073] In some embodiments, the electronic device 100 and the electronic device 200 can be, for example, smart phones, tablet computers, computers, servers, server clusters and other devices. The embodiment of the present application does not limit the device types of the electronic device 100 and the electronic device 200. The electronic device 100 and the electronic device 200 in Figure 1 are illustrated by taking computers as an example. The mobile terminal 300 can be, for example, a smart phone, tablet computer, smart watch or other wearable smart device, computer, laptop computer, or any other terminal that can support financial applications developed by Flutter. The embodiment of the present application does not limit the type of mobile terminal 300. The mobile terminal 300 in Figure 1 is illustrated by taking a smart phone as an example. In addition, the embodiment of the present application does not limit the specific content of the financial application. For example, it can be an application such as the U chat desktop terminal of a financial institution department.
[0074] It should be noted that the above application scenarios are merely illustrative, and the data processing methods, devices, equipment, and storage media provided in the embodiments of the present application include but are not limited to the above application scenarios.
[0075] FIG2 is a flow chart of a data processing method provided in an embodiment of the present application. As shown in FIG2 , the data processing method provided in an embodiment of the present application includes:
[0076] S101: Compiling the source code of the initial programming language by a compiler to obtain a compilation result resource.
[0077] The compilation result resources include custom domain-specific language structure information.
[0078] For example, a compiler is used to compile the source code of the initial programming language to generate custom domain-specific language (DSL) structure information, that is, to obtain the compilation result resource. The custom domain-specific language structure information not only includes the grammatical information of the source code file, but also includes the custom structure information. The initial programming language can be a programming language compiled before the execution of the program, that is, it can include the corresponding programming language run by AOT.
[0079] Customize domain-specific language structure information. For example, the isGetter and isSetter fields in a function type can indicate whether it is a getter or setter function, distinguishing it from other functions. Getter and setter functions with the same name can also be used as a variable. Another example is a function body, which can contain two types of function bodies: a standard method body and a function body that is a syntax sugar expression. Customizing domain-specific language structure information allows you to maximize the restoration of original syntax features, facilitating subsequent execution and error log collection and analysis.
[0080] In one possible design, possible implementations of step S101 include:
[0081] The compiler compiles the source code of the initial programming language in a single source code file as a unit, and stores the compiler node information of the source code of the initial programming language into the custom domain feature language structure information to obtain the compilation product, which is defined as the compilation result resource.
[0082] For example, the syntax information in a single source code file can be described in the form of a DSL, but not limited to JSON. The DSL structure information compiled from a single Dart file is shown in FIG3 .
[0083] As shown in Figure 3, based on the syntax characteristics of the Dart language, each DSL contains the syntax information of the current Dart source code file, such as package references, variables, functions, classes, type aliases, etc. Dashed boxes indicate optional items, and dashed lines indicate optional one-to-one or one-to-many relationships.
[0084] In some embodiments, package references may include import, export, part and other contents, which mainly include path, prefix, display name and hidden name. Variables may include name, type and value, where type and value are optional, and value is the value of the variable or expression. The type is Type, which has three types: function generic, named type and Record type. Functions may include positional parameters, named parameters and method bodies, etc. Method bodies may include block method bodies and expression method bodies (lambda expressions). The method body may include statements, such as if statements, switch statements, etc., and statements may be composed of multiple expressions, such as binary expressions, method call expressions, assignment expressions, lists, maps, etc. Meta classes may include classes, mixins, enumerations, extensions, etc., where classes may include member variables, member functions, constructors, static member variables, static member functions, etc. Generic aliases may include class type aliases, method aliases, etc.
[0085] To further facilitate runtime parsing, you can also set specific character identifiers, such as &(XX), @(XX), ^(XX), etc., to identify variable / function access, Meta access, member variable access, etc.
[0086] In some embodiments, specific contents such as expressions and statements are related to the syntax of the source code file. The embodiments of the present application are not limited to this, and they can be represented using the same data interface. For example, taking a DSL in JSON format as an example, the DSL structure information such as expressions, statements, and functions can be as follows:
[0087] The DSL structure information of the expression can be:
[0088] A binary expression, such as a+b, has a DSL structure that can:
[0089] The DSL structure information of a statement is, for example:
[0090] The if statement looks like the following code:
[0091] Its DSL structure information can be, for example:
[0092] The function is like the add function below:
[0093] Its DSL structure information can be, for example:
[0094] A lambda expression function, such as the add function: int add(int a, int b)=>a+b; its DSL structure information can be, for example:
[0095] S102: Loading and parsing the compilation result resource through the virtual machine to obtain symbol information in the compilation result resource, and storing the symbol information in the target scope.
[0096] The symbolic information in the compiled result resources refers to the variables, functions, classes, and other information accessible during code execution, also known as accessible syntax information. The execution of Dar code involves the continuous loading, querying, creation, and updating of symbolic information.
[0097] The virtual machine loads and parses the compilation result resources output by the compiler, for example, obtains the symbol information in the compilation result resources based on the custom domain feature language structure information, and stores the symbol information in the target scope.
[0098] In some embodiments, the symbol information loading process for each DSL may include: loading its own symbol information, loading exported symbol information, loading part symbol information, and loading imported symbol information based on import information. Symbol information includes both mandatory and optional symbol information. For example, mandatory symbol information includes import content in package references, i.e., import information, because Dart source code implicitly imports dart:core during execution. Optional symbol information includes exported content in package references, i.e., export symbol information, as well as part content and part symbol information.
[0099] In some embodiments, the hierarchical structure of target scopes can be, for example, as shown in FIG4 . Setting a hierarchical structure of context target scopes for storing symbolic information during execution allows for relative independence of symbolic information between different scopes, thereby effectively controlling the scope of symbolic information. Each level of scope stores symbolic information such as classes, variables, and functions accessed within the current level, and can access symbolic information in the upper-level context scope by reference.
[0100] S103: The virtual machine uses a target query strategy to call symbol information from the target scope according to the scope entry identifier, and runs the called symbol information to complete the runtime parsing of the initial programming language.
[0101] For the symbolic information loaded and parsed, the virtual machine determines the target call entry based on the pre-set scope entry identifier, and then enters the target call entry to query the corresponding symbolic information from the target scope, and then performs the function execution process on the queried symbolic information to complete the runtime parsing of the initial programming language.
[0102] In some embodiments, the scope entry identifier is used to identify the target call entry, and the target call entry may include but is not limited to at least one of a class call entry, a mixed mixin call entry, an extended call entry, a static call entry, an anonymous function call entry, an internal function call entry, and an original call entry. Among them, the original call entry identifies the entry of the code block inside the function. Different target call entries can effectively distinguish the symbol information query order in different scenarios, and can also improve the query speed. For example, for a static call entry, only static member variables and global variables need to be queried, and extended member information does not need to be queried. Therefore, setting the scope entry identifier can identify the level of the scope and can quickly perform corresponding symbol information queries based on different target call entries at runtime.
[0103] Adopting a corresponding query strategy based on a scope entry means that different target call entries can be determined based on different scope entry identifiers, so that corresponding symbol information can be queried through the corresponding target call entry. In some embodiments, the process of using different query strategies to query corresponding symbol information based on different scope entry identifiers can be shown in Figure 5. It should be noted that Figure 5 is only an illustrative example of some target call entries and does not limit them.
[0104] As shown in Figure 3, the DSL structure information shows that executing Dart source code, or running calls to symbolic information, is a collection of various function execution processes, with the smallest execution unit being an expression. Furthermore, based on the characteristics of the DSL structure information, a pre-defined "Evaluate" method can be set to identify the execution process of the expression, statement, function, or class corresponding to the symbolic information.
[0105] In some embodiments, the execution process of the expression, statement, function, and class corresponding to the preset evaluation method identifier symbol information is set. Possible implementation methods include:
[0106] The virtual machine can be used to set a method name for the class corresponding to the symbolic information, and use the evaluation method of the function in the symbolic information to identify the execution process of the class in the symbolic information, where the method name is used to identify the member function information in the symbolic information that is called. Compared with the parameters of the evaluation method of the function, the parameters of the class evaluation method have the method name added. Therefore, the evaluation method of the function corresponding to the symbolic information by the virtual machine takes the target scope, positional parameter list, and named parameter icon (Map) as parameters, and executes different expressions or statements under the function in sequence. The evaluation method of the expression and statement corresponding to the symbolic information by the virtual machine takes the target scope as a parameter, so that it can be executed according to its DSL structure information and obtain the corresponding execution results.
[0107] In one possible design, the function execution process may be as shown in FIG6 , which is a schematic diagram of the function execution process in a virtual machine provided by an embodiment of the present application. As shown in FIG6 , the function execution process includes:
[0108] S201: A new context scope is constructed according to a target call entry through a virtual machine, and the upper layer of the new context scope is pointed to the scope corresponding to the current source code file.
[0109] A new context scope is constructed based on different target call entries, and the upper layer of the newly constructed context scope points to the scope corresponding to the current source code file. The current source code file is the current Dart file.
[0110] S202: Determine whether the target call entry corresponds to a class function call.
[0111] Determine whether the current target call entry corresponds to a class function call. If so, execute step S203; if not, execute step S204.
[0112] S203: Generate current variables and store the current variables in a new context scope.
[0113] If it is a class function call, the current (this) variable is constructed and placed in the newly constructed context scope to access the attributes of the class during the function call. In other words, the class instance is placed in the new scope as the current variable, and then step S204 is executed.
[0114] S204: Obtain function parameters and store them in a new context scope, execute the method body and obtain the result of the function execution process.
[0115] The execution method body includes the process of executing each expression and statement under the function.
[0116] Calculating the value of the function parameters is to obtain the function parameters, which include positional parameters and named parameters, and storing the calculated function parameters in the new context scope, and finally executing the method body.
[0117] The process of executing a method body is the process of executing various statements and expressions. If other functions are called, the process repeats. If a code block such as if or switch is executed, a new scope is created and its parent is pointed to the current scope to control different scopes. When the method body is executed, the entire function execution process ends, and the result of the function execution can be obtained.
[0118] For example, the add function in the aforementioned embodiment places the two parameters a and b passed in into the scope during execution. At the same time, when executing a binary expression, the values of a and b are queried in the scope and then the addition operation is performed to complete the execution of the add function.
[0119] At this point, by designing and implementing the execution process of all Dart expressions, statements, functions, classes, etc., we can complete the JIT execution of the Dart language, that is, complete the runtime parsing of the initial programming language.
[0120] The data processing method provided in the embodiment of the present application first compiles the source code of the initial programming language through a compiler to obtain a compilation result resource, wherein the compilation result resource includes a domain characteristic language of custom domain characteristic language structure information. The compilation result resource is then loaded and parsed by a virtual machine to obtain the symbolic information in the compilation result resource, and the symbolic information is stored in the target scope. The virtual machine then uses the target query strategy to call the symbolic information from the target scope according to the scope entry identifier, and runs the called symbolic information to complete the runtime parsing of the initial programming language. The data processing method provided in the present application compiles the source code through a compiler to generate a domain characteristic language of custom domain characteristic language structure information, and uses a virtual machine to parse the domain characteristic language and run it, thereby realizing the function of runtime parsing of the initial programming language, and decoupling compilation from operation, effectively increasing the execution efficiency of runtime parsing of the initial programming language.
[0121] FIG7 is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. As shown in FIG7 , the data processing device 400 provided in an embodiment of the present application includes:
[0122] Compilation module 401, used to compile the source code of the initial programming language through a compiler to obtain compilation result resources, the compilation result resources including custom domain feature language structure information;
[0123] The loading and parsing module 402 is used to load and parse the compilation result resource through the virtual machine to obtain the symbol information in the compilation result resource, and store the symbol information in the target scope;
[0124] The running module 403 is used to call symbol information from the target scope using a corresponding query strategy according to the scope entry identifier through the virtual machine, and run the called symbol information to complete the runtime analysis of the initial programming language.
[0125] In one possible design, the compilation module 401 is specifically configured to:
[0126] The compiler compiles the source code of the initial programming language using a single source code file as a unit, and stores compiler node information of the source code of the initial programming language in a custom structure to obtain a compilation result resource.
[0127] In a possible design, the custom domain-specific language structure information includes syntax information of a source code file, where the syntax information includes package references, variables, functions, classes, and type aliases.
[0128] In one possible design, the loading and parsing module 402 is specifically configured to:
[0129] Obtain and load symbol information based on custom domain feature language structure information. Symbol information is accessible syntax information. Symbol information includes mandatory symbol information and optional symbol information. Mandatory symbol information includes import content in package references, and optional symbol information includes export content and part content in package references.
[0130] In one possible design, the running module 403 is specifically configured to:
[0131] The virtual machine determines the target call entry according to the scope entry identifier, and calls the symbol information from the target scope through the target call entry;
[0132] The target call entry includes at least one of a class call entry, a mixin call entry, an extension call entry, a static call entry, an anonymous function call entry, an internal function call entry, and an original call entry.
[0133] In one possible design, the running module 403 is further configured to:
[0134] The virtual machine is used to obtain a collection of various function execution processes in the symbol information, and a preset evaluation method is set to identify the execution process of the expression, statement, function and class corresponding to the symbol information.
[0135] In one possible design, the running module 403 is further configured to:
[0136] The method name is set for the class corresponding to the symbol information through the virtual machine, and the execution process of the class in the symbol information is identified by the evaluation method of the function in the symbol information. The method name is used to identify the member function information in the called symbol information.
[0137] The method of evaluating the function corresponding to the symbolic information through the virtual machine is to use the target scope, positional parameter list and named parameter icon as parameters, and execute different expressions or statements under the function in sequence;
[0138] The evaluation method of the expression and statement corresponding to the symbolic information by the virtual machine is to use the target scope as a parameter.
[0139] In one possible design, the running module 403 is further configured to:
[0140] A new context scope is constructed through the virtual machine according to the target call entry, and the upper layer of the new context scope points to the scope corresponding to the current source code file;
[0141] Get the function parameters and store them in the new context scope, execute the method body and get the result of the function execution process. Executing the method body includes the process of executing each expression and statement under the function.
[0142] In one possible design, the running module 403 is further configured to:
[0143] Generates the current variable and stores it in the new context scope.
[0144] In one possible design, the compiler includes an abstract syntax tree; and the initial programming language includes a pre-runtime compiled programming language.
[0145] The data processing device provided in the embodiment of the present application can execute the corresponding steps of the data processing method in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0146] FIG8 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. As shown in FIG8 , the electronic device 500 may include: a processor 501 and a memory 502 communicatively connected to the processor 501 .
[0147] The memory 502 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer-executable instructions.
[0148] The memory 502 may include a high-speed RAM memory, and may also include a non-volatile memory (NoN-volatile memory), such as at least one disk memory.
[0149] The processor 501 is configured to execute computer-executable instructions stored in the memory 502 to implement the above-mentioned data processing method.
[0150] The processor 501 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0151] Optionally, the memory 502 may be independent or integrated with the processor 501 .
[0152] When the memory 502 is a device independent of the processor 501, the electronic device 500 may further include:
[0153] Bus 503 is used to connect processor 501 and memory 502. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, control buses, etc., but this does not mean there is only one bus or only one type of bus.
[0154] Optionally, in a specific implementation, if the memory 502 and the processor 501 are integrated on a chip, the memory 502 and the processor 501 can communicate through an internal interface.
[0155] The present application also provides a computer-readable storage medium, which may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes. Specifically, the computer-readable storage medium stores computer execution instructions, and the computer execution instructions are used for the methods in the above embodiments.
[0156] The present application also provides a computer program product, including computer execution instructions, which implement the method in the above embodiment when executed by a processor.
[0157] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered merely as exemplary, and the true scope and spirit of the present application are indicated by the claims.
[0158] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A data processing method, wherein: include: Compiling the source code of the initial programming language through a compiler to obtain a compilation result resource, wherein the compilation result resource includes custom domain characteristic language structure information; Loading and parsing the compilation result resource through a virtual machine to obtain symbol information in the compilation result resource, and storing the symbol information in a target scope; The virtual machine uses a target query strategy to call the symbol information from the target scope according to the scope entry identifier, and runs the called symbol information to complete the runtime parsing of the initial programming language.
2. The data processing method according to claim 1, wherein: The compilation result resource is obtained by compiling the source code of the initial programming language through the compiler, including: The compiler compiles the source code of the initial programming language using a single source code file as a unit, and stores compiler node information of the source code of the initial programming language in the custom domain-specific language structure to obtain the compilation result resource.
3. The data processing method according to claim 1 or 2, wherein: The user-defined domain-specific language structure information includes syntax information of the source code file, and the syntax information includes package references, variables, functions, classes, and type aliases.
4. The data processing method according to any one of claims 1 to 3, wherein: The step of loading and parsing the compilation result resource by a virtual machine to obtain symbol information in the compilation result resource includes: The symbol information is obtained and loaded according to the custom domain feature language structure information, wherein the symbol information is the accessible syntax information, and the symbol information includes mandatory symbol information and optional symbol information. The mandatory symbol information includes the import content in the package reference, and the optional symbol information includes the export content and part content in the package reference.
5. The data processing method according to any one of claims 1 to 4, wherein: The calling the symbol information from the target scope by the virtual machine according to the scope entry identifier and adopting a corresponding query strategy includes: Determining a target call entry according to the scope entry identifier by the virtual machine, and calling the symbol information from the target scope through the target call entry; The target call entry includes at least one of a class call entry, a mixin call entry, an extension call entry, a static call entry, an anonymous function call entry, an internal function call entry, and an original call entry.
6. The data processing method according to any one of claims 1 to 5, wherein: The symbol information called by the operation includes: A set of various function execution processes in the symbol information is obtained through the virtual machine, and a preset evaluation method is set to identify the execution process of the expression, statement, function and class corresponding to the symbol information.
7. The data processing method according to claim 6, wherein: The setting of the preset evaluation method identifies the execution process of the expression, statement, function, and class corresponding to the symbol information, including: Setting a method name for the class corresponding to the symbolic information by the virtual machine, and identifying an execution process of the class in the symbolic information with an evaluation method of the function in the symbolic information, wherein the method name is used to identify member function information in the symbolic information being called; The method for evaluating the function corresponding to the symbolic information by the virtual machine is to sequentially execute different expressions or statements under the function using the target scope, the positional parameter list, and the named parameter icon as parameters; The method for evaluating the expression and the statement corresponding to the symbolic information by the virtual machine is to use the target scope as a parameter.
8. The data processing method according to claim 6, wherein: The function execution process includes: Constructing a new context scope according to the target call entry by the virtual machine, and pointing the upper layer of the new context scope to the scope corresponding to the current source code file; Obtain function parameters and store the function parameters in the new context scope, execute the method body and obtain the result of the function execution process, wherein the execution method body includes the process of executing each expression and statement under the function.
9. The data processing method according to claim 8, wherein: If the target call entry corresponds to a class function call, before obtaining function parameters and storing the function parameters in the new context scope, the method further includes: Generate current variables and store the current variables in the new context scope.
10. The data processing method according to any one of claims 1 to 9, wherein: The compiler includes an abstract syntax tree; the initial programming language includes a pre-runtime compiled programming language.
11. A data processing device, characterized in that: include: A compilation module, configured to compile the source code of the initial programming language through a compiler to obtain compilation result resources, wherein the compilation result resources include custom domain feature language structure information; A loading and parsing module, configured to load and parse the compilation result resource through a virtual machine to obtain symbol information in the compilation result resource, and store the symbol information in a target scope; The running module is used to call the symbol information from the target scope by using the virtual machine according to the scope entry identifier and adopting a corresponding query strategy, and run the called symbol information to complete the runtime parsing of the initial programming language.
12. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the data processing method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the data processing method according to any one of claims 1 to 10.
14. A computer program product, comprising computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the computer-executable instructions are used to implement the data processing method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Search optimization method and device, electronic equipment and storage medium
CN112364053A
Code compiling method and device, code running method and device, computer equipment and storage medium
CN114706586A
Text programming language compiling method based on decoupling architecture
CN116501330A
Code compiling method and device and compiler
CN117519715A
Data processing method and device, equipment and storage medium
CN118151945A