CN114706586A - Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium - Google Patents

Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium Download PDF

Info

Publication number
CN114706586A
CN114706586A CN202210243133.6A CN202210243133A CN114706586A CN 114706586 A CN114706586 A CN 114706586A CN 202210243133 A CN202210243133 A CN 202210243133A CN 114706586 A CN114706586 A CN 114706586A
Authority
CN
China
Prior art keywords
file
code
dart
compiling
bytecode
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210243133.6A
Other languages
Chinese (zh)
Inventor
季涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202210243133.6A priority Critical patent/CN114706586A/en
Publication of CN114706586A publication Critical patent/CN114706586A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/425Lexical analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/48Incremental compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure provides a code compiling method, a code running method, a code compiling apparatus, a code running apparatus, a computer device and a storage medium, wherein the method comprises: acquiring a to-be-processed Dart code file applied by the Flutter; compiling the Dart code file to be processed, and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed; and acquiring a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file. In the embodiment of the disclosure, the Dart code file to be processed may be compiled, and the intermediate compiled file is compiled according to a preset byte code format, so as to obtain and store a target byte code file, where a Dart virtual machine in the Flutter application may run the byte code file to be executed through a Dart interpreter, thereby implementing a function corresponding to the byte code file to be executed, further shortening an update flow of the Flutter application, and improving update efficiency.

