Transcoding method and device, electronic equipment and storage medium

By converting code on different devices into WebAssembly code, the problem of code reuse between different devices is solved, cross-device reuse of code is realized, reducing development difficulty and improving efficiency.

CN120010861APending Publication Date: 2025-05-16BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311529528.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-16
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

Due to differences in hardware and system capabilities of different types of electronic devices, codes in the same programming language are difficult to reuse on different devices, which increases the difficulty of developing the same application or function.

Method used

By determining the multiple code blocks and their types contained in the first code, the code generation method of the WebAssembly code block is determined according to the code type, and converting it into WebAssembly code, enabling it to be reused on electronic devices with different hardware and system capabilities.

Benefits of technology

It realizes the conversion of other types of codes except WebAssembly code into WebAssembly code, so that the code can be reused on different devices, reducing development difficulty, improving development efficiency, and expanding the access application of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010861A_ABST
    Figure CN120010861A_ABST
Patent Text Reader

Abstract

The invention relates to a transcoding method and device, electronic equipment and a storage medium. The transcoding method comprises the following steps: determining a plurality of first code blocks contained in a first code and code types of the first code blocks; according to the code type of the first code block, a code generation mode of a second code block in the second code is determined, and the second code block and the first code block have the same code logic; generating the second code block according to the code generation mode of the second code block; wherein the first code is a WebAssembly code, the second code is a WebAssembly code, and the first code is codes of other types except the WebAssembly code; and obtaining a second code according to the second code block. According to the transcoding method, the first code except the WebAssembly code is converted into the WebAssembly code, so that the first code can be reused on different electronic devices, the development difficulty of realizing the same application program or the same function in different types of electronic devices is reduced, the development efficiency is improved, the access application of the electronic devices can be expanded, and the user experience is improved. And applications supported by the electronic equipment are enriched.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a transcoding method, device, electronic device and storage medium. Background Art

[0002] Different types of electronic devices may have different hardware capabilities and system capabilities. For example, smartphones and smart watches have stronger computing power and greater storage capacity but poorer portability, while the latter are more portable but have poorer storage and computing capabilities. Therefore, there may be differences in the code implementation of each application or function in an electronic device. Code in the same programming language is difficult to reuse on electronic devices with different hardware capabilities and system capabilities, thereby increasing the difficulty of developing the same application or the same function in different types of electronic devices.

[0003] WebAssembly is a kind of assembly language. WebAssembly code has the characteristics of portability, small size, fast loading, high security, etc., and can be used as the compilation target of multiple high-level languages, thereby reusing a large number of programming language ecosystems. Therefore, converting other types of code into WebAssembly code can take advantage of its high efficiency, light weight, security and its rich programming language ecosystem. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the present disclosure provides a transcoding method, device, electronic device and storage medium.

[0005] According to a first aspect of an embodiment of the present disclosure, a transcoding method is provided, the method comprising:

[0006] Determine a plurality of first code blocks included in a first code and code types of the first code blocks;

[0007] Determine, according to the code type of the first code block, a code generation method of a second code block in the second code, wherein the second code block has the same code logic as the first code block; wherein the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code;

[0008] Generate the second code block according to the code generation method of the second code block;

[0009] The second code is obtained according to the second code block.

[0010] In an exemplary embodiment, determining, according to the code type of the first code block, a code generation method of the second code block in the second code includes:

[0011] According to the code type of the first code block, matching at least one code generation mode of the second code block in the first mapping relationship;

[0012] The first mapping relationship represents a mapping relationship between a code type of the first code block and at least one code generation mode of the second code block.

[0013] In an exemplary embodiment, generating the second code block according to the code generation method of the second code block includes:

[0014] Selecting a target code generation method from the at least one code generation method;

[0015] The second code block is generated according to the target code generation method.

[0016] In an exemplary embodiment, the selecting a target code generation mode in the at least one code generation mode includes:

[0017] Determine a plurality of first sub-code blocks contained in the first code block and a code type of the first sub-code block;

