Transcoding method and apparatus, electronic device, and computer readable medium
By performing syntax transformation, variable substitution, code state maintenance and updates, and modular splitting and integration on the code, and by conducting testing, the problem of users not being able to understand the quality of the transformed code in existing technologies has been solved, thereby improving the user experience and reducing the waste of computing resources.
Patent Information
- Application Number
- CN202510439591.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-04-09
AI Technical Summary
Existing code conversion tools lack testing of the converted code when converting it from one language to another, resulting in users being unable to understand the code quality and having a poor user experience.
By performing syntax conversion, variable substitution, code status maintenance and updates, modular splitting and integration, and testing on the code files to be converted, and generating test result information, we ensure that users understand the quality of the converted code.
It improves the user experience by enabling users to understand the quality of the converted code through a detailed testing process, thereby reducing the waste of computing resources.
Smart Images

Figure CN120335817B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of computer technology, and particularly, to a code conversion method and device, electronic equipment and computer readable medium. BACKGROUND
[0002] Code conversion is a technology of converting code information in one language into code information in another language. At present, when code conversion is performed, the commonly used way is to use an automatic conversion tool to convert code from one language into another language.
[0003] However, when the above way is used to perform code conversion, the following technical problems often exist:
[0004] When code is converted from one language into another language using an automatic conversion tool, the automatic conversion tool usually only performs basic syntax and structure conversion, and lacks testing of the converted code. The code before conversion itself may have problems, so the converted code may also have errors. Since no test result of testing the converted code is generated, the user cannot understand the code quality of the converted code, resulting in a low user experience.
[0005] The above information disclosed in the background section is only intended to enhance the understanding of the background of the present inventive concept, and therefore, it can include information that does not form the prior art known to those of ordinary skill in the art. SUMMARY
[0006] The summary section is provided to introduce concepts briefly in a simplified form, which will be described in detail in the specific embodiments section. The summary section is not intended to identify key or essential features of the claimed technology nor is it intended to be used to limit the scope of the claimed technology.
[0007] Some embodiments of the present disclosure propose a code conversion method and device, electronic equipment and computer readable medium to solve one or more of the technical problems mentioned in the background section.
[0008] In a first aspect, some embodiments of the present disclosure provide a code conversion method, comprising: in response to receiving code file information to be converted sent by a client, determining a code file to be converted included in the code file information to be converted as a target code file to be converted, wherein the code file information to be converted includes the code file to be converted and a code file name to be converted, the code file to be converted is determined by a user on a preset conversion page through an interactive operation with a preset file selection control, the code file name to be converted is input information of a code file name input box displayed on the preset conversion page, the preset file selection control is displayed at a first preset position in the preset conversion page, and the code file name input box is displayed at a second preset position in the preset conversion page; determining file content included in the target code file to be converted as code information to be converted; performing syntax conversion processing on the code information to be converted to obtain initial conversion code information; performing variable replacement processing on the initial conversion code information to obtain variable conversion code information; performing code state maintenance update processing on the variable conversion code information to obtain maintenance update conversion code information; storing the maintenance update conversion code information in a preset format into a preset file to obtain a code conversion file; performing modularization splitting and integration processing on the maintenance update conversion code information to obtain each modularization conversion code information and each integrated conversion code file; performing test processing on the maintenance update conversion code information and each modularization conversion code information to obtain test result information; and sending the code conversion file corresponding to the code file name to be converted, each modularization conversion code information, each integrated conversion code file, and the test result information to the client.
[0009] In a second aspect, some embodiments of the present disclosure provide a code conversion apparatus, the apparatus comprising: a first determining unit configured to determine a target code file to be converted from code file information to be converted received from a client, wherein the code file information to be converted comprises the code file to be converted and a code file name to be converted, the code file to be converted is determined by a user on a preset conversion page through an interaction with a preset file selection control, the code file name to be converted is input information of a code file name input box displayed on the preset conversion page, the preset file selection control is displayed at a first preset position in the preset conversion page, and the code file name input box is displayed at a second preset position in the preset conversion page; a second determining unit configured to determine file content included in the target code file to be converted as code information to be converted; a syntax conversion processing unit configured to perform syntax conversion processing on the code information to be converted to obtain initial conversion code information; a variable replacement processing unit configured to perform variable replacement processing on the initial conversion code information to obtain variable conversion code information; a code state maintenance update processing unit configured to perform code state maintenance update processing on the variable conversion code information to obtain maintenance update conversion code information; a storage unit configured to store the maintenance update conversion code information in a preset format to a preset file to obtain a code conversion file; a modularization splitting and integration processing unit configured to perform modularization splitting and integration processing on the maintenance update conversion code information to obtain each modularization conversion code information and each integrated conversion code file; a test processing unit configured to perform test processing on the each modularization conversion code information to obtain test result information; and a sending unit configured to send the code conversion file corresponding to the code file name to be converted, the each modularization conversion code information, the each integrated conversion code file, and the test result information to the client.
[0010] In a third aspect, some embodiments of the present disclosure provide an electronic device, comprising: one or more processors; and a storage device having one or more programs stored thereon, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method described in any implementation manner of the first aspect.
[0011] In a fourth aspect, some embodiments of the present disclosure provide a computer readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any implementation manner of the first aspect.
[0012] The above various embodiments of the present disclosure have the following beneficial effects: through the code conversion method of some embodiments of the present disclosure, the user experience is improved. Specifically, the reason for the low user experience is that the code is converted from one language to another using an automated conversion tool, which usually only performs basic syntax and structure conversion, and lacks testing of the converted code, the pre-conversion code itself may have problems, resulting in errors in the converted code, and since no test results are generated for the converted code, the user cannot understand the code quality of the converted code, resulting in a low user experience. Based on this, the code conversion method of some embodiments of the present disclosure, first, in response to receiving the client sent code conversion file information, the above-mentioned code conversion file information includes the code conversion file and the code conversion file name, the above-mentioned code conversion file is determined as the target code conversion file, wherein the above-mentioned code conversion file is determined by the user on the preset conversion page through the interaction operation of the preset file selection control, the above-mentioned code conversion file name is the input information of the code conversion file name input box displayed on the above-mentioned preset conversion page, the above-mentioned preset file selection control is displayed in the first preset position in the above-mentioned preset conversion page, and the above-mentioned code conversion file name input box is displayed in the second preset position in the above-mentioned preset conversion page. Thus, the target code conversion file can be obtained. Then, the file content included in the target code conversion file is determined as the code conversion information. Thus, the original code, i.e., the code conversion information, can be obtained. Then, the above-mentioned code conversion information is subjected to syntax conversion processing to obtain initial conversion code information. Thus, the code conversion information can be converted from one programming language to another programming language syntax structure, and the initial conversion code information that retains the basic logic and function of the original code is obtained. Then, the above-mentioned initial conversion code information is subjected to variable replacement processing to obtain variable conversion code information. Thus, it can be ensured that the converted code conforms to the syntax of the target language. Next, the above-mentioned variable conversion code information is subjected to code state maintenance update processing to obtain maintenance update conversion code information. Thus, the code information converted to another language, i.e., the maintenance update conversion code information, can be obtained. Then, the above-mentioned maintenance update conversion code information is stored in a preset file in a preset storage format to obtain a code conversion file. Thus, the code conversion file storing the maintenance update conversion code information converted to another language can be obtained. The above-mentioned maintenance update conversion code information is subjected to modularization splitting and integration processing to obtain each modularized conversion code information and each integrated conversion code file. Thus, the maintenance update conversion code information can be split and integrated to obtain each modularized conversion code information for testing processing. Then, the above-mentioned each modularized conversion code information is subjected to testing processing to obtain test result information.Thus, each modularized conversion code information can be tested. Finally, the above code conversion file, each modularized conversion code information, each integrated conversion code file and the test result information are sent to the client. Thus, the test result information representing the quality of the converted code can be sent to the client while sending the code conversion file, each modularized conversion code information and each integrated conversion code file, so that the user can understand the quality of the converted code and the user experience is improved. BRIEF DESCRIPTION OF DRAWINGS
[0013] The above and other features, aspects and advantages of the present disclosure will become more apparent by reference to the following detailed description taken in conjunction with the accompanying drawings. In the drawings, like reference numerals refer to like elements throughout. It is to be understood that the drawings are schematic and elements and features are not necessarily to scale.
[0014] Figure 1 is a flowchart of some embodiments of a code conversion method according to the present disclosure;
[0015] Figure 2 is a structural schematic diagram of some embodiments of a code conversion apparatus according to the present disclosure;
[0016] Figure 3 is a structural schematic diagram of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION
[0017] Embodiments of the present disclosure will be described in more detail with reference to the drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms, and should not be interpreted as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes, and are not intended to limit the scope of protection of the present disclosure.
[0018] It should also be noted that, for ease of description, only the parts related to the present application are shown in the drawings. The embodiments in the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0019] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not intended to limit the order or interdependence of the functions performed by these devices, modules or units.
[0020] It should be noted that the modification of "one", "multiple" mentioned in the present disclosure is illustrative but not restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".
[0021] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0022] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0023] Figure 1 Flow 100 of some embodiments of the code conversion method according to the present disclosure is shown. The code conversion method includes the following steps:
[0024] Step 101, in response to receiving the code file information to be converted sent by the client, determining the code file to be converted included in the code file information to be converted as the target code file to be converted.
[0025] In some embodiments, the execution subject (e.g., a computing device) of the code conversion method can determine the to-be-converted code file included in the to-be-converted code file information received by the client as a target to-be-converted code file in response to receiving the to-be-converted code file information sent by the client, wherein the to-be-converted code file information includes the to-be-converted code file and a to-be-converted code file name. The to-be-converted code file is determined by the user on a preset conversion page through an interaction operation with a preset file selection control, the to-be-converted code file name is input information of a to-be-converted code file name input box displayed on the preset conversion page, the preset file selection control is displayed at a first preset position in the preset conversion page, and the to-be-converted code file name input box is displayed at a second preset position in the preset conversion page. The preset conversion page can be a page for converting programming code in Magnum format (e.g., C language code or C++ language code) into programming code in Python format. The preset file selection control can be a page element for selecting a to-be-converted code file. The to-be-converted code file name input box can be an input box for inputting a to-be-converted code file name. The first preset position can be a position where the preset file selection control is displayed on the preset conversion page. The second preset position can be a position where the to-be-converted code file name input box is displayed on the preset conversion page. The client can be a client device (e.g., a computer, a mobile phone, a tablet computer, etc.) used by a development user. The execution subject can be a computing device for converting programming code in Magnum format (e.g., C++ code) into programming code in Python format. The programming code in Magnum format can be code (e.g., C language code or C++ language code) written using a Magnum framework or engine. The to-be-converted code file can be a file storing programming code in Magnum format. The to-be-converted code file name can be the file name of the to-be-converted code file.
[0026] In step 102, the file content included in the target to-be-converted code file is determined as to-be-converted code information.
[0027] In some embodiments, the execution subject can determine the file content included in the target to-be-converted code file as to-be-converted code information.
[0028] In step 103, the to-be-converted code information is subjected to syntax conversion processing to obtain initial conversion code information.
[0029] In some embodiments, the execution subject can subject the to-be-converted code information to syntax conversion processing to obtain initial conversion code information.
[0030] In some optional implementations of some embodiments, the execution subject can perform syntax conversion on the to-be-converted code information to obtain initial converted code information by the following steps:
[0031] Firstly, the to-be-converted code information is processed by line segmentation to obtain a sequence of to-be-converted line code information. In practice, the execution subject can divide the to-be-converted code information by lines by using text processing technology to obtain the sequence of to-be-converted line code information. Each to-be-converted line code information in the sequence of to-be-converted line code information can represent a line of code.
[0032] Secondly, each indentation information of each to-be-converted line code information in the sequence of to-be-converted line code information is recorded. In practice, the execution subject can record each indentation information of each to-be-converted line code information in the to-be-converted code information by using a text editor. Each indentation information in the sequence of to-be-converted line code information can represent the indentation of the line of code corresponding to the to-be-converted line code information. For example, the to-be-converted code information can be "#include<stdio.h> printf("Hello,World!\n");", the to-be-converted line code information can be "#include<stdio.h>", and the indentation information of "#include<stdio.h>" can be "0 space indentation".
[0033]
[0034]
[0035] Thirdly, the sequence of to-be-converted line code information is updated by performing line-by-line keyword replacement on the sequence of to-be-converted line code information.
[0036] Fourthly, the to-be-converted line code information in the updated sequence of to-be-converted line code information is spliced based on the indentation information to obtain the initial converted code information. In practice, the execution subject can arrange the to-be-converted line code information in the sequence of to-be-converted line code information by lines in order. Then, for each line of to-be-converted line code information arranged, the execution subject can indent according to the indentation information corresponding to the to-be-converted line code information in the sequence of indentation information. Finally, the execution subject can splice the indented to-be-converted line code information by lines to obtain the initial converted code information.
[0037] In some optional implementations of some embodiments, the execution subject can update the sequence of to-be-converted line code information by performing line-by-line keyword replacement on the sequence of to-be-converted line code information by the following steps:
[0038] In a first step, for each to-be-converted line code information in the to-be-converted line code information sequence, the following update processing is performed:
[0039] In a first sub-step, string segmentation processing is performed on the to-be-converted line code information to obtain a to-be-recognized string sequence. In practice, the execution subject can perform string segmentation processing on the to-be-converted line code information by using a preset segmentation function (for example, a split() function) to obtain the to-be-recognized string sequence. For example, the to-be-recognized string sequence can be [“IF”, “Bill”, “Not”, “=”, “UNKNOWW”].
[0040] In a second sub-step, identification processing is performed on the to-be-recognized string sequence to obtain each to-be-replaced string. In practice, the execution subject can perform identification processing on the to-be-recognized string sequence by using a regular expression (Regex) or a simple string matching technique to obtain each to-be-replaced string. For example, each to-be-replaced string can be ““IF”, “Bill”, “Not”, “UNKNOWW””.
[0041] In a third sub-step, based on a preset string mapping relationship table, each to-be-replaced string included in the to-be-converted line code information is replaced to update the to-be-converted line code information. The preset string mapping relationship table can include each string mapping relationship information. Each string mapping relationship information includes a source string and a target string. In practice, for each to-be-replaced string in the to-be-converted line code information, the execution subject can determine, as a target string mapping relationship information, a string mapping relationship information in which the source string is the same as the to-be-replaced string in the to-be-converted line code information. Then, the execution subject can determine, as a replacement string, a target string included in the target string mapping relationship information. Then, the execution subject can replace the to-be-replaced string included in the to-be-converted line code information with the replacement string to update the to-be-converted line code information.
[0042] In step 104, variable replacement processing is performed on the initial converted code information to obtain variable converted code information.
[0043] In some embodiments, the execution subject can perform variable replacement processing on the initial converted code information to obtain variable converted code information.
[0044] In some optional implementations of some embodiments, the execution subject can perform variable replacement processing on the initial converted code information to obtain variable converted code information by the following steps:
[0045] In a first step, the initial conversion code information is subjected to a naming standard conversion process to obtain initial variable conversion code information. In practice, first, the execution subject can match variable names containing a preset prefix from the initial conversion code information through a regular expression to obtain each matching variable name. Then, the execution subject can change the prefix of each matching variable name to a preset changed prefix to obtain each updated variable name. Subsequently, for each updated variable name in the updated variable names, the execution subject can replace the updated variable name with a corresponding variable in the initial conversion code information. For example, the preset prefix can be “mg_”. The preset changed prefix can be “py_”.
[0046] In a second step, the initial variable conversion code information is subjected to a preset variable replacement process to obtain variable conversion code information. In practice, the execution subject can identify each specified variable in the variable conversion code information through a regular expression or a string matching technique. Then, for each specified variable in the specified variables existing in the variable conversion code information, the execution subject can query a preset variable corresponding to the specified variable from a preset relationship table. Subsequently, the execution subject can replace the specified variable in the variable conversion code information with the preset variable to update the variable conversion code information. Finally, the execution subject can determine the updated variable conversion code information as the variable conversion code information. Among them, the specified variable in the specified variables can be a preset type variable or a keyword of a preset control flow statement (or loop structure). For example, the specified variables can be “int32(10), foreach, forever”. The preset variable corresponding to the specified variable “int32(10)” can be “int(10)”. The preset variable corresponding to the specified variable “foreach” can be “for”. The preset variable corresponding to the specified variable “forever” can be “while”.
[0047] In step 105, the variable conversion code information is subjected to a code state maintenance update process to obtain maintenance update conversion code information.
[0048] In some embodiments, the execution subject can subject the variable conversion code information to a code state maintenance update process to obtain maintenance update conversion code information.
[0049] In some optional implementations of some embodiments, the execution subject can subject the variable conversion code information to a code state maintenance update process to obtain maintenance update conversion code information by the following steps:
[0050] The first step is to perform the following update steps for each of the preset global variables included in the above-mentioned maintenance and update transformation code information:
[0051] The first sub-step involves copying the initial value of the aforementioned global variable to a preset temporary variable at the first preset position of the loop function corresponding to the preset global variable in the maintenance and update conversion code information.
[0052] The second sub-step involves assigning the initial value back to the preset global variable at the second preset position after the loop function corresponding to the preset global variable that maintains and updates the conversion code information ends.
[0053] The second step is to determine the maintenance update conversion code information after each preset global variable is updated.
[0054] As an example, variable conversion code information can be:
[0055] life_list = [1,2,3,4]
[0056] history_list=[
[0057] for iin range(len(life_list)):
[0058] history_list.append(life_list[i]*2) # Adds the value *2 to history_list
[0059] life_list[i] = life_list[i] * 3 # Store the value multiplied by 3 back into life_list
[0060] "
[0061] The maintenance and update conversion code information can be:
[0062] "life_list=[1,2,3,4]"
[0063] history_list=[
[0064] for iin range(len(life_list)):
[0065] temp_history = life_list[i] * 2 # Temporarily store the result of * 2 in a temporary variable
[0066] temp_life = life_list[i] * 3 # Temporarily store the result of *3
[0067] After the loop ends, the value is assigned back to the corresponding global variable
[0068] history_list.append(temp_history) # add the result of *2 to history_list
[0069] life_list[i] = temp_life # store the result of *3 back to life_list
[0070] In step 106, the maintenance update conversion code information is converted and stored in a preset format to a preset file to obtain a code conversion file.
[0071] In some embodiments, the above-mentioned execution subject can store the above-mentioned maintenance update conversion code information in a preset format to a preset file to obtain a code conversion file. Wherein, the above-mentioned preset format can be "taking ".py" as the file extension of the maintenance update conversion code information".
[0072] In step 107, the maintenance update conversion code information is modularized and integrated to obtain each modularized conversion code information and each integrated conversion code file.
[0073] In some embodiments, the above-mentioned execution subject can modularize and integrate the above-mentioned maintenance update conversion code information to obtain each modularized conversion code information and each integrated conversion code file.
[0074] In some optional implementations of some embodiments, the above-mentioned execution subject can modularize and integrate the above-mentioned maintenance update conversion code information to obtain each modularized conversion code information and each integrated conversion code file by the following steps:
[0075] First, identify each division identification information table in the above-mentioned maintenance update conversion code information. In practice, the above-mentioned execution subject can identify each division identification information in the maintenance update conversion code information through a preset compiler or interpreter. Wherein, the above-mentioned each division identification information can identify the start and end marks of the function in the maintenance update conversion code information.
[0076] Second, based on the above-mentioned division identification information, the above-mentioned maintenance update conversion code information is divided to obtain each modularized conversion code information. Each modularized conversion code information in the above-mentioned each modularized conversion code information can be a code corresponding to a function in the maintenance update conversion code information. As an example, the above-mentioned maintenance update conversion code information can be:
[0077]
[0078]
[0079] In the third step, for each of the modularized transformation code information, the modularized transformation code information is subjected to rule name recognition processing to obtain rule name information. In practice, the execution subject can extract the information within the square brackets in the modularized transformation code information as the rule name information by using the regular expression technique. As an example, the rule name can be "life_rule1".
[0080] In the fourth step, the rule name information is subjected to clustering processing to obtain rule name information clusters. In practice, first, the execution subject can convert each of the rule name information into a corresponding rule name information vector by using the bag-of-words model. Each of the rule name information vectors can be a vector representing the rule name information. Each of the rule name information corresponds to a corresponding rule name information vector among the rule name information vectors. Next, the execution subject can cluster the rule name information vectors by using a preset clustering algorithm (e.g., the K-means clustering algorithm) to obtain rule name information vector clusters. Then, for each of the rule name information vector clusters, the execution subject can determine at least one rule name information corresponding to at least one rule name information vector included in the rule name information vector cluster as at least one target rule name information. Then, the execution subject can determine the at least one target rule name information as a rule name information cluster corresponding to the rule name information vector cluster. Optionally, the execution subject can determine the prefix of each of the rule name information. Then, the execution subject can divide at least one rule name information having the same prefix among the rule name information into a rule name information cluster to obtain rule name information clusters. As an example, the rule name information can be "RuleA1_item1, RuleA1_item2, RuleA2_item1, RuleB1_item1, RuleB1_item2, RuleB1_item3, RuleC1_item1". The rule name information clusters can be "Cluster 1: {RuleA1_item1, RuleA1_item2}", the corresponding prefix is RuleA1, "Cluster 2: {RuleA2_item1}", the corresponding prefix is RuleA2, "Cluster 3: {RuleB1_item1, RuleB1_item2, RuleB1_item3}", the corresponding prefix is RuleB1, and "Cluster 4: {RuleC1_item1}", the corresponding prefix is RuleC1.
[0081] In the fifth step, for each of the rule name information clusters, the following steps are performed:
[0082] In the first sub-step, at least one of the modularized conversion code information corresponding to at least one of the rule name information clusters is determined as at least one target modularized conversion code information.
[0083] In the second sub-step, the at least one target modularized conversion code information is saved to a preset file to obtain an integrated conversion code file.
[0084] In step 108, the maintenance update conversion code information and each of the modularized conversion code information are tested to obtain test result information.
[0085] In some embodiments, the execution subject can test the maintenance update conversion code information and each of the modularized conversion code information to obtain test result information. In practice, the execution subject can use a static analysis tool (such as pylint, flake8, etc.) to check the maintenance update conversion code information and each of the modularized conversion code information for potential problems to obtain test result information.
[0086] In the process of using the technical solutions to solve the problems mentioned in the background, the following problems often occur:
[0087] When testing the converted maintenance update conversion code information and each of the modularized conversion code information, the commonly used method is to directly use a static analysis tool to test the maintenance update conversion code information and each of the modularized conversion code information. However, the static analysis tool mainly focuses on the structure and syntax of the code, and it is difficult to detect runtime errors of the code, so the accuracy of the test is low, which leads to the consumption of more computing resources in the subsequent development and testing process of the converted code. Moreover, the static analysis tool can only estimate the possible problem areas according to the static structure of the code, but it cannot determine which code paths are not executed in actual operation, cannot locate the code that is not tested, cannot guide the client user to perfect the test case, and leads to a low experience of the client user.
[0088] In the face of the above technical problems, the inventors decided to use the following solutions:
[0089] In some optional implementations of some embodiments, the execution subject can test the maintenance update conversion code information and each of the modularized conversion code information to obtain test result information by the following steps:
[0090] In a first step, for each modularized transformation code information among the above modularized transformation code information, the following module test step is performed:
[0091] In a sub-step one, the above modularized transformation code information is parsed to obtain modularized transformation code parsed information, wherein the modularized transformation code parsed information comprises function name information, parameter information and control flow information. In practice, the execution subject can parse the modularized transformation code information by using a static code analysis technology to obtain the modularized transformation code parsed information. For example, the function name information can be “max_value”. The parameter information can be “a (type: int), b (type: int), return value type: int”. The control flow information can be “contains an if-else branch condition (a > b)”.
[0092] In a sub-step two, based on the above modularized transformation code parsed information, each test data among the test data is generated, wherein each test data among the test data comprises input test data and expected test data. In practice, the execution subject can generate each test data by using a preset test tool (for example, a Faker test data generation tool) and the modularized transformation code parsed information. For example, the test data can be “input test data: a = 10, b = 20, expected test data: 20”.
[0093] In a sub-step three, based on the above each test data, each test case information corresponding to the above modularized transformation code information is generated. In practice, the execution subject can generate each test case information by using a test case automatic generation technology based on each test data and the modularized transformation code parsed information. One test case information among the each test case information can represent one test case. For example, the test case can be represented as “input data: a = 10, b = 20; expected output: 20; test step: call the max_value(a, b) function, wherein a and b are values in the input data. Check whether the return value is equal to the expected output. Test result judgment: if the return value is equal to the expected output (20), the test passes. If the return value is not equal to the expected output (20), the test fails”.
[0094] Sub-step four, based on the above-mentioned various test case information, generate various module test result information. In practice, the above-mentioned execution subject can execute various test cases corresponding to various test case information to generate various module test result information. Each test result information in the above-mentioned various module test result information can represent the result obtained after executing the test case. The above-mentioned test result information can be represented by a Boolean value. For example, True (or 1) generally represents that the test passes, while False (or 0) represents that the test fails.
[0095] Sub-step five, in response to determining that the above-mentioned various module test result information all represent that the test passes, determining the information representing that the test passes as the module test information corresponding to the above-mentioned modular conversion code information.
[0096] Sub-step six, in response to determining that there is a module test result information in the above-mentioned various module test result information representing that the test fails, determining the information representing that the test fails as the module test information corresponding to the above-mentioned modular conversion code information.
[0097] Second step, obtain preset code file test case information corresponding to the above-mentioned to-be-converted code file information. In practice, the above-mentioned execution subject can obtain preset code file test case information corresponding to the above-mentioned to-be-converted code file information from a preset test case library. The above-mentioned preset code file test case information can represent a test case for testing a to-be-converted code file included in the to-be-converted code file information.
[0098] Third step, adjust the above-mentioned preset code file test case information to obtain update conversion code test case information corresponding to the above-mentioned maintenance update conversion code information. In practice, the above-mentioned execution subject can use test case migration technology (for example, use an AST conversion tool) to adjust the preset code file test case information to update conversion code test case information for testing maintenance update conversion code information under a preset language. The above-mentioned update conversion code test case information can represent a test case for testing code corresponding to the maintenance update conversion code information.
[0099] Fourth step, execute the following test steps on the above-mentioned maintenance update conversion code information:
[0100] Sub-step one, add probe code to each line of code in the above-mentioned maintenance update conversion code information to update the maintenance update conversion code information. The above-mentioned probe code can be a code segment for recording the execution of the code.
[0101] Sub-step two, determine the updated maintenance update conversion code information as the instrumented conversion code information.
[0102] Sub-step three, execute the update conversion code test case corresponding to the update conversion code test case information to test the patched conversion code information, and obtain test information and at least one probe execution information corresponding to at least one patch conversion code in the above-mentioned patched conversion code information. Wherein each probe execution information in the at least one probe execution information can be but not limited to at least one of the following: whether the probe code is triggered, the number of times the probe code is triggered.
[0103] Sub-step four, determine at least one line of code in the above-mentioned maintenance update conversion code information which does not have corresponding probe execution information as test uncovered code information.
[0104] Sub-step five, determine the above-mentioned test information and the above-mentioned test uncovered code information as maintenance update conversion code test information corresponding to the above-mentioned maintenance update conversion code information.
[0105] Fifth step, determine the module test information and the maintenance update conversion code test information as test result information.
[0106] The technical solution and related content thereof serve as one inventive point of the embodiments of the present disclosure, and solve the technical problem of wasted computing resource and low user experience. Factors leading to wasted computing resource and low user experience are often as follows: directly using a static analysis tool to test the maintenance update conversion code information and the various modular conversion code information, however, the static analysis tool mainly focuses on the structure and syntax of the code, and is difficult to detect code runtime errors, so the accuracy of the test is low, and the converted code consumes more computing resources in the subsequent development and testing process. Moreover, the static analysis tool can only estimate the possible problem area according to the static structure of the code, and cannot determine which code paths are not executed in actual operation, cannot locate the code that is not tested, cannot guide the client user to perfect the test case, and leads to low user experience. If the above factors are solved, the effect of reducing the waste of computing resources and improving the user experience can be achieved. In order to achieve this effect, first, for each modular conversion code information in the various modular conversion code information, the following module test steps are performed: a first sub-step of performing parsing processing on the modular conversion code information to obtain modular conversion code parsing information, wherein the modular conversion code parsing information includes function name information, parameter information and control flow information. Thus, the modular conversion code parsing information for generating each test data can be obtained. A second sub-step of generating each test data based on the modular conversion code parsing information, wherein each test data in the test data includes input test data and expected test data. A third sub-step of generating each test case information corresponding to the modular conversion code information based on the test data. Thus, each test case information for testing the modular conversion code information can be generated. A fourth sub-step of generating each module test result information based on the test case information. A fifth sub-step of determining information representing test passing as module test information corresponding to the modular conversion code information in response to determining that the module test result information represents test passing. Thus, in the case that each module test result information represents test passing, the information representing test passing can be determined as the module test information corresponding to the modular conversion code information. A sixth sub-step of determining information representing test failure as module test information corresponding to the modular conversion code information in response to determining that at least one module test result information in the module test result information represents test failure. Thus, in the case that at least one module test result information in the module test result information represents test failure, the information representing test failure can be determined as the module test information corresponding to the modular conversion code information.Thus, the above module test steps can be used to dynamically run test the codes corresponding to each modularized conversion code information, so that runtime errors and performance problems that may be missed by static analysis tools can be found, thereby improving the accuracy of the test. Then, preset code file test case information corresponding to the above to-be-converted code file information is obtained. Thus, preset code file test case information for testing the to-be-converted code file information before conversion can be obtained. After that, the above preset code file test case information is adjusted to obtain update conversion code test case information corresponding to the above maintenance and update conversion code information. Thus, update conversion code test case information for testing the maintenance and update conversion code information can be obtained. Then, the following test steps are performed on the above maintenance and update conversion code information: a first sub-step, adding probe code to each line of code in the above maintenance and update conversion code information to update the maintenance and update conversion code information. A second sub-step, determining the updated maintenance and update conversion code information as the instrumented conversion code information. A third sub-step, executing the update conversion code test case corresponding to the above update conversion code test case information to test the instrumented conversion code information, obtaining test information and at least one probe execution information corresponding to at least one instrumented conversion code in the above instrumented conversion code information. A fourth sub-step, determining at least one line of code in the above maintenance and update conversion code information that does not have corresponding probe execution information as test uncovered code information. A fifth sub-step, determining the above test information and the above test uncovered code information as maintenance and update conversion code test information corresponding to the above maintenance and update conversion code information. A sixth sub-step, determining the obtained each module test information and maintenance and update conversion code test information as test result information. Thus, the above test steps can be used to dynamically and integrally test the maintenance and update conversion code information based on the update conversion code test case information, and obtain test information. In the testing process, the test uncovered code information (i.e., the code that is not tested) is located through the added probe code. Also, the module test steps can be used to dynamically run test the codes corresponding to each modularized conversion code information, so that runtime errors and performance problems that may be missed by static analysis tools can be found, thereby improving the accuracy of the test, avoiding the consumption of more computing resources in the subsequent development and testing process of the converted code, and reducing the waste of computing resources. The update conversion code test case information is used to dynamically and integrally test the maintenance and update conversion code information, and obtain test information and test uncovered code information, which helps to guide the client user to improve the test case of the uncovered code and improve the user experience.
[0107] In step 109, the code conversion file corresponding to the to-be-converted code file name, each modularized conversion code information, each integrated conversion code file, and test result information are sent to the client.
[0108] In some embodiments, the execution subject can send the code conversion file corresponding to the code file name to be converted, the various modular conversion code information, the various integrated conversion code files, and the test result information to the client.
[0109] The above various embodiments of the present disclosure have the following beneficial effects: through the code conversion method of some embodiments of the present disclosure, the user experience is improved. Specifically, the reason for the low user experience is that the code is converted from one language to another using an automated conversion tool, which usually only performs basic syntax and structure conversion, and lacks testing of the converted code, the pre-conversion code itself may have problems, resulting in errors in the converted code, and since no test results are generated for the converted code, the user cannot understand the code quality of the converted code, resulting in a low user experience. Based on this, the code conversion method of some embodiments of the present disclosure, first, in response to receiving the client sent code conversion file information, the above-mentioned code conversion file information includes the code conversion file and the code conversion file name, the above-mentioned code conversion file is determined as the target code conversion file, wherein the above-mentioned code conversion file is determined by the user on the preset conversion page through the interaction operation of the preset file selection control, the above-mentioned code conversion file name is the input information of the code conversion file name input box displayed on the above-mentioned preset conversion page, the above-mentioned preset file selection control is displayed in the first preset position in the above-mentioned preset conversion page, and the above-mentioned code conversion file name input box is displayed in the second preset position in the above-mentioned preset conversion page. Thus, the target code conversion file can be obtained. Then, the file content included in the target code conversion file is determined as the code conversion information. Thus, the original code, i.e., the code conversion information, can be obtained. Then, the above-mentioned code conversion information is subjected to syntax conversion processing to obtain initial conversion code information. Thus, the code conversion information can be converted from one programming language to another programming language syntax structure, and the initial conversion code information that retains the basic logic and function of the original code is obtained. Then, the above-mentioned initial conversion code information is subjected to variable replacement processing to obtain variable conversion code information. Thus, it can be ensured that the converted code conforms to the syntax of the target language. Next, the above-mentioned variable conversion code information is subjected to code state maintenance update processing to obtain maintenance update conversion code information. Thus, the code information converted to another language, i.e., the maintenance update conversion code information, can be obtained. Then, the above-mentioned maintenance update conversion code information is stored in a preset file in a preset storage format to obtain a code conversion file. Thus, the code conversion file storing the maintenance update conversion code information converted to another language can be obtained. The above-mentioned maintenance update conversion code information is subjected to modularization splitting and integration processing to obtain each modularized conversion code information and each integrated conversion code file. Thus, the maintenance update conversion code information can be split and integrated to obtain each modularized conversion code information for testing processing. Then, the above-mentioned maintenance update conversion code information and the above-mentioned each modularized conversion code information are subjected to testing processing to obtain test result information.Thus, each modularized conversion code information can be tested. Finally, the code conversion file corresponding to the above-mentioned to-be-converted code file name, the above-mentioned each modularized conversion code information, the above-mentioned each integrated conversion code file and the above-mentioned test result information are sent to the above-mentioned client. Thus, the test result information representing the quality of the converted code can be sent to the client at the same time as the code conversion file, the above-mentioned each modularized conversion code information and the above-mentioned each integrated conversion code file are sent, so that the user can understand the code quality of the converted code, and the user experience is improved.
[0110] Further referring to Figure 2 , as an implementation of the method shown in each figure, the disclosure provides some embodiments of a code conversion device, which device embodiments correspond to those method embodiments shown, and the device can be specifically applied in various electronic devices. Figure 1
[0111] As Figure 2 As shown, the transcoding apparatus 200 of some embodiments includes a first determining unit 201, a second determining unit 202, a syntax conversion processing unit 203, a variable replacement processing unit 204, a code state maintenance updating processing unit 205, a storage unit 206, a modularization splitting and integrating processing unit 207, a testing processing unit 208, and a sending unit 209. The first determining unit 201 is configured to determine a target transcoding code file from a transcoding code file information received from a client, the transcoding code file information including the transcoding code file and a transcoding code file name, the transcoding code file being determined by a user on a preset conversion page through an interaction with a preset file selection control, the transcoding code file name being input information of a transcoding code file name input box displayed on the preset conversion page, the preset file selection control being displayed at a first preset position in the preset conversion page, and the transcoding code file name input box being displayed at a second preset position in the preset conversion page. The second determining unit 202 is configured to determine file content included in the target transcoding code file as transcoding code information. The syntax conversion processing unit 203 is configured to perform syntax conversion processing on the transcoding code information to obtain initial transcoding code information. The variable replacement processing unit 204 is configured to perform variable replacement processing on the initial transcoding code information to obtain variable transcoding code information. The code state maintenance updating processing unit 205 is configured to perform code state maintenance updating processing on the variable transcoding code information to obtain maintenance updating transcoding code information. The storage unit 206 is configured to store the maintenance updating transcoding code information in a preset storage format to a preset file to obtain a transcoding file. The modularization splitting and integrating processing unit 207 is configured to perform modularization splitting and integrating processing on the maintenance updating transcoding code information to obtain each modularized transcoding code information and each integrated transcoding code file. The testing processing unit 208 is configured to perform testing processing on the maintenance updating transcoding code information and each modularized transcoding code information to obtain testing result information. The sending unit 209 is configured to send the transcoding file, each modularized transcoding code information, each integrated transcoding code file, and the testing result information to the client.
[0112] It can be understood that the units described in the apparatus 200 correspond to the steps in the method described above. Therefore, the operations, features, and advantages described above for the method also apply to the apparatus 200 and the units included therein, which will not be described again. Figure 1
[0113] The following will be described with reference to the drawings. Figure 3 It shows a schematic diagram of the structure of an electronic device 300 suitable for implementing some embodiments of the present disclosure. Figure 3 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0114] like Figure 3 As shown, the electronic device 300 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the electronic device 300. The processing unit 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0115] Typically, the following devices can be connected to I / O interface 305: input devices 306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 307 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 308 including, for example, magnetic tapes, hard disks, etc.; and communication devices 309. Communication device 309 allows electronic device 300 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 3 An electronic device 300 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 3 Each box shown can represent a device or multiple devices as needed.
[0116] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 309, or installed from storage device 308, or installed from ROM 302. When the computer program is executed by processing device 301, it performs the functions defined in the methods of some embodiments of this disclosure.
[0117] Note that the computer-readable medium in some embodiments of the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium may, for example and without limitation, be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In some embodiments of the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In some embodiments of the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is contained. Such a propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that is not a storage medium and that can communicate, propagate, or transport program for use by or in connection with an instruction execution system, apparatus, or device. Program code contained in the computer-readable medium can be transmitted using any suitable medium, including but not limited to wire, cable, RF, etc., or any suitable combination of the foregoing.
[0118] In some embodiments, the client, server, or both can communicate using any current known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.
[0119] The computer readable medium can be included in the electronic device or exist separately from the electronic device. The computer readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: determine a target code file to be converted as a code file to be converted included in code file information to be converted in response to receiving the code file information to be converted sent by a client, wherein the code file information to be converted includes the code file to be converted and a code file name to be converted, the code file to be converted being determined by a user on a preset conversion page through an interaction operation with a preset file selection control, the code file name to be converted being input information of a code file name input box displayed on the preset conversion page, the preset file selection control being displayed at a first preset position in the preset conversion page, and the code file name input box being displayed at a second preset position in the preset conversion page; determine file content included in the target code file to be converted as code information to be converted; perform syntax conversion processing on the code information to be converted to obtain initial conversion code information; perform variable replacement processing on the initial conversion code information to obtain variable conversion code information; perform code state maintenance update processing on the variable conversion code information to obtain maintenance update conversion code information; store the maintenance update conversion code information in a preset format to a preset file to obtain a code conversion file; perform modularization splitting and integration processing on the maintenance update conversion code information to obtain each modularized conversion code information and each integrated conversion code file; perform testing processing on the maintenance update conversion code information and the each modularized conversion code information to obtain testing result information; and send the code conversion file corresponding to the code file name to be converted, the each modularized conversion code information, the each integrated conversion code file, and the testing result information to the client.
[0120] Computer program code for carrying out operations of some embodiments of the disclosure can be written in one or more programming languages or combinations of languages including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages such as "C" or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0121] The computer program product of the first aspect can further include one or more of the following features. The computer program product can further include a second determining unit configured to determine a file content included in the target code file to be converted as the code information to be converted. The computer program product can further include a syntax conversion processing unit configured to convert the code information to be converted into the target code information. The computer program product can further include a variable replacement processing unit configured to replace a variable in the target code information with a value of the variable. The computer program product can further include a code state maintenance updating processing unit configured to update a code state of the target code information. The computer program product can further include a storage unit configured to store the target code information. The computer program product can further include a modularization splitting and integration processing unit configured to split the target code information into a plurality of code modules, and integrate the plurality of code modules into a target code file. The computer program product can further include a test processing unit configured to test the target code information. The computer program product can further include a sending unit configured to send the target code information.
[0122] The units described in some embodiments of the present disclosure can be implemented in software or hardware. The described units can also be arranged in a processor, for example, a processor can be described as including a first determining unit, a second determining unit, a syntax conversion processing unit, a variable replacement processing unit, a code state maintenance updating processing unit, a storage unit, a modularization splitting and integration processing unit, a test processing unit, and a sending unit. In some cases, the names of these units do not constitute a limitation on the units themselves, for example, the second determining unit can also be described as a unit that determines a file content included in a target code file to be converted as code information to be converted.
[0123] The functions described above in the specification can be implemented in part or in whole in one or more hardware logic components. For example, and without limitation, non-limiting examples of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Application-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0124] The above description is merely exemplary of the disclosure and the application of the principles thereof. It is not intended to limit the scope of the application to the specific forms described. Rather, the application is intended to cover any and all modifications and variations within the scope of the area comprising the areas presented herein. For example, it is anticipated that alternative embodiments of the present disclosure will be developed and that the foregoing embodiments are presented by way of example only. Therefore, it is the following claims including any amendments thereto that define the scope of the application.
Claims
1. A code conversion method, comprising: In response to receiving the code file information to be converted sent by the client, the code file to be converted included in the code file information to be converted is determined as the target code file to be converted. The code file information to be converted includes the code file to be converted and the code file name to be converted. The code file to be converted is determined by the user through interactive operation with the preset file selection control on the preset conversion page. The code file name to be converted is the input information of the code file name input box displayed on the preset conversion page. The preset file selection control is displayed in a first preset position on the preset conversion page, and the code file name input box to be converted is displayed in a second preset position on the preset conversion page. The file contents included in the target code file to be converted are identified as the code information to be converted; The code information to be converted is subjected to syntax conversion processing to obtain initial converted code information; The initial conversion code information is subjected to variable substitution processing to obtain variable conversion code information; The variable conversion code information is subjected to code state maintenance and update processing to obtain the maintained and updated conversion code information; The maintenance and update conversion code information is stored in a preset file in a preset format to obtain a code conversion file; The maintenance and update conversion code information is modularly split and integrated to obtain individual modular conversion code information and individual integrated conversion code files, including: Identify each segmentation identifier in the maintenance update conversion code information; Based on the partitioning identifier information, the maintenance and update conversion code information is partitioned to obtain various modular conversion code information; Each modular conversion code in the modular conversion code information is processed by rule name recognition to obtain rule name information; The obtained rule name information is clustered to obtain rule name information clusters; For each rule name information cluster in the aforementioned rule name information clusters, perform the following steps: At least one modular conversion code information in each modular conversion code information that corresponds to at least one rule name information in the rule name information cluster is determined as at least one target modular conversion code information; Save the at least one target modular conversion code information to a preset file to obtain an integrated conversion code file; The maintenance and update conversion code information and the various modular conversion code information are tested to obtain test result information; The code conversion file corresponding to the filename of the code to be converted, the information of each modular conversion code, the information of each integrated conversion code file, and the test result information are sent to the client.
2. The method according to claim 1, wherein, The step of performing syntax conversion processing on the code information to be converted to obtain initial converted code information includes: The code information to be converted is processed by line segmentation to obtain a sequence of line code information to be converted; Record the indentation information of each line of code to be converted in the sequence of line code information to be converted; The sequence of line code information to be converted is updated by performing line-by-line keyword replacement processing. Based on the indentation information, the line code information to be converted in the updated sequence of line code information to be converted is concatenated to obtain the initial conversion code information.
3. The method according to claim 2, wherein, The step of performing line-by-line keyword replacement processing on the sequence of line code information to be converted, in order to update the sequence of line code information to be converted, includes: For each line code information to be converted in the sequence of line code information to be converted, perform the following update process: The line code information to be converted is processed by string segmentation to obtain the string sequence to be recognized; The sequence of strings to be identified is processed to obtain each string to be replaced; Based on a preset string mapping table, each string to be replaced in the line code information to be converted is replaced to update the line code information to be converted.
4. The method according to claim 1, wherein, The step of performing variable substitution processing on the initial conversion code information to obtain variable conversion code information includes: The initial conversion code information is subjected to naming convention conversion processing to obtain the initial variable conversion code information; The initial variable conversion code information is subjected to preset variable replacement processing to obtain variable conversion code information.
5. The method according to claim 1, wherein, The step of performing code state maintenance and update processing on the variable conversion code information to obtain the maintained and updated conversion code information includes: For each preset global variable included in the variable conversion code information, perform the following update steps: At the first preset position at the beginning of the loop function corresponding to the preset global variable mentioned in the variable conversion code information, the initial value corresponding to the preset global variable is copied to the preset temporary variable; At the second preset position after the loop function corresponding to the preset global variable in the variable conversion code information ends, the initial value is assigned back to the preset global variable; The variable transformation code information after updating each preset global variable is identified as the maintenance and update transformation code information.
6. A code conversion apparatus, comprising: The first determining unit is configured to, in response to receiving code file information to be converted sent by the client, determine the code file to be converted included in the code file information to be converted as the target code file to be converted. The code file information to be converted includes the code file to be converted and the code file name to be converted. The code file to be converted is determined by the user through interactive operation with a preset file selection control on a preset conversion page. The code file name to be converted is the input information of the code file name input box displayed on the preset conversion page. The preset file selection control is displayed at a first preset position on the preset conversion page, and the code file name input box to be converted is displayed at a second preset position on the preset conversion page. The second determining unit is configured to determine the file content included in the target code file to be converted as the code information to be converted; The syntax conversion processing unit is configured to perform syntax conversion processing on the code information to be converted to obtain initial converted code information; The variable substitution processing unit is configured to perform variable substitution processing on the initial conversion code information to obtain variable conversion code information; The code state maintenance and update processing unit is configured to perform code state maintenance and update processing on the variable conversion code information to obtain maintenance and update conversion code information. The storage unit is configured to store the maintenance and update conversion code information in a preset storage format to a preset file, thereby obtaining a code conversion file; The modular splitting and integration processing unit is configured to perform modular splitting and integration processing on the maintenance and update conversion code information to obtain various modular conversion code information and various integrated conversion code files, including: identifying various partitioning identifiers in the maintenance and update conversion code information; dividing the maintenance and update conversion code information based on the partitioning identifiers to obtain various modular conversion code information; performing rule name recognition processing on each modular conversion code information to obtain rule name information; performing clustering processing on the obtained rule name information to obtain various rule name information clusters; and performing the following steps on each rule name information cluster: determining at least one modular conversion code information corresponding to at least one rule name information in the rule name information cluster as at least one target modular conversion code information; and saving the at least one target modular conversion code information to a preset file to obtain an integrated conversion code file. The test processing unit is configured to perform test processing on the maintenance and update conversion code information and the various modular conversion code information to obtain test result information; The sending unit is configured to send the code conversion file corresponding to the filename of the code to be converted, the information of each modular conversion code, the information of each integrated conversion code file, and the test result information to the client.
7. An electronic device, comprising: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1 to 5.
8. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and apparatus for testing tested program code
CN106126411A
Code conversion method and device, electronic equipment and computer readable medium
CN117555542A