Description

Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a code compiling method, a code running method, a code compiling apparatus, a code running apparatus, a computer device, and a storage medium.
Background
With the popularization of the Flutter cross-terminal technology, more and more Flutter applications are developed based on the Flutter cross-terminal technology, and therefore, the requirements for version updating and problem repairing of the Flutter applications are more and more common. However, in the existing scheme for compiling the code of the Flutter application, the obtained patch package often needs to be uploaded to an application store, so that the user downloads the patch package from the application store, thereby completing function repair or version update in the Flutter application, which results in a relatively long whole update process and a relatively low update efficiency.
Disclosure of Invention
The embodiment of the disclosure at least provides a code compiling method, a code running method, a code compiling device, a code running device, computer equipment and a storage medium.
In a first aspect, an embodiment of the present disclosure provides a code compiling method applied to a server, where the server includes a Dart compiler, and the method includes:
acquiring a to-be-processed Dart code file of the Flutter application, wherein the to-be-processed Dart code file comprises a Dart code of a new function in the Flutter application, or comprises a Dart code of a to-be-repaired function in the Flutter application; compiling the Dart code file to be processed, and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed; and acquiring a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file.
In an optional implementation manner, the obtaining a preset byte code format and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file includes:
acquiring attribute information of each component in the intermediate compilation file; wherein the attribute information is used for indicating the byte code format matched with the corresponding component; and compiling the intermediate compilation file based on the attribute information and the preset byte code format to obtain the target byte code file.
In an optional implementation manner, the compiling the intermediate compiled file based on the attribute information and the preset bytecode format to obtain the target bytecode file includes:
determining a target bytecode format matching with a corresponding component among the bytecode formats based on the attribute information; and compiling the components according to the target byte code format to obtain the target byte code file.
In an optional implementation manner, the obtaining an intermediate compiled file in the compiling process of the to-be-processed Dart code file includes:
and acquiring a dynamic link library file in the compiling process of the Dart code file to be processed, and determining the dynamic link library file as the intermediate compiled file.
In an optional embodiment, the method further comprises:
and after the target byte code file is stored, responding to a calling request of a user terminal to a target function corresponding to the target byte code file, and sending the target byte code file to the user terminal.
In a second aspect, an embodiment of the present disclosure provides a code running method, applied to a Flutter application, including:
acquiring a bytecode file to be executed, which is sent by a server; wherein the bytecode file to be executed is a bytecode file obtained by a Dart compiler in the server after compiling by the code compiling method according to any of the first aspect; and calling a Dart virtual machine in the Flutter application, and operating the bytecode file to be executed through a Dart interpreter in the Dart virtual machine so as to realize the function corresponding to the bytecode file to be executed in the Flutter application.
In an optional embodiment, the running, by a Dart interpreter in the Dart virtual machine, the bytecode file to be executed includes:
analyzing the byte code file to be executed to obtain an analysis result; extracting target byte code information from the analysis result, and loading the target byte code information in the Dart virtual machine; and running the target bytecode information through the Dart interpreter.
In a third aspect, an embodiment of the present disclosure further provides a code compiling apparatus, including:
the device comprises a first obtaining unit, a second obtaining unit and a third obtaining unit, wherein the first obtaining unit is used for obtaining a to-be-processed Dart code file of the Flutter application, and the to-be-processed Dart code file comprises a Dart code of a new function in the Flutter application or comprises a Dart code of a to-be-repaired function in the Flutter application; the compiling unit is used for compiling the Dart code file to be processed and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed; and the second acquisition unit is used for acquiring a preset byte code format and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file.
In a fourth aspect, an embodiment of the present disclosure further provides a code running apparatus, including:
the third acquisition unit is used for acquiring the byte code file to be executed sent by the server; wherein the bytecode file to be executed is a bytecode file obtained by a Dart compiler in the server after compiling by the code compiling method according to any of the first aspect; and the calling unit is used for calling a Dart virtual machine in the Flutter application, and running the bytecode file to be executed through a Dart interpreter in the Dart virtual machine so as to realize the function corresponding to the bytecode file to be executed in the Flutter application.
In a fifth aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the computer device is running, the machine-readable instructions being executable by the processor to perform the steps of any one of the possible implementations of the first to second aspects.
In a sixth aspect, the disclosed embodiments further provide a computer-readable storage medium, where a computer program is stored, and the computer program is executed by a processor to perform the steps in any one of the possible implementation manners of the first aspect to the second aspect.
The embodiment of the disclosure provides a code compiling method, a code running method, a code compiling device, a code running device, a computer device and a storage medium. In the embodiment of the disclosure, after a to-be-processed Dart code file of a Flutter application is obtained, the to-be-processed Dart code file may be compiled, an intermediate compiled file in the compiling process of the to-be-processed Dart code file is obtained, and then the intermediate compiled file may be compiled according to a preset byte code format, so as to obtain and store a target byte code file, where the target byte code file may be sent to the Flutter application as a to-be-executed byte code, so that a Dart virtual machine in the Flutter application operates the to-be-executed byte code file through a Dart interpreter, thereby implementing a function corresponding to the to-be-executed byte code file, further shortening an update flow of the Flutter application, and improving update efficiency.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is to be understood that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art to which the disclosure pertains without the benefit of the inventive faculty, and that additional related drawings may be derived therefrom.
Fig. 1 shows a flowchart of a code compiling method provided by an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating a Dart compiler compiling a to-be-processed Dart code file according to an embodiment of the disclosure;
FIG. 3 is a flow chart illustrating a method for executing code provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a code compiling apparatus provided by an embodiment of the disclosure;
FIG. 5 is a schematic diagram of a code running device provided by an embodiment of the present disclosure;
FIG. 6 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure;
fig. 7 shows a schematic diagram of another computer device provided by an embodiment of the disclosure.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions in the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Research shows that in the existing scheme for compiling the code of the Flutter application, the obtained patch package is often required to be uploaded to an application store, so that a user downloads the patch package from the application store, and thus function repair or version update in the Flutter application is completed, the whole update process is relatively long, and the update efficiency is relatively low.
Based on the research, the present disclosure provides a code compiling method, a code running method, a code compiling apparatus, a code running apparatus, a computer device, and a storage medium. In the embodiment of the disclosure, after a to-be-processed Dart code file of a Flutter application is obtained, the to-be-processed Dart code file may be compiled, an intermediate compiled file in the compiling process of the to-be-processed Dart code file is obtained, and then the intermediate compiled file may be compiled according to a preset byte code format, so as to obtain and store a target byte code file, where the target byte code file may be sent to the Flutter application as a to-be-executed byte code, so that a Dart virtual machine in the Flutter application operates the to-be-executed byte code file through a Dart interpreter, thereby implementing a function corresponding to the to-be-executed byte code file, further shortening an update flow of the Flutter application, and improving update efficiency.
To facilitate understanding of the present embodiment, a code compiling and code running method disclosed in the embodiments of the present disclosure is first described in detail, and an execution subject of the code compiling and code running method provided in the embodiments of the present disclosure is generally a computer device with certain computing capability. In some possible implementations, the code compiling, code running method may be implemented by a processor invoking computer readable instructions stored in a memory.
Referring to fig. 1, a flowchart of a code compiling method provided in an embodiment of the present disclosure is a code compiling method applied to a server, where the server includes a Dart compiler, the method includes steps S101 to S105, where:
s101: acquiring a to-be-processed Dart code file of the Flutter application, wherein the to-be-processed Dart code file comprises a Dart code of a new function in the Flutter application, or comprises a Dart code of a to-be-repaired function in the Flutter application.
In the embodiment of the present disclosure, a to-be-processed Dart code file of the Flutter application needs to be obtained first. Here, in the case of repairing a function to be repaired in the Flutter application or developing a new function for the Flutter application, the obtained repair product or development product may be the Dart code file to be processed.
It should be understood that, since the compiling language of the Flutter application is the Dart language, a language adopted when the Flutter application is subjected to new function development or a function to be repaired is also the Dart language, and an obtained repair product or a development product is the Dart code file to be processed.
S103: and compiling the Dart code file to be processed, and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed.
In the embodiment of the present disclosure, after the to-be-processed Dart code file is obtained, the to-be-processed Dart code file may be compiled. In specific implementation, the Dart code file to be processed may be loaded into a Dart compiler, so that the Dart compiler identifies and compiles the Dart code file to be processed.
Here, the process of compiling the Dart code file to be processed by the Dart compiler is shown in fig. 2, where syntax analysis and lexical analysis may be performed on the Dart code file to be processed first to obtain an intermediate compiled file, and here, the process of syntax analysis and lexical analysis on the Dart code file to be processed is described below, and is not described herein again.
It should be understood that, as can be seen from fig. 2, after the Dart compiler performs intermediate optimization and instruction generation on the intermediate compiled file in sequence, the resulting compiled product is an AOT compiled file, which is a binary code associated with a processor type.
S105: and acquiring a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file.
In this embodiment of the disclosure, as shown in fig. 2, the Dart compiler may compile the intermediate compiled file according to a preset byte code format to obtain a target byte code file, and store the target byte code file.
It should be understood that the intermediate compiled file may be compiled by the Dart compiler described above, thereby outputting the target bytecode file.
In the embodiment of the present disclosure, after the target bytecode file is obtained, the target bytecode file can be saved in a local file. In specific implementation, first, whether the target bytecode file is a bytecode file corresponding to a new function developed for the Flutter application is determined based on a function identifier of the target bytecode file, where the function identifier is used to indicate a function in the Flutter application corresponding to the target bytecode file.
When it is determined that the target function corresponding to the target bytecode file is not a new function based on the function identifier, it may be determined that the target function corresponding to the target bytecode file is based on the function identifier, and a first storage location corresponding to the target function in the local file is determined. Then, a second storage location for storing the target bytecode file can be determined based on the storage directory of the first storage location in the local file, and the target bytecode file can be saved in the local file based on the second storage location, wherein the second storage location is located under the storage directory of the first storage location.
In addition, when the second storage location contains the bytecode file of the other version of the target function, the bytecode file of the other version can be deleted in advance; then, the target byte code file is stored in the second storage position, and the storage space of the server can be cleaned through the processing mode, so that the waste of the storage space is avoided.
When the target function corresponding to the target bytecode file is determined to be a new function based on the function identifier, a first storage location of the target function may be determined in the local file of the server, for example, a first storage location may be allocated to the target bytecode file in the storage location of the local file of the server, and a second storage location corresponding to the target bytecode file may be determined based on the first storage location. The target bytecode file can then be saved to a local file based on the second storage location.
As can be seen from the above description, in the embodiment of the present disclosure, after the to-be-processed Dart code file of the Flutter application is obtained, the to-be-processed Dart code file may be compiled, and an intermediate compiled file in the compiling process of the to-be-processed Dart code file is obtained, and then the intermediate compiled file may be compiled according to a preset byte code format, so as to obtain and store a target byte code file, where the target byte code file may be sent to the Flutter application as the to-be-executed byte code, so that a Dart virtual machine in the Flutter application operates the to-be-executed byte code file through a Dart interpreter, thereby implementing a function corresponding to the to-be-executed byte code file, further shortening an update flow of the Flutter application, and improving update efficiency.
In an optional embodiment, in step S103, obtaining an intermediate compiled file in the compiling process of the to-be-processed Dart code file specifically includes the following processes:
and acquiring a dynamic link library file in the compiling process of the Dart code file to be processed, and determining the dynamic link library file as the intermediate compiled file.
In the embodiment of the present disclosure, as can be seen from fig. 2, after the Dart code file to be processed is obtained, the intermediate compiled file can be obtained by performing syntax analysis and lexical analysis on the Dart code file to be processed. In specific implementation, after performing syntax analysis and lexical analysis on the Dart code file to be processed, a dynamic link library file (i.e., a dill file) of the Dart code file to be processed may be obtained first, and then the dynamic link library file may be determined as an intermediate compiled file, where the dynamic link library file may be an intermediate compiled file (i.e., a kernel product).
In the embodiment of the present disclosure, firstly, the to-be-processed Dart code file needs to be parsed and lexical analyzed. Specifically, the parsing can be used to identify the word sequence of the Dart code in the Dart code file to be processed, and analyze whether the word sequence of the Dart code conforms to the syntax of the Dart language. In addition, the lexical analysis can be used for identifying the characters in the Dart code file to be processed and analyzing whether the characters in the Dart code file to be processed meet the requirements of the Dart code.
Here, in the case that the word sequence of the Dart code in the Dart code file to be processed does not conform to the syntax of the Dart language, or the characters in the Dart code file to be processed do not conform to the requirement of the Dart code, the Dart code in the Dart code file to be processed may be modified, so that the modified Dart code file to be processed can be normally compiled.
After the to-be-processed Dart code file is subjected to syntactic analysis and lexical analysis, the to-be-processed Dart code file can be compiled to obtain a dynamic link library file (i.e., dill file) of the to-be-processed Dart code file, and the dynamic link library file is determined as an intermediate compiled file.
As can be seen from the above description, by obtaining the dynamic link library file in the compiling process of the Dart code file to be processed, the dynamic link library file can be determined as an intermediate compiled file, so that the Dart compiler can compile the intermediate compiled file to obtain the target bytecode file.
In an optional embodiment, in step S105, obtaining a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file, specifically including the following steps:
s1051: acquiring attribute information of each component in the intermediate compilation file; wherein the attribute information is used for indicating the byte code format matched with the corresponding component.
As can be seen from the above description, in the embodiment of the present disclosure, the to-be-processed Dart code file corresponds to a new function or a to-be-repaired function in a Flutter application, where the to-be-processed Dart code file includes Dart codes for implementing different types of instructions.
For example, the pending Dart code file may include Dart codes of various types of instructions such as data access, method call, type check, mathematical operation, memory allocation, content jump, and the like. Therefore, after the intermediate compiled file obtained by compiling the Dart code file to be processed is obtained, the intermediate compiled file may include various components for implementing different types of instructions. Here, the types of instructions that can be implemented by each component in the compiled file may be different, and thus, each component may correspond to different attribute information.
It should be understood that the type of the implemented instruction, the corresponding compiling rule, and the format of the bytecode converted according to the compiling rule, which are indicated by the different attribute information, should be different. Therefore, in the embodiment of the present disclosure, a matching bytecode format may be preset for each attribute information.
S1052: and compiling the intermediate compilation file based on the attribute information and the preset byte code format to obtain the target byte code file.
In the embodiment of the present disclosure, after determining the attribute information of each component in the intermediate compilation file, the predetermined bytecode format corresponding to each component may be determined based on the attribute information of each component. Then, based on the byte code format, the compiling rule of the component part can be determined; and converting each component into a preset byte code format based on the compiling rule so as to obtain a target byte code file corresponding to the intermediate compiling file.
According to the description, the preset byte code format is determined according to the attribute information of each component in the intermediate compilation file, and the intermediate compilation file is compiled according to the preset byte code format to obtain the target byte code file, so that the correctness of the determined target byte code file is ensured, and the normal operation of the target byte code file is ensured.
In an optional implementation manner, in the step S1052, the compiling the intermediate compiled file based on the attribute information and the preset bytecode format to obtain the target bytecode file, specifically including the following processes:
(1) determining a target bytecode format matched with the corresponding component in the bytecode formats based on the attribute information;
(2) and compiling the components according to the target byte code format to obtain the target byte code file.
In the embodiment of the present disclosure, a mapping relationship between different attribute information and corresponding bytecode formats may be established in advance through a table. Therefore, after determining the attribute information of the component in the intermediate compilation file, the mapping relationship can be obtained in the table. Then, a target bytecode format matching the component can be determined based on the mapping relationship. Then, the component can be compiled according to the target byte code format to obtain a target byte code file.
According to the description, the mapping relation between different attribute information and the corresponding byte code formats can be established, so that the target byte code format corresponding to the attribute information of the components in the intermediate compilation file can be directly determined according to the mapping relation, the efficiency of determining the target byte code format is improved, and the efficiency of converting the intermediate compilation file into the target byte code file is improved.
In an optional embodiment, the method further comprises the process of:
and after the target byte code file is stored, responding to a calling request of a user terminal to a target function corresponding to the target byte code file, and sending the target byte code file to the user terminal.
In the embodiment of the present disclosure, after detecting a call request of a user for the target function, the Flutter application may send an acquisition request of a target bytecode file for the target function to the server. After receiving the obtaining request, the server may determine a function identifier of a target function carried by the obtaining request, and determine a storage location of a target bytecode file of the target function in the local file based on the function identifier, thereby obtaining the target bytecode file based on the storage location, and returning the found target bytecode file to the Flutter application in response to the calling request.
It should be understood that, in the embodiment of the present disclosure, after detecting a call request of a user for an arbitrary function in the Flutter application, the Flutter application may first determine whether the function is a target function, and in a case that the function is the target function, may want the server to send an acquisition request of a target bytecode file of the target function.
Specifically, the target function may include an update identifier, and after a call request for any function in the Flutter application is detected, it may be determined whether the function includes the update identifier, and in a case that the function includes the update identifier, the function may be determined as the target function.
In another optional implementation manner, after the target bytecode file is saved, the target bytecode file can be directly sent to the Flutter application. In specific implementation, the function type of the target function corresponding to the target bytecode file may be determined first, where the function type of the function to be repaired may be a first type, and the function type of the new function may be a second type.
Under the condition that the function type of the target function is determined to be the second type, the target byte code file can be directly sent to the Flutter application, so that a user can experience the target function corresponding to the target byte code file. In addition, when the function type of the target function is determined to be the first type, a sending instruction for the target bytecode file may be detected, and after the sending instruction is detected, the target bytecode file may also be directly sent to the Flutter application.
According to the description, the target byte code file can be sent to the Flutter application in response to the acquisition request for the target byte code file, and the target byte code file can also be directly sent to the Flutter application, so that the scheme can be suitable for different types of target functions, and the application range of the scheme is widened.
In an alternative embodiment, as shown in fig. 2, a Dart compiler compiles a to-be-processed Dart code file, and the method includes steps S201 to S204. Wherein:
s201: acquiring a Dart code file to be processed;
s202: performing syntactic analysis and lexical analysis on the processed Dart code file to obtain an intermediate compiled file;
in the embodiment of the present disclosure, the syntax analysis and the lexical analysis are performed on the processed Dart code file as described in the embodiment corresponding to the step S103, which is not described herein again.
S203: acquiring a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file;
in the embodiment of the present disclosure, first, attribute information of each component in an intermediate compiled file may be obtained, and the intermediate compiled file is compiled according to a preset bytecode format indicated by the attribute information, so as to obtain a target bytecode file. The specific process of compiling the intermediate compilation file is described in the above embodiment corresponding to step S105, and is not described herein again.
S204: and performing intermediate optimization and instruction generation on the intermediate compiled file to obtain the AOT compiled file.
As can be seen from the above description, in the embodiment of the present disclosure, after the to-be-processed Dart code file of the Flutter application is obtained, the to-be-processed Dart code file may be compiled, an intermediate compiled file in the compiling process of the to-be-processed Dart code file is obtained, and then the intermediate compiled file may be compiled according to the preset byte code format, so as to obtain and store the target byte code file. Here, the target bytecode file can be sent to the Flutter application as the to-be-executed bytecode, so that a Dart virtual machine in the Flutter application runs the to-be-executed bytecode file through a Dart interpreter, thereby implementing a function corresponding to the to-be-executed bytecode file, further shortening an update flow of the Flutter application, and improving update efficiency.
In addition, referring to fig. 3, a flowchart of a code running method provided in an embodiment of the present disclosure is applied to a Flutter application, where the method includes steps S301 to S303, where:
s301: acquiring a bytecode file to be executed, which is sent by a server; the bytecode file to be executed is a bytecode file obtained by a Dart compiler in the server after compiling by the code compiling method corresponding to fig. 1.
In this disclosure, a to-be-executed bytecode file sent by a server may be first obtained, where the to-be-executed bytecode file is the target bytecode file. Here, the bytecode file to be executed may be a target bytecode file returned by the server based on a call request initiated by the Flutter application, or may be a target bytecode file directly transmitted by the server.
After the to-be-executed bytecode file is acquired, the to-be-executed bytecode file can be stored in a local storage space of the terminal device installed with the Flutter application.
S303: and calling a Dart virtual machine in the Flutter application, and operating the bytecode file to be executed through a Dart interpreter in the Dart virtual machine so as to realize the function corresponding to the bytecode file to be executed in the Flutter application.
In the embodiment of the present disclosure, after a call request for a target function is detected, a to-be-executed bytecode file corresponding to the target function may be loaded to a Dart virtual machine, so that a Dart interpreter in the Dart virtual machine runs the to-be-executed bytecode file, thereby implementing a function corresponding to the to-be-executed bytecode file.
According to the above description, after the to-be-executed bytecode file sent by the acquisition server is obtained, the to-be-executed bytecode file can be run through the Dart virtual machine, so that the function corresponding to the to-be-executed bytecode file is realized, the updating process of the Flutter application is further shortened, and the updating efficiency is improved.
In an optional embodiment, in step S301, running the to-be-executed bytecode file through a Dart interpreter in the Dart virtual machine specifically includes the following processes:
(1) analyzing the byte code file to be executed to obtain an analysis result;
(2) extracting target byte code information from the analysis result, and loading the target byte code information in the Dart virtual machine;
(3) and operating the target bytecode information through the Dart interpreter.
In the embodiment of the present disclosure, the bytecode file to be executed may be parsed first, an executable bytecode file in the bytecode file to be executed is determined, and the executable bytecode file is determined as a parsing result.
After the parsing result is determined, the executable bytecode file included in the parsing result may be extracted to obtain target bytecode information in the executable bytecode file, where the target bytecode information may be information indicated by fields such as library, function, and field in the executable bytecode file.
After the target bytecode information is determined, the target bytecode information can be loaded into a Dart virtual machine, so that a Dart interpreter in the Dart virtual machine runs the target bytecode information, and thus, the function corresponding to the bytecode file to be executed is realized.
As can be seen from the above description, by extracting the target bytecode information in the bytecode file to be executed, the target bytecode information can be loaded into the Dart virtual machine, so that the Dart interpreter in the Dart virtual machine runs the bytecode file to be executed, thereby implementing the function corresponding to the bytecode file to be executed.
In summary, in the embodiment of the present disclosure, after a to-be-processed Dart code file of a Flutter application is obtained, the to-be-processed Dart code file may be compiled, an intermediate compiled file in a compiling process of the to-be-processed Dart code file is obtained, and then the intermediate compiled file may be compiled according to a preset byte code format, so as to obtain and store a target byte code file, where the target byte code file may be sent to the Flutter application as a to-be-executed byte code, so that a Dart virtual machine in the Flutter application operates the to-be-executed byte code file through a Dart interpreter, thereby implementing a function corresponding to the to-be-executed byte code file, further shortening an update process of the Flutter application, and improving update efficiency.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, a code compiling device corresponding to the code compiling method is also provided in the embodiments of the present disclosure, and as the principle of solving the problem of the device in the embodiments of the present disclosure is similar to the code running method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 4, a schematic diagram of a code compiling apparatus provided in an embodiment of the present disclosure is shown, where the apparatus includes: a first acquiring unit 41, a compiling unit 42, a second acquiring unit 43; wherein the content of the first and second substances,
a first obtaining unit 41, configured to obtain a Dart code file to be processed of a Flutter application, where the Dart code file to be processed includes a Dart code of a new function in the Flutter application, or includes a Dart code of a function to be repaired in the Flutter application;
the compiling unit 42 is configured to compile the to-be-processed Dart code file, and acquire an intermediate compiled file in a compiling process of the to-be-processed Dart code file;
a second obtaining unit 43, configured to obtain a preset byte code format, and compile the intermediate compilation file according to the preset byte code format, to obtain and store a target byte code file.
In the embodiment of the disclosure, after a to-be-processed Dart code file of a Flutter application is obtained, the to-be-processed Dart code file may be compiled, an intermediate compiled file in the compiling process of the to-be-processed Dart code file is obtained, and then the intermediate compiled file may be compiled according to a preset byte code format, so as to obtain and store a target byte code file, where the target byte code file may be sent to the Flutter application as a to-be-executed byte code, so that a Dart virtual machine in the Flutter application operates the to-be-executed byte code file through a Dart interpreter, thereby implementing a function corresponding to the to-be-executed byte code file, further shortening an update flow of the Flutter application, and improving update efficiency.
In a possible implementation, the second obtaining unit 43 is further configured to:
acquiring attribute information of each component in the intermediate compilation file; wherein the attribute information is used for indicating the byte code format matched with the corresponding component;
and compiling the intermediate compilation file based on the attribute information and the preset byte code format to obtain the target byte code file.
In a possible implementation, the second obtaining unit 43 is further configured to:
determining a target bytecode format matching with a corresponding component in the bytecode formats based on the attribute information;
and compiling the components according to the target byte code format to obtain the target byte code file.
In a possible embodiment, the compiling unit 42 is further configured to:
and acquiring a dynamic link library file in the compiling process of the Dart code file to be processed, and determining the dynamic link library file as the intermediate compiled file.
In one possible embodiment, the apparatus is further configured to:
and after the target byte code file is stored, responding to a call request of a user terminal for a target function corresponding to the target byte code file, and sending the target byte code file to the user terminal.
Referring to fig. 5, a schematic diagram of a code running apparatus provided in an embodiment of the present disclosure is shown, where the apparatus includes: a third acquiring unit 51 and a calling unit 52; wherein the content of the first and second substances,
a third obtaining unit 51, configured to obtain a bytecode file to be executed and sent by the server; wherein, the bytecode file to be executed is a bytecode file obtained after a Dart compiler in the server compiles by the code compiling method of any one of the above claims 1 to 5;
the calling unit 52 is configured to call a Dart virtual machine in the Flutter application, and run the bytecode file to be executed through a Dart interpreter in the Dart virtual machine, so as to implement a function corresponding to the bytecode file to be executed in the Flutter application.
In the embodiment of the disclosure, after the to-be-executed bytecode file sent by the acquisition server is acquired, the to-be-executed bytecode file can be run through the Dart virtual machine, so that a function corresponding to the to-be-executed bytecode file is realized, an update process of the Flutter application is further shortened, and the update efficiency is improved.
In a possible implementation, the third obtaining unit 51 is further configured to:
analyzing the byte code file to be executed to obtain an analysis result;
extracting target byte code information from the analysis result, and loading the target byte code information in the Dart virtual machine;
and running the target bytecode information through the Dart interpreter.
The description of the processing flow of each unit in the device and the interaction flow between each unit may refer to the related description in the above method embodiments, and will not be described in detail here.
Corresponding to the code compiling method in fig. 1, an embodiment of the present disclosure further provides a computer device 600, as shown in fig. 6, a schematic structural diagram of the computer device 600 provided for an embodiment of the present disclosure includes:
a processor 61, a memory 62, and a bus 63; the memory 62 is used for storing execution instructions and includes a memory 621 and an external memory 622; the memory 621 is also referred to as an internal memory, and is used for temporarily storing the operation data in the processor 61 and the data exchanged with the external memory 622 such as a hard disk, the processor 61 exchanges data with the external memory 622 through the memory 621, and when the computer device 600 operates, the processor 61 communicates with the memory 62 through the bus 63, so that the processor 61 executes the following instructions:
acquiring a to-be-processed Dart code file of the Flutter application, wherein the to-be-processed Dart code file comprises a Dart code of a new function in the Flutter application, or comprises a Dart code of a to-be-repaired function in the Flutter application;
compiling the Dart code file to be processed, and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed;
and acquiring a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file.
Corresponding to the code running method in fig. 3, an embodiment of the present disclosure further provides a computer device 700, as shown in fig. 7, a schematic structural diagram of the computer device 700 provided for an embodiment of the present disclosure includes:
a processor 71, a memory 72, and a bus 73; the memory 72 is used for storing execution instructions and includes a memory 721 and an external memory 722; the memory 721 is also referred to as an internal memory, and is used for temporarily storing the operation data in the processor 71 and the data exchanged with the external memory 722 such as a hard disk, the processor 71 exchanges data with the external memory 722 through the memory 721, and when the computer device 700 is operated, the processor 71 communicates with the memory 72 through the bus 73, so that the processor 71 executes the following instructions:
acquiring a bytecode file to be executed, which is sent by a server; wherein, the bytecode file to be executed is a bytecode file obtained after a Dart compiler in the server compiles by the code compiling method of any one of the above claims 1 to 5;
and calling a Dart virtual machine in the Flutter application, and operating the bytecode file to be executed through a Dart interpreter in the Dart virtual machine so as to realize the function corresponding to the bytecode file to be executed in the Flutter application.
The embodiments of the present disclosure also provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the steps of the code compiling and code running methods described in the above method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure also provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute steps of the code compiling and code running method in the foregoing method embodiments, which may be referred to specifically for the foregoing method embodiments, and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, but not to limit the technical solutions, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (11)