[0018] According to the code type of the first sub-code block, matching a code generation mode of the second sub-code block in the second code block in a second mapping relationship;

[0019] Determining the target code generation method according to the code generation method of the second sub-code block;

[0020] The second mapping relationship represents a mapping relationship between a code type of the first sub-code block and a code generation method of the second sub-code block.

[0021] In an exemplary embodiment, obtaining the second code according to the second code block includes:

[0022] According to the logical relationship between the multiple first code blocks, the multiple second code blocks are assembled to obtain the second code.

[0023] In an exemplary embodiment, the method further comprises:

[0024] Obtaining a first code block that is not commonly used in the first code;

[0025] The uncommon first code block is modified into a common first code block.

[0026] In an exemplary embodiment, the first code is a TypeScript code.

[0027] According to a second aspect of an embodiment of the present disclosure, a transcoding device is provided, the device comprising:

[0028] A first determining module is configured to determine a plurality of first code blocks included in a first code and a code type of the first code block;

[0029] A second determination module is configured to determine a code generation method of a second code block in a second code according to a code type of the first code block, wherein the second code block has the same code logic as the first code block; wherein the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code;

[0030] The generating module is configured to generate the second code block according to the code generating method of the second code block; and obtain the second code according to the second code block.

[0031] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0032] processor;

[0033] a memory for storing processor-executable instructions;

[0034] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure.

[0035] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure.

[0036] The above method disclosed in the present invention has the following beneficial effects: by converting the first code other than the WebAssembly code into the WebAssembly code, the first code can be reused on electronic devices with different hardware capabilities and system capabilities, thereby reducing the development difficulty of implementing the same application or the same function in different types of electronic devices, improving development efficiency, and being able to expand the access applications of electronic devices and enrich the applications supported by electronic devices.

[0037] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0039] Figure 1is a flow chart of a transcoding method according to an exemplary embodiment;

[0040] Figure 2 is a flow chart of a transcoding method according to an exemplary embodiment;

[0041] Figure 3 is a block diagram of a transcoding device according to an exemplary embodiment;

[0042] Figure 4 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0043] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0044] In some embodiments, the statically typed programming language TypeScript is a superset of the programming language JavaScript. Since TypeScript provides strong syntax type checking and better code hints, it can help developers find potential errors earlier when writing code and improve the readability and maintainability of the code. At the same time, it also supports the latest ECMAScript standard and provides some additional language features, such as interfaces, enumerations, generics, etc. Therefore, front-end developers usually use TypeScript to develop application interfaces. However, applications implemented using TypeScript consume more storage space and memory resources. For electronic devices with limited resources, such as embedded electronic devices, their hardware capabilities and system capabilities cannot support applications implemented by TypeScript. Therefore, in order to support the same application in electronic devices with limited resources, it is necessary to convert applications implemented using TypeScript into applications implemented using a lightweight programming language, such as converted into applications implemented using the programming language WebAssembly.

[0045] In an exemplary embodiment of the present disclosure, in order to overcome the technical problem that codes of the same programming language are difficult to reuse on electronic devices with different hardware capabilities and system capabilities existing in the related art, a transcoding method is provided, including: determining multiple first code blocks contained in a first code, determining a code generation method of a second code block in a second code according to the code type of the first code block, the second code block having the same code logic as the first code block, wherein the second code is a WebAssembly code, the first code is a type of code other than the WebAssembly code, generating a second code block according to the code generation method of the second code block, and obtaining a second code according to the second code block. The transcoding method converts the first code except the WebAssembly code into the WebAssembly code, so that the first code can be reused on electronic devices with different hardware capabilities and system capabilities, reduces the development difficulty of realizing the same application or the same function in different types of electronic devices, improves development efficiency, and can expand the access applications of electronic devices and enrich the applications supported by electronic devices.

[0046] In an exemplary embodiment of the present disclosure, a transcoding method is provided. Figure 1 is a flowchart of a transcoding method according to an exemplary embodiment. Figure 1 As shown, the following steps are included:

[0047] Step S101, determining a plurality of first code blocks and code types of the first code blocks contained in a first code;

[0048] Step S102, determining a code generation method of a second code block in the second code according to a code type of the first code block, wherein the second code block has the same code logic as the first code block; wherein the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code;

[0049] Step S103, generating a second code block according to a code generation method of the second code block;

[0050] Step S104: Obtain a second code according to the second code block.

[0051] The method in the embodiments of the present disclosure is applied to electronic devices, such as smart phones, tablets, personal computers, and other electronic devices with code processing capabilities.

[0052] In step S101, the first code is the code before transcoding, which means the code implemented in the first programming language and can be run on the first electronic device. According to the preset logical rule, the first code is parsed by the parser, and the first code is divided into a plurality of first code blocks. The preset logical rule may be a lexical rule, a grammatical rule, or a semantic rule. The first code is parsed by a lexical parser, a grammatical parser, or a semantic parser, respectively, and the first code block is obtained as a lexical unit, a grammatical unit, or a semantic unit in the first code; the preset logical rule may also be other rules that can divide the code with the same code logic in the first code into one code block.

[0053] The code type of the first code block is determined according to the common code logic of the code in the first code block. For example, when the first code block is a grammatical unit, the code type of the grammatical unit can be an integer, a string, a variable definition, a function, a function block, etc. The code type of the first code block is related to the first code. Different first codes have different code types of the first code blocks. The first code is parsed by a parser, and while the first code is divided into a plurality of first code blocks, the code type of each first code block is determined.

[0054] In step S102, the second code is the transcoded WebAssembly code, which means the code implemented using the second programming language WebAssembly, which has the characteristics of high efficiency, lightness, security and a rich programming language ecology. The first code is other types of code except WebAssembly code, so the first programming language is different from the second programming language.

[0055] In one example, the first code is TypeScript code, that is, code implemented using the programming language TypeScript, and the second code is WebAssembly code, that is, code implemented using the programming language WebAssembly. The first code consumes a lot of storage resources and can run on electronic devices with rich storage resources such as smartphones. The second code consumes less storage resources and can run on resource-constrained embedded electronic devices such as smart watches, and has a rich programming language ecosystem. Converting the first code to the second code can expand the access applications of the device and enrich the applications supported by the electronic device.

[0056] The second code block corresponds to the first code block one-to-one, and the second code block and the first code block have the same code logic. The first code blocks of different code types are converted differently when converted to the second code blocks, that is, the code generation methods of the second code blocks corresponding to the first code blocks of different code types are different. For example, the code generation method of the WebAssembly code block corresponding to the TypeScript code block with the code type of string is: generate a string WebAssembly code block with the same code logic as the TypeScript code block; the code generation method of the WebAssembly code block corresponding to the TypeScript code block with the code type of integer is: generate an integer WebAssembly code block with the same code logic as the TypeScript code block.

[0057] In step S103, after the code generation method of the second code block is obtained, the second code block can be generated according to the code generation method of the second code block, and the generated second code block has the same code logic as the first code block.

[0058] In step S104, all first code blocks in the first code are converted into second code blocks, and all second code blocks are assembled to obtain a second code, and the application or function implemented by the second code is the same as the application or function implemented by the first code.

[0059] In an exemplary embodiment of the present disclosure, by converting multiple first code blocks divided from a first code into second code blocks in a second code respectively, a technical effect of converting other types of code except WebAssembly code into WebAssembly code is achieved, thereby utilizing the efficient, lightweight, secure characteristics of WebAssembly code and a rich programming language ecosystem, so that the first code can be reused on electronic devices with different hardware capabilities and system capabilities, reducing the difficulty of developing the same application or the same function in different types of electronic devices, improving development efficiency, and being able to expand the access applications of electronic devices and enrich the applications supported by electronic devices.

[0060] In an exemplary embodiment of the present disclosure, a transcoding method is provided. Figure 2 is a flowchart of a transcoding method according to an exemplary embodiment. Figure 2 As shown, the following steps are included:

