Script processing method, terminal, storage medium and program product
By adding hook functions to the script to obtain and comment the execution results, the problem of inefficient script troubleshooting caused by the complex model parameterization formula is solved, and the readability and visualization of the script is realized, and the efficiency of problem-solving is improved.
Patent Information
- Application Number
- CN202210470940.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-04-28
AI Technical Summary
In the field of mechanical manufacturing, especially in the design and manufacturing of panel furniture, the complex model parameterization formulas lead to inefficient script problem investigation, and it is difficult for designers and debuggers to quickly locate problem code blocks.
Process the original script through hook functions, obtain the execution results of expression statements and add comments to the script, improving the readability and visualization of the script.
It improves the efficiency of script problem troubleshooting, reduces learning costs and difficulty, and enables users to quickly determine the executed statements and their results.
Smart Images

Figure CN114840251B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer software technology, and in particular to a script processing method, terminal, storage medium, and program product. Background Art
[0002] In the field of mechanical manufacturing, such as panel furniture design and manufacturing, in order to improve the convenience of model design and modification, parametric formula design is adopted for the model. By constraining the correspondence between different parameters through formulas, designers or other users can adjust the parameters to obtain the desired model.
[0003] When designers report that there are anomalies in the model parameters, programmers need to analyze and debug the model's original script to troubleshoot the problem.
[0004] In some scenarios, the parameterized formula definition of the model is relatively complex, such as including a large number of conditional branches and complex parameter node connection relationships. As a result, it takes a long time to analyze the script code, resulting in inefficient script troubleshooting and failure to meet demand. Summary of the Invention
[0005] The present application provides a script processing method, terminal, storage medium and program product, which annotates the original script through a hook function, improves the readability of the script and the visualization of the script execution, thereby improving the efficiency of script problem troubleshooting.
[0006] In a first aspect, the present application provides a script processing method, comprising:
[0007] Process the copied original script based on the hook function to obtain the processed script;
[0008] Executing the hook script to obtain the execution results of each expression statement of the original script intercepted by the hook function;
[0009] According to the execution results of each expression statement, each expression statement of the original script is annotated, and the annotated original script is displayed.
[0010] In a second aspect, the present application provides another script processing method, including:
[0011] Obtaining and copying an original script corresponding to a target model parameter input by a user, wherein the original script includes an expression statement for determining the target model parameter;
[0012] Process the copied original script based on the hook function to obtain the processed script;
[0013] Executing the processed script to obtain the execution result of the expression statement intercepted by the hook function;
[0014] Annotating the expression statement according to the execution result of the expression statement;
[0015] Display the original script after comments to the user.
[0016] In a third aspect, the present application provides a script processing device, comprising:
[0017] The hook function module is used to process the copied original script based on the hook function to obtain the processed script;
[0018] An execution module, configured to execute the hook script to obtain execution results of each expression statement of the original script intercepted by the hook function;
[0019] A script annotation module, for annotating each expression statement of the original script according to the execution result of each expression statement;
[0020] Script display module, used to display the original script after annotation.
[0021] In a fourth aspect, the present application provides another script processing device, comprising:
[0022] A script acquisition module, configured to acquire and copy an original script corresponding to a target model parameter input by a user, wherein the original script includes an expression statement for determining the target model parameter;
[0023] A processing module is used to process the copied original script based on the hook function to obtain a processed script;
[0024] A script execution module, configured to execute the processed script to obtain an execution result of the expression statement intercepted by the hook function;
[0025] An annotation module, used for annotating the expression statement according to the execution result of the expression statement;
[0026] The display module is used to display the original script after annotation to the user.
[0027] In a fifth aspect, the present application provides a script processing terminal, comprising:
[0028] at least one processor, and a memory communicatively coupled to the at least one processor;
[0029] The memory stores computer-executable instructions;
[0030] The at least one processor executes the computer-executable instructions stored in the memory to implement the script processing method provided in the first aspect or the second aspect of the present application.
[0031] In a sixth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the script processing method provided in the first aspect or the second aspect of the present application.
[0032] In a seventh aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the script processing method provided in the first or second aspect of the present application.
[0033] The script processing method, terminal, storage medium and program product provided by the present application enhance the code or statements of the original script based on a hook function. When the original script is executed, the execution results of each expression statement being executed are intercepted by the hook function, and based on the execution results, each expression statement in the original script is annotated. By displaying the annotated original script to the user, the user, such as a designer or debugger, can quickly determine the executed statement and its execution result, thereby improving the readability of the script and the visualization of the script execution. By annotating the expression statement execution results added to the original script, the difficulty of script problem troubleshooting is reduced, allowing the user to quickly determine the problem code block, thereby improving the efficiency of script problem troubleshooting. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0035] Figure 1 A schematic diagram of an application scenario of an embodiment of the present application;
[0036] Figure 2 A schematic diagram of the main process of the script processing method provided in an embodiment of the present application;
[0037] Figure 3 A flowchart of a script processing method provided in an embodiment of the present application;
[0038] Figure 4 A schematic diagram of the structure of a syntax tree provided for one embodiment of the present application;
[0039] Figure 5 A flowchart of a script processing method provided in another embodiment of the present application;
[0040] Figure 6A schematic diagram of a model design page provided for one embodiment of the present application;
[0041] Figure 7 A flowchart of a script processing method provided in another embodiment of the present application;
[0042] Figure 8 A schematic diagram of the structure of a script processing terminal provided in an embodiment of the present application.
[0043] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0044] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0045] First, let’s explain the terms involved in this application:
[0046] Hook function: In computer programming, hook functions are primarily used to modify or enhance the behavior of the operating system, application, or other software by intercepting function calls, messages, or events passed between software keys. The code that handles these intercepted function calls, events, or messages is called a hook. Essentially, it's a program that handles system messages, hooked into the system through system calls.
[0047] Parametric formulas: Express formulas and equations as expressions that include dimensional constraint parameters and user-defined parameters.
[0048] Figure 1 This is a schematic diagram of an application scenario of an embodiment of the present application, such as Figure 1 As shown, when a designer designs a product model based on a model provided by a parametric design tool on the user terminal 100, a model library can be displayed on the model design page of the parametric design tool. The model library includes multiple models, such as Figure 1Models 01 to 03 in the model display area can display the 3D graph corresponding to the model selected by the designer, such as Model 02. The designer can also view and adjust some parameters of the model through the parameter details area of the model, and adaptively adjust other parameters of the model through the script corresponding to the parameterized formula of the model to obtain the expected model.
[0049] When there are anomalies in the model parameters, the designer or debugger needs to check the original script corresponding to the parameterized formula of the model. By analyzing the code of the original script, the problematic code or parameter statement can be determined, thereby troubleshooting the script problem.
[0050] In some application scenarios, the product model structure is complex or includes many parameters, and the definition of the corresponding parameterized formula is also relatively complex, which makes it difficult for debuggers or designers to quickly locate the problem code block. Designers, in particular, usually have no development experience and cannot quickly understand the script. Script problem troubleshooting is difficult and has a high learning cost, resulting in time-consuming and inefficient script problem troubleshooting.
[0051] In order to improve the visualization of scripts and the efficiency of script problem troubleshooting, the present application provides a script processing method based on hook functions. By adding hook functions to the original script, the execution results of each executed expression statement are determined, and the execution results of the statements are added to the original script as comments, thereby improving the readability and visualization of the original script, allowing debuggers or designers to quickly determine the executed statements and the execution results of each executed statement, thereby quickly locating the problem statements based on the execution results, thereby improving the efficiency of problem troubleshooting.
[0052] Figure 2 A schematic diagram of the main process of the script processing method provided in the embodiment of the present application is shown as follows: Figure 2 As shown, when the user needs to view the original script corresponding to the model parameterization formula, the original script is copied through the background, such as Figure 2 The script 110 in the copy is added with a preset hook function in the original script, and the execution result of the expression statement in the original script is obtained through the hook function. Then, based on the execution result, a comment is added to the original script. Specifically, a comment corresponding to the execution result of the expression statement is added after each expression statement to obtain the annotated original script, such as Figure 2 120 in the script and displays the annotated original script, ie, script 120, to the user.
[0053] Figure 2Take the script 110 as an example, which includes two code blocks, namely code block 01 and code block 02. Code block 01 and code block 02 are both executed when script 110 is executed. Code block 01 consists of 5 statements, namely statement 11 to statement 15, and code block 02 consists of 6 statements, namely statement 16 to statement 21, among which statements 12 to statement 15, statement 16 and statement 21 are expression statements, and the comments corresponding to each expression statement are comment 1 to comment 6, respectively, and the content of each comment is the execution result of the corresponding expression statement. In the original script after annotation, namely script 120, a comment is followed by each expression statement to inform relevant personnel of the execution result of the statement, thereby facilitating problem troubleshooting based on the execution results of each expression statement and improving the efficiency of problem troubleshooting.
[0054] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0055] Figure 3 A flowchart of a script processing method provided in an embodiment of the present application, which can be executed by any device with data processing function, such as the above-mentioned user terminal 100 or a subsequent script annotation terminal, such as Figure 3 As shown, the script processing method includes the following steps:
[0056] Step S301: Process the copied original script based on the hook function to obtain a processed script.
[0057] The original script may be a script corresponding to a button displayed on a display page of a browser or other software, such as a button corresponding to a parameterized formula, a function button, etc. The original script may be a script written in JS (JavaScript) scripting language.
[0058] Specifically, a parameterized formula can be a formula related to a parameter of a model, such as a furniture product model, such as an unadjustable parameter or an intermediate parameter. The parameterized formula can be used to describe the relationships between model parameters, such as the relationships between related parameters such as size, material, type, and location. The original script is used to process at least one parameter of a model, such as a furniture product model. The original script can be used to determine the value of a parameter related to an adjustable parameter, such as an unadjustable parameter, based on an adjustable parameter, such as an adjustable parameter input or adjusted by the user.
[0059] In one embodiment, the hook function can be used to obtain the execution results of each expression statement in the original script. The hook function can also be used to obtain the executed code block or statement.
[0060] In the field of furniture model design, expression statements are used to represent the calculation process of the parameters of the furniture product model, such as size, material, position and other parameters, or intermediate parameters associated with these parameters. Intermediate parameters are only used to calculate non-adjustable parameters and are process parameters. They will not be output by the original script.
[0061] Specifically, a pre-designed hook function may be added to the copied original script to obtain a processed script.
[0062] Specifically, each expression statement in the copied original script can be rewritten based on the hook function, so that when the rewritten expression statement is executed, the execution result of the expression statement can be obtained based on the hook function.
[0063] For example, when the parameter a is greater than 0, the expression statement "b+c+d" is executed. After adding a hook function to the expression statement, or rewriting or enhancing the expression statement through the hook function, the expression statement becomes "$get(b+c+d)", where $get() is the hook function. When the expression statement is executed, the execution result of the expression statement can be intercepted through $get().
[0064] Specifically, after detecting a display request corresponding to the original script, the original script may be copied, and the copied original script may be processed based on the hook function to obtain a processed script.
[0065] The user may input a display request through an input device such as a mouse, keyboard, microphone, etc. After receiving the display request input by the user, the original script of the software button corresponding to the display request is copied.
[0066] Specifically, the user can trigger a display request for the original script of the preset button by clicking the script viewing function of the preset button, and thereby obtain and copy the original script corresponding to the preset button based on the display request.
[0067] Exemplarily, the preset button may be a button for one or more parameterized formulas of the product model.
[0068] Optionally, the hook function includes a first hook function, which is used to intercept the execution result of the corresponding expression statement; processing the copied original script based on the hook function to obtain a processed script includes:
[0069] The copied original script is converted into a syntax tree; based on the first hook function, the code of the original script corresponding to the expression node in the syntax tree is processed to obtain a processed script; wherein the expression node is a node corresponding to the expression statement in the original script.
[0070] The syntax tree is a tree-like structure composed of multiple nodes, such as code block nodes and statement nodes. Each statement in the source code (i.e., the original script you copied) corresponds to a node in the syntax tree. The root node is typically the node corresponding to the "body" block in the code. A code block is a section of code enclosed in curly braces in the script.
[0071] Specifically, the copied original script may be subjected to lexical analysis and grammatical analysis, and then converted into a grammar tree based on the analysis results.
[0072] Specifically, the copied original script may be converted into a syntax tree through a JS engine, such as the nashorn engine.
[0073] Specifically, each node of the syntax tree can be traversed by using recursive traversal, hierarchical traversal, and other traversal methods. If the current node is a node corresponding to an expression statement or the node type is an expression type, the code or statement corresponding to the node is obtained, and the code or statement corresponding to the node is processed based on the first hook function, such as enhancement processing; if the current node is not a node corresponding to an expression statement or the node type is not an expression type, the next node is obtained.
[0074] For example, Figure 4 A schematic diagram of the structure of a syntax tree provided in one embodiment of the present application is shown in FIG. Figure 4 As shown, each node is represented by the flag "f", and each node is represented by "node name = {node type @ node identifier}". The content in the quotation marks following the node is the content of the code corresponding to the node. The node name can be determined according to the element, function, variable or statement corresponding to the node, such as body, token, his, etc.; the node type includes code block type (Block) and expression type. The expression type is the type of the node corresponding to the expression statement, which can be an assignment statement, a relational expression statement, a logical expression statement, an arithmetic expression statement, etc.; in Figure 4 The midpoint identifier is represented by three digits, such as 787. Figure 4In the example, the root node of the syntax tree corresponding to the original script is the node of the body code block, with node identifier 787. The body code block includes a child node, namely the test node (node identifier 806), which corresponds to an if branch statement to determine whether a is greater than 10; the test node includes two child nodes, namely the pass node (node identifier 809) and the fail node (node identifier 810); the pass node corresponds to the case where a is greater than 10, and the pass node includes a child node, namely the expression node, which is used to calculate b+c+d; the fail node corresponds to the case where a is less than or equal to 10, and this node is used to return 0.
[0075] Through the syntax tree, the expression nodes in the syntax tree are enhanced based on the hook function. It is easy to implement, and the coverage rate of expression statements is high, and statements are not easily missed.
[0076] Step S302: executing the processed script to obtain the execution results of each expression statement of the original script intercepted by the hook function.
[0077] The execution result is the value of the model parameters after the expression statement is executed.
[0078] Specifically, the processed script can be executed by a browser to obtain an execution result. From the execution result, the information intercepted by each hook function, that is, the execution result of each expression statement, is extracted.
[0079] Taking the original script used to calculate one of the non-adjustable parameters of the model (such as the subsequent second parameter) as an example, the execution result may include the value of the non-adjustable parameter and the value of the intermediate parameter associated with the non-adjustable parameter.
[0080] For example, taking a cabinet as an example, the cabinet's total height, total length, and total width are all adjustable parameters. The dimensions of components such as the cabinet door and base can be non-adjustable parameters. The original script corresponding to the parameterized formula can be used to calculate the cabinet's total height, total length, and total width based on these parameters. For example, the cabinet door width can be 40%, 50%, etc. of the total cabinet width.
[0081] Step S303: annotate each expression statement of the original script according to the execution result of each expression statement, and display the annotated original script.
[0082] Specifically, for each expression statement, the execution result of the expression statement can be added to the original script in the form of a comment. For example, after the expression statement, that is, in the original script after the comment, each executed expression statement will be followed by a comment. This shows the execution result of the expression statement, making it easier for users to know the execution result of the expression statement based on the comment.
[0083] In one embodiment, comments may be represented by “ / ** / ” or “ / / ”.
[0084] For example, taking the expression statement "r=thin_groove_y;", the execution result of which is 6, the expression statement after comment is "r=thin_groove_y / *6* / ;", where " / *6* / " is a comment.
[0085] The script processing method provided in this embodiment enhances the code or statements of the original script based on a hook function. When the original script is executed, the execution results of each expression statement being executed are intercepted by the hook function, and based on the execution results, each expression statement in the original script is annotated. By displaying the annotated original script to the user, the user, such as a designer or debugger, can quickly determine the executed statement and its execution result, thereby improving the readability of the script and the visualization of the script execution. By annotating the expression statement execution results added to the original script, the difficulty of script problem troubleshooting is reduced, allowing the user to quickly determine the problem code block, thereby improving the efficiency of script problem troubleshooting.
[0086] Figure 5 A flowchart of a script processing method provided in another embodiment of the present application. Figure 3 On the basis of the embodiment shown, step S301 is further refined, and after step S302, a step of setting the color of the code block executed by the original script is added, such as Figure 5 As shown, the script processing method provided in this embodiment may include the following steps:
[0087] Step S501: Display the buttons corresponding to the parameterized formulas corresponding to the selected components of the model.
[0088] The model can be any two-dimensional or three-dimensional model of an object, such as a furniture model or a building material model. The model can be any model in the model library. The button corresponding to the parameterized formula can be any element displayed on the page that is wrapped in a container, such as a link, title, text, or button.
[0089] The selected component of the model is any component of the model selected by the user, such as the bottom plate of a cabinet model, the door of a car model, etc. If the user clicks, such as single-clicking or double-clicking, any component of the model, or if the user keeps the mouse on one of the components of the model for a preset time, such as 1s, 2s, 3s, etc., the component is the selected component, and the buttons corresponding to one or more parameterized formulas corresponding to the component can be displayed at the bottom, side, etc. of the model.
[0090] Specifically, after a user selects or drags a model from the model library, the model can be displayed on the model design page. The model design page also displays the corresponding structure tree for the model, where each node in the structure tree represents a component of the model. The model design page also displays information such as the model's parameters and basic properties. Users can view each component of the model by clicking the area corresponding to the component in the displayed model or clicking the node corresponding to the component in the structure tree. Users can also adjust the model's adjustable parameters, thereby updating the model parameters and the displayed model.
[0091] For example, Figure 6 A schematic diagram of a model design page provided for an embodiment of the present application, such as Figure 6 As shown, Figure 6 Taking a single-door left-opening wall cabinet as an example, the corresponding 3D diagram of the model is displayed in the middle area of the model design page, and the model parameters and the model structure tree are displayed on both sides of the 3D diagram. Figure 6 In the example, the single-door left-opening wall cabinet corresponds to 10 parameters, namely parameter 001 to parameter 010, and the adjustable parameters (such as Figure 6 An input box is provided next to parameter 001, parameter 003, parameter 004, and parameters 008 to 010 in the figure to allow the user to adjust the value of the adjustable parameter. The parameters of the single-door left-opening wall cabinet model include corresponding parameters such as size, material, color, relative position, and type. The single-door left-opening wall cabinet includes components such as the left side panel, right side panel, top panel, bottom panel, two movable shelves, and left-opening door. The node of each component can also include sub-nodes. Users can view component information through a three-dimensional diagram or a structure tree, such as the parameters corresponding to the component, the parametric formula corresponding to the component, the properties of the component, related information, etc.
[0092] Optionally, the method further includes:
[0093] When it is detected that a first parameter of the model is updated, the original script of the parameterized formula corresponding to the first parameter is initialized based on the new first parameter; the initialized original script is run to determine at least one second parameter of the model; and the displayed model is updated according to the new first parameter and the at least one second parameter.
[0094] Among them, the first parameter is an adjustable parameter of the model, such as the total width of a cabinet, the total length of a sofa, etc. The second parameter is a parameter that changes with the first parameter, such as the width of a double-door cabinet door. The second parameter can be a non-adjustable parameter.
[0095] Specifically, when displaying a model, each first parameter of the model can be displayed on one side of the model. The user can adjust the first parameters through an input device. When an update of any first parameter is detected, the updated first parameter, i.e., the new first parameter, is obtained, and the original script of the corresponding parameterized formula is initialized based on the new first parameter. By running the initialized original script, at least one second parameter corresponding to the first parameter is obtained or updated. The displayed model is then updated based on the new first parameter and its corresponding new second parameter, thereby displaying the updated model based on the first parameters to the user.
[0096] When the adjustable parameters of the model are updated, the original script corresponding to the parameterized formula is used to adaptively adjust the display model, and the adjusted model is displayed in real time, which improves the real-time and intuitiveness of the interaction of the model design and enhances the model design experience.
[0097] Step S502: monitoring key events corresponding to the parameterized formulas.
[0098] Step S503: When a click event of a key corresponding to a parameterized formula is detected, the original script of the parameterized formula is copied.
[0099] The click event may be a single click, double click, or other operation-triggered event, and is used to view the original script of the corresponding parameterized formula.
[0100] Specifically, it is used to click a button corresponding to one of the parameterized formulas on the model design page displayed on a browser or other software, thereby triggering a corresponding click event, and based on the click event, obtaining and copying the original script of the parameterized formula.
[0101] By visualizing the parameterized formula button, users can use the button to view and debug the script, improving the convenience of script viewing.
[0102] Step S504: convert the copied original script into a syntax tree.
[0103] Specifically, the copied original script may be converted into a syntax tree based on a syntax interpreter.
[0104] Step S505 : Based on the first hook function, the code of the original script corresponding to the expression node in the syntax tree is processed.
[0105] The expression node is a node corresponding to the expression statement in the original script.
[0106] Step S506: traverse each code block node in the syntax tree and add the second hook function to each code block of the copied original script.
[0107] The code block node is a node corresponding to the code block in the original script.
[0108] In one embodiment, the second hook function may be added to the beginning, end, or other locations of the code block corresponding to each code block node.
[0109] In one embodiment, a recursive traversal method may be used to traverse each code block node in the syntax tree.
[0110] Specifically, each code block node in the syntax tree may be traversed, a code block identifier may be set for each code block node, and a second hook function may be inserted into each code block node.
[0111] Step S505 and step S506 may be executed in parallel or in series, such as executing step S505 first and then step S506, or executing step S506 first and then step S505. This application does not limit this.
[0112] The copied original script is processed in steps S505 and S506 to obtain a processed script.
[0113] Step S507: execute the processed script to obtain the execution result of the first hook function and the execution result of the second hook function.
[0114] The execution result of the first function is the execution result of the corresponding expression statement in the original script.
[0115] Among them, the execution result of the second hook function can be the identifier of the code block where the second hook function is located, or the execution result of the second hook function can be the third parameter. The third parameter corresponding to each second hook function is different, so the executed code block is determined based on the correspondence between the third parameter and the identifier of the code block.
[0116] Exemplarily, the second hook function may be $record(N), where N is the value returned when the code block corresponding to the second hook function is executed, and may be the identifier of the code block where the second hook function is located or corresponds to, or may be a third parameter.
[0117] Step S508: annotate each expression statement of the original script according to the execution result of the first hook function.
[0118] Specifically, based on the execution result of the first hook function, the execution result of the expression statement corresponding to the first hook function is determined, and the execution result of the expression statement is added to the expression statement in the original script in the form of a comment.
[0119] Exemplarily, the execution result of the expression statement may include only the value of the variable, such as 10, or may include the variable and its value, such as the bottom plate length is 10, a=10, or a is currently 10.
[0120] Step S509: determining the executed code block of the original script based on the execution result of the second hook function.
[0121] In one embodiment, if the execution result of the second hook function is a third parameter, a preset correspondence between the third parameter and the identifier of the code block is obtained; based on each third parameter in the execution result of the second hook function and the preset correspondence, the identifier of each executed code block is determined, and then the code blocks executed in the original script are determined.
[0122] Furthermore, after determining the executed code blocks of the original script, the names of the executed code blocks, such as the function names corresponding to the code blocks, can be displayed on the model design page to facilitate the user to know the executed code blocks. The displayed names of the code blocks can be sorted according to the order in which the code blocks are executed.
[0123] Step S508 and step S509 can be executed in parallel or in series, such as executing step S508 first and then executing step S509, or executing step S509 first and then executing step S508. This application does not limit this.
[0124] Optionally, after determining the executed code block of the original script based on the execution result of the second hook function, the method further includes:
[0125] An execution path of the original script is generated and displayed according to the executed code blocks of the original script.
[0126] The execution path may be composed of the names of the executed code blocks sorted in the execution order.
[0127] In one embodiment, the execution path may be composed of multiple path nodes, each path node corresponds to a code block, and the path node may include the name of the corresponding code block and the return value of the corresponding code block.
[0128] Specifically, for each executed code block in the original script, the name of the code block and the comment of the code block are obtained; according to the name of each executed code block and the comment of each executed code block, the execution path of the original script is generated and displayed.
[0129] In one embodiment, the comment of the code block may include the execution results of each expression statement in the code block, that is, the execution result of the first hook function, and may also include the comment added by the writer of the original script to the code block of the original script.
[0130] By displaying the execution path of the code block to the user, the visualization of the original script execution logic is improved. The user can preliminarily troubleshoot the original script based on the short execution path to identify the code blocks that may have problems. Then, the user only needs to view the code of a small number of code blocks in the original script to troubleshoot the problems of the entire original script, which improves the efficiency of code troubleshooting.
[0131] Step S510: adjusting the color of the executed code block of the original script to a preset color.
[0132] The preset color may be any color different from the color of the original script code itself, such as green, red, yellow, etc.
[0133] By adjusting the color of the executed code block, users can intuitively determine the executed code, thereby reducing the amount of code the user needs to view and improving the efficiency of user code problem troubleshooting.
[0134] Step S511: Display the original script after color adjustment and annotation.
[0135] Specifically, the original script after color adjustment and annotations can be displayed at the bottom, side or other locations of the model design interface, so that the user can troubleshoot problems based on the displayed original script.
[0136] In this embodiment, the execution results of the expression statements and the executed code blocks in the original script of the parameterized formula are obtained respectively through the first hook function and the second hook function, and then the executed and non-executed code blocks are distinguished by color differentiation, and the execution result of each executed expression statement is followed by the execution result of the expression statement, so that the user can intuitively distinguish the executed code blocks by color, thereby reducing the amount of code that the user needs to view and improving the efficiency of script problem troubleshooting; by adding the execution result after the expression statement, the user can quickly understand the values of each variable during the code execution process, so that the user does not need to master the context of the parameterized formula, reducing the learning cost of the formula script and the difficulty of script problem troubleshooting, and further improving the efficiency of script problem troubleshooting.
[0137] Figure 7 A flowchart of another script processing method is provided for the embodiment of the present application. Figure 3 Based on the embodiment, before step S301, a user interaction process is added, such as Figure 7 As shown, the script processing method provided in this embodiment may include the following steps:
[0138] Step S701: Acquire and copy the original script corresponding to the target model parameters input by the user.
[0139] The original script includes expression statements for determining the target model parameters.
[0140] Step S702: Process the copied original script based on the hook function to obtain a processed script.
[0141] Step S703: execute the processed script to obtain the execution result of the expression statement intercepted by the hook function.
[0142] Step S704: annotate the expression statement according to the execution result of the expression statement.
[0143] Step S705: Display the annotated original script to the user.
[0144] The target model parameter may be any parameter of the model, such as size, material, color, etc. The model may be a 3D model of a home product.
[0145] For example, a user views a model on a display interface and adjusts some of the model's parameters, such as adjustable parameters, thereby updating the displayed model and its associated parameters. The user can select any of the displayed parameters as a target model parameter, thereby triggering the aforementioned script processing method. This script processing method displays the annotated original script corresponding to the selected or input target model parameter to the user, allowing the user to quickly understand the calculation process of the target model parameter based on the annotations and determine whether the target model parameter has any anomalies.
[0146] In one embodiment, the user may input the target model parameters by clicking a button, or may input the target model parameters through an input box.
[0147] In one embodiment, the parameterized formula corresponding to the target model parameter may also be displayed to the user, and the user may click on the displayed parameterized formula to view the annotated original script corresponding to the clicked parameterized formula.
[0148] In one embodiment, the code block of the original script being executed may be determined through a hook function, so that the color of the code block of the original script being executed displayed to the user is adjusted to a preset color, such as green.
[0149] In one embodiment, the execution path of the original script may also be displayed to the user.
[0150] Based on the above Figure 3 and Figure 5 The technical solutions provided in any corresponding embodiment include steps such as annotating the original script, adjusting the color, and determining the execution path, which will not be repeated here in this embodiment.
[0151] An embodiment of the present application provides a script processing device, which includes:
[0152] A hook function module is used to process the copied original script based on the hook function to obtain a processed script; an execution module is used to execute the hook script to obtain the execution results of each expression statement in the original script intercepted by the hook function; a script annotation module is used to annotate each expression statement in the original script according to the execution results of each expression statement; and a script display module is used to display the annotated original script.
[0153] Optionally, the hook function includes a first hook function, which is used to intercept the execution result of the corresponding expression statement; the hook function module is specifically used to:
[0154] The copied original script is converted into a syntax tree; based on the first hook function, the code of the original script corresponding to the expression node in the syntax tree is processed to obtain a processed script; wherein the expression node is a node corresponding to the expression statement in the original script.
[0155] Optional hook function module, including:
[0156] A script conversion unit is used to convert the copied original script into a syntax tree; a first hook function unit is used to process the code of the original script corresponding to the expression node in the syntax tree based on the first hook function; a second hook function unit is used to traverse each code block node in the syntax tree and add the second hook function to each code block of the copied original script; wherein the code block node is the node corresponding to the code block in the original script.
[0157] Optionally, the device further includes:
[0158] The color adjustment module is configured to determine the executed code block of the original script based on the execution result of the second hook function after the processed script is executed, and adjust the color of the executed code block of the original script to a preset color.
[0159] Correspondingly, the script display module is specifically used to:
[0160] Shows the original script after color adjustments and annotations.
[0161] Optionally, the device further includes:
[0162] The execution path generation module is used to generate and display the execution path of the original script according to the executed code block of the original script after determining the executed code block of the original script based on the execution result of the second hook function.
[0163] Optionally, the device further includes:
[0164] A component button display module is used to display the button corresponding to the parameterized formula corresponding to the selected component of the model; an event monitoring module is used to monitor the events of the button corresponding to the parameterized formula; a script copy module is used to copy the original script of the parameterized formula when a click event of the button corresponding to the parameterized formula is detected; wherein the parameterized formula is used to characterize the correspondence between at least two parameters of the model.
[0165] Optionally, the device further includes:
[0166] A model update module is used to initialize an original script of a parameterized formula corresponding to a first parameter based on the new first parameter when detecting that a first parameter of the model is updated; run the initialized original script to determine at least one second parameter of the model; and update the displayed model according to the new first parameter and the at least one second parameter.
[0167] The script processing device provided in the embodiment of the present application can be used to execute the above Figure 3 and Figure 5 The technical solutions provided in any corresponding embodiment have similar implementation principles and technical effects, which will not be described in detail in this embodiment.
[0168] An embodiment of the present application provides another script processing device, which includes:
[0169] A script acquisition module is used to acquire and copy the original script corresponding to the target model parameters input by the user, wherein the original script contains an expression statement for determining the target model parameters; a processing module is used to process the copied original script based on the hook function to obtain a processed script; a script execution module is used to execute the processed script to obtain the execution result of the expression statement intercepted by the hook function; an annotation module is used to annotate the expression statement based on the execution result of the expression statement; a display module is used to display the annotated original script to the user. Optionally, the hook function includes a first hook function, which is used to intercept the execution result of the corresponding expression statement when it is executed; the processing module is specifically used to:
[0170] The copied original script is converted into a syntax tree; based on the first hook function, the code of the original script corresponding to the expression node in the syntax tree is processed to obtain a processed script; wherein the expression node is a node corresponding to the expression statement in the original script.
[0171] Optional processing module, specifically used for:
[0172] The copied original script is converted into a syntax tree; based on the first hook function, the code of the original script corresponding to the expression node in the syntax tree is processed; each code block node in the syntax tree is traversed, and the second hook function is added to each code block of the copied original script; wherein the code block node is the node corresponding to the code block in the original script.
[0173] Optionally, the device further includes:
[0174] A color adjustment module is used to determine the executed code block of the original script based on the execution result of the second hook function after the processed script, and adjust the color of the executed code block of the original script to a preset color.
[0175] Accordingly, the display module is specifically used for:
[0176] The user is shown the original script with the color adjustments and annotations.
[0177] Optionally, the device further includes:
[0178] The path generation module is used to generate and display the execution path of the original script according to the executed code block of the original script after determining the executed code block of the original script based on the execution result of the second hook function.
[0179] Optional, script acquisition module, specifically used for:
[0180] Display the key corresponding to the parameterized formula corresponding to the target model parameter of the model; monitor the event of the key corresponding to the parameterized formula; when the click event of the key corresponding to the parameterized formula is detected, obtain and copy the original script of the parameterized formula; wherein the parameterized formula is used to characterize the correspondence between at least two parameters of the model.
[0181] Optionally, the device further includes:
[0182] An update module is used to initialize an original script of a parameterized formula corresponding to a first parameter based on the new first parameter when detecting that a first parameter of the model is updated; run the initialized original script to determine at least one second parameter of the model; and update the displayed model according to the new first parameter and the at least one second parameter.
[0183] The script processing device provided in the embodiment of the present application can be used to execute the above Figure 7 The technical solutions provided in any corresponding embodiment have similar implementation principles and technical effects, which will not be described in detail in this embodiment.
[0184] Figure 8 A schematic diagram of the structure of a script processing terminal provided in an embodiment of the present application is shown as follows: Figure 8 As shown, the script processing terminal provided in this embodiment includes:
[0185] At least one processor 810; and a memory 820 communicatively connected to the at least one processor; wherein the memory 820 stores computer-executable instructions; the at least one processor 810 executes the computer-executable instructions stored in the memory to enable the electronic device to perform a method as provided in any of the foregoing embodiments.
[0186] Optionally, the memory 820 may be independent or integrated with the processor 810 .
[0187] In one embodiment, the script processing terminal further includes a display for displaying the original script processed by the method provided in this application, such as the annotated original script, color adjustment, and the annotated original script.
[0188] In one embodiment, the display is also used to display the model design page.
[0189] The implementation principle and technical effects of the script processing terminal provided in this embodiment can be found in the aforementioned embodiments and will not be described in detail here.
[0190] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the method provided in any of the aforementioned embodiments can be implemented.
[0191] An embodiment of the present application further provides a computer program product, including a computer program, which implements the method provided in any of the aforementioned embodiments when executed by a processor.
[0192] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules is merely a logical function division. In actual implementation, other division methods may be used. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not implemented.
[0193] The above-mentioned integrated module implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present application.
[0194] It should be understood that the above-mentioned processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor. The memory may include high-speed RAM memory, and may also include non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0195] The storage medium may be implemented by any type of volatile or non-volatile memory 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 storage, flash memory, magnetic disk, or optical disk. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0196] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an application-specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete buttons in an electronic device or a main control device.
[0197] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0198] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0199] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods provided in each embodiment of the present application.
[0200] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0201] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A script processing method, characterized in that: include: Process the copied original script based on the hook function to obtain the processed script; Executing the processed script to obtain the execution results of each expression statement of the original script intercepted by the hook function; According to the execution results of each expression statement, each expression statement of the original script is annotated, and the annotated original script is displayed.
2. The method according to claim 1, characterized in that The hook function includes a first hook function, and the first hook function is used to intercept the execution result of the corresponding expression statement; The copied original script is processed based on the hook function to obtain the processed script, including: Convert the copied original script into a syntax tree; Based on the first hook function, the code of the original script corresponding to the expression node in the syntax tree is processed to obtain a processed script; The expression node is a node corresponding to the expression statement in the original script.
3. The method according to claim 2, characterized in that The hook function further includes a second hook function, wherein the second hook function is used to intercept the executed code block of the original script; After converting the copied original script into a syntax tree, the method further includes: Traversing each code block node in the syntax tree, and adding the second hook function to each code block of the copied original script; The code block node is a node corresponding to the code block in the original script.
4. The method according to claim 3, characterized in that After processing the code of the original script corresponding to the expression node in the syntax tree based on the first hook function to obtain a processed script, the method further includes: Determining a code block of the original script to be executed based on an execution result of the second hook function; The color of the code block where the original script is executed is adjusted to a preset color.
5. The method according to claim 4, characterized in that After determining the executed code block of the original script based on the execution result of the second hook function, the method further includes: An execution path of the original script is generated and displayed according to the executed code blocks of the original script.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Display the key corresponding to the parameterized formula of the selected component of the model; Monitor key events corresponding to the parameterized formula; When a click event of a key corresponding to a parameterized formula is detected, the original script of the parameterized formula is copied; The parameterized formula is used to characterize the corresponding relationship between at least two parameters of the model.
7. The method according to claim 6, characterized in that The method further comprises: When it is detected that a first parameter of the model is updated, initializing an original script of the parameterized formula corresponding to the first parameter based on the new first parameter; running the initialized original script to determine at least one second parameter of the model; The displayed model is updated according to the new first parameter and the at least one second parameter.
8. A script processing method, characterized in that: include: Obtaining and copying an original script corresponding to a target model parameter input by a user, wherein the original script includes an expression statement for determining the target model parameter; Processing the copied original script based on the hook function to obtain a processed script; executing the processed script to obtain an execution result of the expression statement intercepted by the hook function; Annotating the expression statement according to the execution result of the expression statement; Display the original script after comments to the user.
9. A script processing terminal, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 8 when the computer program is executed by a processor.
Citation Information
Patent Citations
Cloud-based universal parameterized model analysis method and design system
CN111324965A
Program analysis method and device and electronic equipment
CN114138280A