1. A code compiling method applied to a server, wherein the server includes a Dart compiler, and the method comprises:
acquiring a to-be-processed Dart code file of the Flutter application, wherein the to-be-processed Dart code file comprises a Dart code of a new function in the Flutter application, or comprises a Dart code of a to-be-repaired function in the Flutter application;
compiling the Dart code file to be processed, and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed;
and acquiring a preset byte code format, and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file.
2. The method of claim 1, wherein the obtaining a predetermined bytecode format and compiling the intermediate compilation file according to the predetermined bytecode format to obtain and store a target bytecode file, and comprising:
acquiring attribute information of each component in the intermediate compilation file; wherein the attribute information is used for indicating the byte code format matched with the corresponding component;
and compiling the intermediate compilation file based on the attribute information and the preset byte code format to obtain the target byte code file.
3. The method according to claim 2, wherein the compiling the intermediate compiled file based on the attribute information and the predetermined bytecode format to obtain the target bytecode file includes:
determining a target bytecode format matching with a corresponding component among the bytecode formats based on the attribute information;
and compiling the components according to the target byte code format to obtain the target byte code file.
4. The method according to claim 1, wherein the obtaining of the intermediate compiled file in the compiling process of the to-be-processed Dart code file comprises:
and acquiring a dynamic link library file in the compiling process of the Dart code file to be processed, and determining the dynamic link library file as the intermediate compiled file.
5. The method of claim 1, further comprising:
and after the target byte code file is stored, responding to a calling request of a user terminal to a target function corresponding to the target byte code file, and sending the target byte code file to the user terminal.
6. A code running method is applied to a Flutter application and comprises the following steps:
acquiring a bytecode file to be executed, which is sent by a server; wherein, the bytecode file to be executed is a bytecode file obtained after a Dart compiler in the server compiles by the code compiling method of any one of the above claims 1 to 5;
and calling a Dart virtual machine in the Flutter application, and operating the bytecode file to be executed through a Dart interpreter in the Dart virtual machine so as to realize the function corresponding to the bytecode file to be executed in the Flutter application.
7. The method of claim 6, wherein the executing the bytecode file to be executed by a Dart interpreter in the Dart virtual machine comprises:
analyzing the byte code file to be executed to obtain an analysis result;
extracting target byte code information from the analysis result, and loading the target byte code information in the Dart virtual machine;
and running the target bytecode information through the Dart interpreter.
8. A code compiling apparatus characterized by comprising:
the device comprises a first obtaining unit, a second obtaining unit and a third obtaining unit, wherein the first obtaining unit is used for obtaining a to-be-processed Dart code file of the Flutter application, and the to-be-processed Dart code file comprises a Dart code of a new function in the Flutter application or comprises a Dart code of a to-be-repaired function in the Flutter application;
the compiling unit is used for compiling the Dart code file to be processed and acquiring an intermediate compiled file in the compiling process of the Dart code file to be processed;
and the second acquisition unit is used for acquiring a preset byte code format and compiling the intermediate compilation file according to the preset byte code format to obtain and store a target byte code file.
9. A code-running apparatus, comprising:
the third acquisition unit is used for acquiring the byte code file to be executed sent by the server; wherein, the bytecode file to be executed is a bytecode file obtained after a Dart compiler in the server compiles by the code compiling method of any one of the above claims 1 to 5;
and the calling unit is used for calling a Dart virtual machine in the Flutter application, and running the bytecode file to be executed through a Dart interpreter in the Dart virtual machine so as to realize the function corresponding to the bytecode file to be executed in the Flutter application.
10. A computer device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when a computer device is running, the machine-readable instructions when executed by the processor performing the steps of the method of code compilation, code execution and method of any of claims 1 to 7.
11. A computer-readable storage medium, having stored thereon a computer program for executing the steps of the code compiling and code running method according to any one of claims 1 to 7 when executed by a processor.
CN202210243133.6A 2022-03-11 2022-03-11 Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium Pending CN114706586A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210243133.6A CN114706586A (en) 2022-03-11 2022-03-11 Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210243133.6A CN114706586A (en) 2022-03-11 2022-03-11 Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114706586A true CN114706586A (en) 2022-07-05