[0061] Step S201, determining a plurality of first code blocks and code types of the first code blocks contained in a first code;

[0062] Step S202, according to the code type of the first code block, matching at least one code generation method of the second code block in the first mapping relationship; wherein the first mapping relationship represents a mapping relationship between the code type of the first code block and at least one code generation method of the second code block, and the second code block has the same code logic as the first code block; the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code;

[0063] Step S203, selecting a target code generation method from at least one code generation method;

[0064] Step S204, generating a second code block according to the target code generation method;

[0065] Step S205, assembling multiple second code blocks according to the logical relationship between the multiple first code blocks to obtain a second code.

[0066] The specific implementation of step S201 refers to step S101 and will not be described in detail here.

[0067] In step S202, the code in the first code block has the same code logic, but the same code logic may also include multiple code subtypes. For example, when the code type of the first code block is a variable definition, the variables therein may be variables of different types, and different types of variables correspond to different code generation methods. Therefore, the code type of the first code block corresponds to one or more code generation methods of the second code block. The first mapping relationship represents the mapping relationship between the code type of the first code block and at least one code generation method of the second code block. For example, the first mapping relationship is a mapping relationship table, and Table 1 is an exemplary mapping relationship table. After determining the code type of the first code block, at least one code generation method of the second code block corresponding to the code type of the first code block is matched from the first mapping relationship.

[0068] Table 1

[0069] Code type of the first code block Code generation method for the second code block Type 1 Method 1 Type 2 Method 2, Method 3, Method 4 Type 3 Method 3, Method 5

[0070] In step S203, at least one code generation method of the second code block obtained in the above steps is all code generation methods of the second code block that may correspond to the code type in the first code block, but during conversion, not every code generation method is necessarily required to be used, and the code generation method to be used, i.e., the target code generation method, needs to be determined according to the actual content of the first code block. For example, as shown in Table 1, when the code type of the first code block is type 2, the code generation methods of the second code block include method 1, method 2, and method 3, but these three methods are not necessarily required to be used. If it is determined according to the actual content of the first code block that only method 1 is required, the target code generation method is method 1.

[0071] In some embodiments, the method of selecting a target code generation method from at least one code generation method comprises the following steps:

[0072] S1. Determine a plurality of first sub-code blocks contained in a first code block and a code type of the first sub-code block.

[0073] The first code block further includes a first sub-code block, and the code type of the first sub-code block is a branch of the code type of the first code block. For example, if the code type of the first sub-code block is type 1, and type 1 further includes sub-type 11 and sub-type 12, then the code type of the first sub-code block is sub-type 11 or sub-type 12. The first code block is parsed by a parser, the first code block is divided into a plurality of first sub-code blocks, and the code type of each first sub-code block is obtained.

[0074] S2: According to the code type of the first sub-code block, match the code generation mode of the second sub-code block in the second code block in the second mapping relationship.

[0075] The second mapping relationship represents the mapping relationship between the code type of the first sub-code block and the code generation method of the second sub-code block. After determining the code type of all first sub-code blocks and each first sub-code block contained in the first code block, in the second mapping relationship, the code generation method of the second sub-code block corresponding to the code type of each first sub-code block is matched in turn.

[0076] S3, determining a target code generation method according to the code generation method of the second sub-code block.

[0077] The target code generation mode represents a set of code generation modes of second sub-code blocks corresponding one-to-one to the first sub-code blocks in the first code block, that is, a set of code generation modes of all second sub-code blocks obtained in step S2.

[0078] In an example, as shown in Table 1, the code type of the first code block is type 2, the first code block contains two first sub-code blocks, and the subtypes corresponding to the two first sub-code blocks are subtype 21 and subtype 22 respectively. According to the second mapping relationship, the code generation method of the second sub-code block corresponding to subtype 21 is matched as method 2, and the code generation method of the second sub-code block corresponding to subtype 22 is method 4, then the target code generation method is method 2 and method 4.

[0079] In step S204, a second sub-code block is generated according to the target code generation method, and the second sub-code block has the same code logic as the first sub-code block. All second sub-code blocks are spliced ​​according to the logical relationship between all first sub-code blocks to generate a second code block.

[0080] In step S205, after all second code blocks corresponding to all first code blocks are obtained, multiple second code blocks are assembled according to the logical relationship between the multiple first code blocks to obtain the second code.

[0081] Among them, logical relationships include reference, parallel, selection, condition, etc., which can characterize the dependency relationship between each sub-code block or the dependency relationship between each code block. For example, code block 1 references code block 2, code block 1 and code block 3 are executed in parallel, and code block 4 and code block 5 are executed one by one.

[0082] In some embodiments, the above embodiments further include: obtaining an uncommon first code block in the first code, and modifying the uncommon first code block into a common first code block.

[0083] In order to ensure the accuracy and stability of transcoding, before dividing the first code into multiple first code blocks, an infrequently used first code block in the first code is obtained, that is, a code block with a low usage probability. Infrequently used code blocks are prone to errors during code conversion. Therefore, the infrequently used first code blocks are modified into commonly used first code blocks.

[0084] In an exemplary embodiment of the present disclosure, a transcoding device is provided. Figure 3 is a block diagram of a transcoding device according to an exemplary embodiment. Figure 3 As shown, including:

[0085] A first determining module 301 is configured to determine a plurality of first code blocks and code types of the first code blocks included in the first code;

[0086] A second determination module 302 is configured to determine a code generation method of a second code block in the second code according to a code type of the first code block, wherein the second code block has the same code logic as the first code block; wherein the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code;

[0087] The generating module 303 is configured to generate a second code block according to the code generating method of the second code block; and obtain a second code according to the second code block.

[0088] In an exemplary embodiment, the second determining module 302 is further configured to:

[0089] According to the code type of the first code block, matching at least one code generation mode of the second code block in the first mapping relationship;

[0090] The first mapping relationship represents a mapping relationship between a code type of the first code block and at least one code generation mode of the second code block.

[0091] In an exemplary embodiment, the generating module 303 is further configured to:

[0092] Selecting a target code generation method from at least one code generation method;

[0093] A second code block is generated according to the target code generation method.

[0094] In an exemplary embodiment, the generating module 303 is further configured to:

[0095] Determining a plurality of first sub-code blocks and code types of the first sub-code blocks contained in the first code block;

[0096] According to the code type of the first sub-code block, matching a code generation mode of the second sub-code block in the second code block in the second mapping relationship;

[0097] Determining a target code generation method according to a code generation method of the second sub-code block;

[0098] The second mapping relationship represents a mapping relationship between a code type of the first sub-code block and a code generation method of the second sub-code block.

[0099] In an exemplary embodiment, the generating module 303 is further configured to:

[0100] According to the logical relationship between the multiple first code blocks, the multiple second code blocks are assembled to obtain the second code.

[0101] In an exemplary embodiment, the first determining module 301 is further configured to:

[0102] Get a non-common first code block in the first code;

[0103] Modify the uncommon first code block to the common first code block.

[0104] In an exemplary embodiment, the first code is TypeScript code.

[0105] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0106] Figure 4 is a block diagram of an electronic device 400 according to an exemplary embodiment.

[0107] Reference Figure 4 , the electronic device 400 may include one or more of the following components: a processing component 402 , a memory 404 , a power component 406 , a multimedia component 408 , an audio component 410 , an input / output (I / O) interface 412 , a sensor component 414 , and a communication component 416 .

[0108] The processing component 402 generally controls the overall operation of the electronic device 400, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 402 may include one or more processors 420 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 402 may include one or more modules to facilitate the interaction between the processing component 402 and other components. For example, the processing component 402 may include a multimedia module to facilitate the interaction between the multimedia component 408 and the processing component 402.