Family

ID=82169341

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210243133.6A Pending CN114706586A (en) 2022-03-11 2022-03-11 Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114706586A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023169164A1 (en) * 2022-03-10 2023-09-14 北京字节跳动网络技术有限公司 Method and apparatus for restoring application program, and computer device and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023169164A1 (en) * 2022-03-10 2023-09-14 北京字节跳动网络技术有限公司 Method and apparatus for restoring application program, and computer device and storage medium

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
CN109032631B (en) Application program patch package obtaining method and device, computer equipment and storage medium
US10459707B2 (en) Instruction-set simulator and its simulator generation method
CN106796525B (en) On-demand loading dynamic script language codes are to reduce memory use
US20190180037A1 (en) Method and system for identifying functional attributes that change the intended operation of a compiled binary extracted from a target system
KR102011725B1 (en) Whitelist construction method for analyzing malicious code, computer readable medium and device for performing the method
CN110673837B (en) Code repairing method and device, electronic equipment and computer readable storage medium
WO2021175053A1 (en) Method and apparatus for executing functional module in virtual machine
CN112612502A (en) Patch generation method, device, equipment and storage medium
CN113110865A (en) Server hot updating method and device
CN112667352A (en) Multi-CPU instruction cross compiling unified construction method, equipment and medium
CN116755713A (en) Application program generation method, device, equipment and storage medium
CN114706586A (en) Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
CN112069052A (en) Abnormal object detection method, device, equipment and storage medium
CN113703779A (en) Cross-platform multi-language compiling method and ultra-light Internet of things virtual machine
CN111352631B (en) Interface compatibility detection method and device
WO2023179298A1 (en) Application program updating method and apparatus, application program development method and apparatus, and computer device
CN115756484A (en) Pre-compiled object code warehouse determination method and device and storage medium
CN107817972B (en) Cache code processing method and device, storage medium and electronic equipment
CN114610516B (en) Application program repairing method and device, computer equipment and storage medium
CN115048082A (en) Micro front-end system construction method and device, server and readable storage medium
CN113050948B (en) Dynamic library optimization method, device, equipment and storage medium
CN114356342A (en) Compiling method and device
CN113127005A (en) Method and device for generating executable file and computer storage medium
CN111796832A (en) Hot patch file generation method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.