[0109] The memory 404 is configured to store various types of data to support operations on the electronic device 400. Examples of such data include instructions for any application or method operating on the electronic device 400, contact data, phone book data, messages, pictures, videos, etc. The memory 404 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0110] The power supply component 406 provides power to the various components of the electronic device 400. The power supply component 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 400.

[0111] The multimedia component 408 includes a screen that provides an output interface between the electronic device 400 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 408 includes a front camera and / or a rear camera. When the electronic device 400 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0112] The audio component 410 is configured to output and / or input audio signals. For example, the audio component 410 includes a microphone (MIC), and when the electronic device 400 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 404 or sent via the communication component 416. In some embodiments, the audio component 410 also includes a speaker for outputting audio signals.

[0113] I / O interface 412 provides an interface between processing component 402 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0114] The sensor assembly 414 includes one or more sensors for providing various aspects of status assessment for the electronic device 400. For example, the sensor assembly 414 can detect the open / closed state of the electronic device 400, the relative positioning of the components, such as the display and keypad of the electronic device 400, and the sensor assembly 414 can also detect the position change of the electronic device 400 or a component of the electronic device 400, the presence or absence of contact between the user and the electronic device 400, the orientation or acceleration / deceleration of the electronic device 400, and the temperature change of the electronic device 400. The sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 414 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 414 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0115] The communication component 416 is configured to facilitate wired or wireless communication between the electronic device 400 and other devices. The electronic device 400 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 416 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0116] In an exemplary embodiment, the electronic device 400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0117] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 404 including instructions, and the instructions can be executed by a processor 420 of an electronic device 400 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0118] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform a transcoding method, the method including any of the above methods.

[0119] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0120] It should be understood that the present disclosure is not limited to the exact structures that have been 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 disclosure is limited only by the appended claims.

Claims

1. A transcoding method, characterized in that: The method comprises: Determine a plurality of first code blocks included in a first code and code types of the first code blocks; Determine, according to the code type of the first code block, a code generation method of a second code block in the second code, wherein the second code block has the same code logic as the first code block; wherein the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code; Generate the second code block according to the code generation method of the second code block; The second code is obtained according to the second code block.

2. The method according to claim 1, characterized in that The determining, according to the code type of the first code block, a code generation method of the second code block in the second code includes: According to the code type of the first code block, matching at least one code generation mode of the second code block in the first mapping relationship; The first mapping relationship represents a mapping relationship between a code type of the first code block and at least one code generation mode of the second code block.

3. The method according to claim 2, characterized in that The step of generating the second code block according to the code generation method of the second code block includes: Selecting a target code generation method from the at least one code generation method; The second code block is generated according to the target code generation method.

4. The method according to claim 3, characterized in that The selecting a target code generation mode in the at least one code generation mode comprises: Determine a plurality of first sub-code blocks contained in the first code block and a code type of the first sub-code block; According to the code type of the first sub-code block, matching a code generation mode of the second sub-code block in the second code block in a second mapping relationship; Determining the target code generation method according to the code generation method of the second sub-code block; The second mapping relationship represents a mapping relationship between a code type of the first sub-code block and a code generation method of the second sub-code block.

5. The method according to claim 1, characterized in that The step of obtaining the second code according to the second code block includes: According to the logical relationship between the multiple first code blocks, the multiple second code blocks are assembled to obtain the second code.

6. The method according to claim 1, characterized in that The method further comprises: Obtaining a first code block that is not commonly used in the first code; The uncommon first code block is modified into a common first code block.

7. The method according to any one of claims 1 to 6, characterized in that: The first code is a TypeScript code.

8. A transcoding device, characterized in that: The device comprises: A first determining module is configured to determine a plurality of first code blocks included in a first code and a code type of the first code block; A second determination module is configured to determine a code generation method of a second code block in a second code according to a code type of the first code block, wherein the second code block has the same code logic as the first code block; wherein the second code is a WebAssembly code, and the first code is a type of code other than the WebAssembly code; The generating module is configured to generate the second code block according to the code generating method of the second code block; and obtain the second code according to the second code block.

9. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method as claimed in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 7.