Function processing method and apparatus, and electronic device and storage medium
By using the first stack in a visual programming environment to read and write functions in a loop, the problem of function call stack overflow during node graph execution is solved, ensuring stable program operation.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2026-03-19
AI Technical Summary
In a visual programming environment, when the control flow of a node graph forms a loop, it can cause a function call stack overflow, leading to program crashes.
By simulating the recursive process of depth-first traversal, the first stack is used to read and write functions in a loop until the stack is empty, thus avoiding function call stack overflow.
It effectively solves the function call stack overflow problem, while retaining the function of connecting lines to form loops in visual programming to avoid program crashes.
Smart Images

Figure CN2025104450_19032026_PF_FP_ABST
Abstract
Description
Function processing method and device, electronic device, and storage medium
[0001] Cross-reference to Related Applications
[0002] This application claims priority to Chinese Patent Application No. 202411288924.6, filed September 13, 2024, the disclosure of which is incorporated herein in its entirety as part of the present application. TECHNICAL FIELD
[0003] Embodiments of the present disclosure relate to a function processing method and device, an electronic device, and a storage medium. BACKGROUND
[0004] In a visual programming environment, a logic flow of a program can be represented by a node graph. The node graph can include a plurality of nodes connected by edges, where a node represents a function or an operation, and an edge represents a data flow or a control flow.
[0005] When the node connections in the control flow form a loop, the control flow can fall into a dead loop due to recursive execution, such as node A, node B, node C, and returning to node A, in which the former calls the latter in a sequence that is continuously executed. In this process, when one function calls another function, the execution of the latter occupies a new position in the function call stack, and the recursive function keeps adding to the function call stack, which can cause overflow of the function call stack. SUMMARY
[0006] The present disclosure provides a function processing method and device, an electronic device, and a storage medium, which can solve the problem of overflow of the function call stack when a node graph is executed in a visual programming environment.
[0007] In a first aspect, embodiments of the present disclosure provide a function processing method, comprising:
[0008] obtaining and executing a first function from a first stack;
[0009] determining a second function to be executed called by the first function in a process of executing the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of a plurality of nodes programmed by a visual programming method;
[0010] writing the second function into the first stack;
[0011] obtaining the second function from the first stack after the first function is executed;
[0012] returning to continue executing the first function until the first stack is empty, with the second function as the first function.
[0013] In a second aspect, the embodiments of the present disclosure further provide a function processing apparatus, comprising:
[0014] an execution module configured to acquire and execute a first function from a first stack;
[0015] a determination module configured to determine a second function to be executed, which is called by the first function, during execution of the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of multiple nodes programmed by a visual programming method;
[0016] a writing module configured to write the second function into the first stack;
[0017] an acquisition module configured to acquire the second function from the first stack after execution of the first function;
[0018] a return execution module configured to return the second function as the first function to continue execution of the first function until the first stack is empty.
[0019] In a third aspect, the embodiments of the present disclosure further provide an electronic device, comprising:
[0020] one or more processing apparatuses;
[0021] a storage apparatus configured to store one or more programs,
[0022] when the one or more programs are executed by the one or more processing apparatuses, the one or more processing apparatuses implement the function processing method provided by the embodiments of the present disclosure.
[0023] In a fourth aspect, the embodiments of the present disclosure further provide a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute the function processing method provided by the embodiments of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0024] The above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent upon reading the following detailed description in conjunction with the accompanying drawings, in which like reference numerals refer to like elements. It is to be understood that the drawings are designed solely for the purpose of illustration and not as a definition of the limits of the disclosure, for which reference should be made only to the appended claims. Throughout the drawings, like reference numerals indicate like elements.
[0025] FIG. 1 is a flow diagram of a function processing method provided by an embodiment of the present disclosure;
[0026] FIG. 2 is a flow diagram of another function processing method provided by an embodiment of the present disclosure;
[0027] FIG. 3 is a schematic diagram of a node graph for visual programming according to an embodiment of the present disclosure;
[0028] FIG. 4 is a schematic diagram of an in-out stack simulation for processing a node graph according to a function processing method according to an embodiment of the present disclosure;
[0029] FIG. 5 is a schematic diagram of a dead loop detection according to an embodiment of the present disclosure;
[0030] FIG. 6 is a schematic diagram of a structure of a function processing apparatus according to an embodiment of the present disclosure; and
[0031] FIG. 7 is a schematic diagram of a structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] Embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be interpreted as being limited to the embodiments set forth herein; rather, these embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It should be understood that the drawings of the present disclosure are for illustrative purposes only and are not intended to limit the scope of the present disclosure.
[0033] It should be understood that the various steps in the method embodiments of the present disclosure can be performed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit performing the steps shown. The scope of the present disclosure is not limited in this respect.
[0034] The term “comprising” and variations thereof as used in the present disclosure are open-ended, that is, “including but not limited to”. The term “based on” is “based, at least in part, on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; the term “some embodiments” means “at least some embodiments”. Related definitions are given throughout the description.
[0035] It should be noted that the terms “first”, “second”, and the like in the present disclosure are merely 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.
[0036] It should be noted that the terms “one”, “multiple” in the present disclosure are illustrative and not limiting, and those skilled in the art should understand that, unless otherwise explicitly stated in the context, it should be understood as “one or more”.
[0037] Names of messages or information exchanged between multiple 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.
[0038] Before the method flow of the embodiments of the present disclosure is described, the visual programming and node graph involved in the embodiments of the present disclosure are described:
[0039] Visual programming can be understood as a programming paradigm that allows programs to be created through a graphical interface and drag-and-drop operations. Visual programming can be applied in various scenarios, such as controlling objects in a game scene to achieve interaction in game development, designing special effect packs that meet requirements in software development, analyzing data and visualizing analysis results in data analysis, etc. A special effect pack can be a collection of special effect resources, such as a collection of visual elements and effects specially provided for video production, game development, and multimedia design.
[0040] In actual applications, a node graph can be obtained by programming in a visual programming manner. A node graph is a representation method that presents program logic and flow in a graphical manner. The node graph can include multiple nodes, which can have different types and purposes. Each node represents a function, operation, or processing step that can implement a specific function. Different nodes in the node graph can be connected by lines or edges, which represent the transmission of data and the direction of control flow. The control flow can be a flow that guides the execution order of the program, and the program can be executed in a predetermined logical order through the control flow.
[0041] For example, in the graphical interface of a visual programming tool, a node graph can be obtained by dragging and connecting different nodes through a drag-and-drop operation. The node graph can be converted into an executable script and executed in the order indicated by the control flow in the node graph. The visual programming tool can be a tool for implementing visual programming, which is not limited here.
[0042] FIG. 1 is a flowchart of a function processing method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the execution of a node graph in a visual programming environment. The method can be executed by a function processing device, which can be implemented in the form of software and / or hardware and integrated in an electronic device. Optionally, the electronic device can be a mobile terminal or a PC terminal, etc. As shown in FIG. 1, the method includes:
[0043] S110, obtaining and executing a first function from a first stack.
[0044] The first stack can be a stack used when the node graph is executed according to the control flow, and the first stack can be used to store a function to be executed. The first function can be a function corresponding to a node in the node graph, for example, a function corresponding to a starting node of the control flow, that is, a function corresponding to a node at which the control flow starts to execute. No limitation is imposed on the action on the first function.
[0045] In the embodiments of the present disclosure, the execution of the control flow in the node graph can be understood as a recursive process of depth-first traversal. The process of pushing and popping the first stack can be used to simulate the process of depth-first traversal, and the recursive process can be changed to a loop execution process. The function corresponding to the starting node of the control flow, that is, the first function, is written into the first stack first, and the first stack is started to be read in a loop to obtain the element at the top of the first stack, that is, the first function, and execute the first function.
[0046] In the process of executing the first function, a second function to be executed called by the first function is determined, the first function and the second function are respectively functions corresponding to different nodes in the node graph, and the node graph is a graph composed of a plurality of nodes obtained by visual programming.
[0047] The second function can be a function to be executed called by the first function, and the second function can be one or more, which is not limited herein. In the node graph, the first function and the second function correspond to different nodes respectively, and when there are a plurality of second functions, different second functions correspond to different nodes.
[0048] In the process of executing the first function, the second function called by the first function can be determined through a node in the node graph that has a connection relationship with the node corresponding to the first function. For example, if the control flow indicates that a node corresponding to a function is flowed into from the node corresponding to the first function, the function corresponding to the flowed-in node is the second function, and the second function needs to be called by the first function.
[0049] It should be noted that when there are a plurality of second functions, the calling of different second functions can be executed through different queues in the node corresponding to the first function, and the calling of different second functions can be realized according to the order of queue execution. For example, queue 1 corresponds to the calling of the second function 1, queue 2 corresponds to the calling of the second function 2, queue 1 is executed first and then queue 2 is executed, that is, the second function 1 is called first and then the second function 2 is called.
[0050] In the process of executing the first function, the second function called by the first function can be determined through a node in the node graph that has a connection relationship with the node corresponding to the first function. For example, if the control flow indicates that a node corresponding to a function is flowed into from the node corresponding to the first function, the function corresponding to the flowed-in node is the second function, and the second function needs to be called by the first function.
[0051] In the process of executing the first function, the second function called by the first function can be determined through a node in the node graph that has a connection relationship with the node corresponding to the first function. For example, if the control flow indicates that a node corresponding to a function is flowed into from the node corresponding to the first function, the function corresponding to the flowed-in node is the second function, and the second function needs to be called by the first function.
[0052] In the case that the number of the second functions is one, the second function can be written into the first stack directly, and the written second function is in the first stack for subsequent execution.
[0053] In the case that the number of the second functions is at least two, the second functions can be written into the first stack in the reverse order of the calling sequence of the first function, that is, the second function called later is entered into the stack first, and the second function called earlier by the first function is at the top of the first stack for subsequent execution.
[0054] S140, in the case that the first function is executed, the second function is obtained from the first stack.
[0055] In this step, in the case that the first function is executed, the execution of the second function needs to be implemented, and specifically, the second function at the top of the first stack can be obtained.
[0056] It should be noted that, in the case that the second function is multiple, the second function at the top of the first stack can also be obtained, and the second functions other than the top of the first stack can be retained for subsequent execution in the order of the control flow.
[0057] S150, the second function is taken as the first function, and the execution of the first function is continued until the first stack is empty.
[0058] In this step, the second function obtained in S140 is taken as a new first function, and the execution of the first function is continued until the first stack is empty. That is, the first stack is read circularly, in each execution of the first function, the second function to be executed called by the first function is determined, the second function is written into the first stack, the second function is obtained from the first stack in the case that the first function is executed, and the second function is taken as a new first function for continuous execution until the first stack is empty, and the control flow in the node graph is executed.
[0059] The technical scheme of the embodiment of the present disclosure is that, when the functions in the node graph are executed, the first stack is read circularly, each time a function is read, the function is executed and the function to be executed called by the function is triggered to be entered into the stack, and in the case that the function is executed, the new function is read from the first stack for execution until the stack is empty. By reading and executing the functions in the first stack circularly, the functions called by the read functions are put into the first stack for reading from the first stack for execution, and the entering and exiting operations in the first stack are continuously performed until the stack is empty, which can solve the problem of stack overflow in the execution of the node graph in the visual programming environment.
[0060] On the basis of the above embodiment, a variant embodiment of the above embodiment is proposed, and it should be noted that, in order to make the description brief, only the differences from the above embodiment are described in the variant embodiment.
[0061] FIG. 2 is a flowchart of another function processing method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is based on the above-mentioned embodiment, and is a refinement of executing the first function and a refinement of writing the second function into the first stack. As shown in FIG. 2, the method comprises:
[0062] S210, obtaining the first function from the first stack.
[0063] S220, determining whether the input edge of the node corresponding to the first function is in a dead loop; if so, determining whether an execution condition is met; and if so, executing the first function.
[0064] The input edge of the node corresponding to the first function can be understood as an edge inputting the node corresponding to the first function, i.e., a line connecting to the input port of the node corresponding to the first function in the node graph. The input edge being in a dead loop can be understood as the input edge being repeatedly executed and unable to automatically exit the loop.
[0065] In this step, whether the input edge of the node corresponding to the first function is in a dead loop can be determined according to the connection relationship of each node in the node graph. For example, if the connection relationship indicates that the input edge of the node corresponding to the first function and other edges in the node graph form a closed loop, it means that the input edge of the node corresponding to the first function is in a dead loop. The connection relationship of each node in the node graph can be a relationship indicating how each node in the node graph is connected.
[0066] If the input edge of the node corresponding to the first function is in a dead loop, it is determined whether an execution condition is met. If so, the first function is executed. If not, the loop is exited. The execution condition can be a condition under which the first function can be executed.
[0067] In one embodiment, the execution condition comprises a current loop number being less than a set threshold.
[0068] The current loop number can be the number of traversals of the input edge of the node corresponding to the first function. The set threshold can be a threshold set according to actual needs, such as an upper limit of the number of traversals of the input edge of the node corresponding to the first function, which is not limited herein.
[0069] In one embodiment, the determining whether the input edge of the node corresponding to the first function is in a dead loop comprises:
[0070] obtaining indication information associated with the first function in the first stack;
[0071] determining whether the input edge of the node corresponding to the first function is in a dead loop according to the indication information.
[0072] The indication information associated with the first function can be information related to the node corresponding to the first function. For example, the indication information associated with the first function can include, but is not limited to, an identifier uniquely corresponding to the input edge of the node corresponding to the first function; information indicating which node the second function called by the first function corresponds to; and information indicating whether the input edge of the node corresponding to the first function is in a dead loop, for example, a value of 1 indicating that the input edge is in a dead loop, and a value of 0 indicating that the input edge is not in a dead loop.
[0073] In the embodiments of the present disclosure, when the first function is written into the first stack, the indication information associated with the first function can also be written into the first stack. Subsequently, the indication information associated with the first function in the first stack can be obtained, and the indication information obtained can be used to determine whether the input edge of the node corresponding to the first function is in a dead loop.
[0074] S230, determining a second function to be executed called by the first function during execution of the first function.
[0075] S240, in a case where the number of the second functions is at least two, sequentially writing each of the second functions into the first stack in a reverse order of a calling sequence of the second functions by the first function.
[0076] In this step, the multiple second functions are sequentially written into the first stack in a reverse order of a calling sequence of the second functions by the first function, that is, the second function called later is first written into the stack, so that the second function called earlier by the first function among the multiple second functions is at the top of the first stack and is ready for subsequent execution.
[0077] In one embodiment, in a case where the number of the second functions is at least two, sequentially writing each of the second functions into the first stack in a reverse order of a calling sequence of the second functions by the first function includes:
[0078] In a case where the number of the second functions is at least two, sequentially writing each of the second functions into the second stack in a calling sequence of the second functions by the first function.
[0079] Sequentially writing the functions in the second stack into the first stack in an order from the top of the stack to the bottom of the stack.
[0080] Due to the last-in-first-out feature of the stack, an additional stack, that is, the second stack, is needed to assist in implementing the first-in-first-out sequence. The multiple second functions are sequentially written into the second stack in a calling sequence of the second functions by the first function, so that the order from the bottom of the stack to the top of the stack in the second stack is the calling sequence of the second functions by the first function. The functions in the second stack are sequentially written into the first stack in an order from the top of the stack to the bottom of the stack, so that the order from the top of the stack to the bottom of the stack in the first stack is the calling sequence of the second functions by the first function.
[0081] S250, obtaining the second function from the first stack after the first function is executed.
[0082] S260, returning to continue executing the first function until the first stack is empty, with the second function as the first function.
[0083] The technical solution of the embodiments of the present disclosure simulates the recursive process of the depth-first traversal through the in-stack and out-stack processes of the first stack, in combination with the assistance of the second stack, adopts the idea of replacing recursion with loop to optimize the script export logic of the node graph. After being replaced with loop execution, the loop connection may become a dead loop, but the process will not crash. By executing the first function when the execution condition is met, and exiting the loop when the condition is not met, the situation of continuously executing without response can be avoided. That is, the scheme can not only solve the problem of function call stack overflow, but also can retain the function of connecting loops in visual programming.
[0084] In one embodiment, the writing of the second function into the first stack comprises:
[0085] Determining whether the input edge of the node corresponding to the second function is in a dead loop through the connection relationship of each node in the node graph;
[0086] If so, write the second function and the indication information into the first stack, the indication information indicating that the input edge of the node corresponding to the second function is in a dead loop.
[0087] Through the connection relationship of each node in the node graph, it is determined whether the input edge of the node corresponding to the second function is in a dead loop. If the connection relationship indicates that the input edge of the node corresponding to the second function forms a closed loop with other edges in the node graph, it indicates that the input edge of the node corresponding to the second function is in a dead loop. If the input edge of the node corresponding to the second function is in a dead loop, the second function and the indication information indicating that the input edge of the node corresponding to the second function is in a dead loop are written into the first stack, so as to determine that the input edge of the node corresponding to the second function is in a dead loop based on the indication information subsequently.
[0088] The following is an exemplary description of the embodiments of the present disclosure:
[0089] FIG. 3 is a schematic diagram of a node graph of visual programming provided by an embodiment of the present disclosure. As shown in FIG. 3, the execution flow of its control flow is a recursive process of depth-first traversal, and the execution order should be: node A→node B→node C→node E→node F→node G→node D→node G.
[0090] FIG. 4 is a schematic diagram of in-out stack simulation in processing a node graph according to the function processing method provided by the embodiments of the present disclosure. FIG. 4 can be understood as a schematic diagram of in-out stack simulation in a first stack in processing the node graph shown in FIG. 3 according to the function processing method provided by the embodiments of the present disclosure, in which the dotted shading represents the nodes previously entered into the first stack and reserved in the first stack, and the diagonal shading represents the nodes newly entered into the first stack in the process of executing the function. Specifically, the steps include:
[0091] (1) The first function is obtained from the top of the first stack and executed, and at this time, the first function can be the function corresponding to node A. In the process of executing the first function, the second function to be executed called by the first function is determined, and at this time, the second function can be the function corresponding to node B. The second function is written into the first stack. After the first function is executed, the second function is obtained from the top of the first stack.
[0092] (2) The second function is taken as the first function to continue executing the first function, and at this time, the first function can be the function corresponding to node B. In the process of executing the first function, the second functions, i.e., the functions corresponding to nodes C and D, are determined. The second functions are written into the first stack in the reverse order of the calling sequence of the first function, i.e., the function corresponding to node D and the function corresponding to node C. After the first function is executed, the second function, i.e., the function corresponding to node C, is obtained from the top of the first stack.
[0093] (3) The second function is taken as the first function to continue executing the first function, and at this time, the first function can be the function corresponding to node C. In the process of executing the first function, the second functions, i.e., the functions corresponding to nodes E and F, are determined. The second functions are written into the first stack in the reverse order of the calling sequence of the first function, i.e., the function corresponding to node F and the function corresponding to node E. After the first function is executed, the second function, i.e., the function corresponding to node E, is obtained from the top of the first stack.
[0094] (4) The second function is taken as the first function to continue executing the first function, and at this time, the first function can be the function corresponding to node E. In the process of executing the first function, the second function, i.e., the function corresponding to node F, is determined. After the first function is executed, the second function, i.e., the function corresponding to node F, is obtained from the top of the first stack.
[0095] (5) The second function is taken as the first function to continue executing the first function, and at this time, the first function can be the function corresponding to node F. In the process of executing the first function, the second function, i.e., the function corresponding to node G, is determined. The second function is written into the first stack. After the first function is executed, the second function is obtained from the top of the first stack.
[0096] (6) take the second function as the first function, return to continue executing the first function, at this time the first function can be the function corresponding to node G; in the process of executing the first function, determine the second function, i.e. the function corresponding to node D; in the case of executing the first function, obtain the second function, i.e. the function corresponding to node D, from the top of the first stack.
[0097] (7) take the second function as the first function, return to continue executing the first function, at this time the first function can be the function corresponding to node D; in the process of executing the first function, determine the second function, i.e. the function corresponding to node G; write the second function into the first stack; in the case of executing the first function, obtain the second function from the top of the first stack.
[0098] (8) take the second function as the first function, return to continue executing the first function, at this time the first function can be the function corresponding to node G; in the process of executing the first function, determine that there is no second function corresponding to the first function, and do not perform stacking; in the case of executing the first function, determine that the first stack is empty, and end.
[0099] Since the stack itself is last-in first-out, to achieve first-in first-out order, an additional stack, i.e. the second stack, is needed to assist in achieving first-in first-out. For example, in the above step (2), the second functions are written into the first stack in the reverse order of the calling order of the first function, i.e. the function corresponding to node D, the function corresponding to node C; specifically, the second functions can be written into the second stack in the calling order of the first function, i.e. the function corresponding to node C, the function corresponding to node D; and the functions in the second stack are written into the first stack in the order from the top to the bottom of the stack.
[0100] In the above process of simulating the stacking and de-stacking of the first stack, a dead loop detection can be performed before executing the first function each time. FIG. 5 is a schematic diagram of a dead loop detection provided by an embodiment of the present disclosure, as shown in FIG. 5, including the following steps:
[0101] obtain the first function from the first stack; check whether the input edge traversal times exceed the upper limit, i.e. determine whether the current loop times of the input edge of the node corresponding to the first function exceed the set threshold, if yes, exit the loop; if not, execute the first function. Through the above dead loop detection, the loop times can be limited to avoid the situation of always executing without responding.
[0102] FIG. 6 is a structural schematic diagram of a function processing device provided by an embodiment of the present disclosure, as shown in FIG. 6, the device includes an executing module 610, a determining module 620, a writing module 630, an obtaining module 640 and a returning executing module 650.
[0103] The executing module 610 is configured to obtain and execute the first function from the first stack.
[0104] determining module 620, configured to determine, in a process of execution of the first function, a second function to be executed, which is called by the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of multiple nodes programmed by a visual programming manner;
[0105] a writing module 630, configured to write the second function into the first stack;
[0106] an obtaining module 640, configured to obtain the second function from the first stack in a case where the first function is executed;
[0107] a returning execution module 650, configured to return the second function as the first function to continue execution of the first function until the first stack is empty.
[0108] The technical scheme provided by the embodiments of the present disclosure comprises: the execution module obtains and executes the first function from the first stack; the determining module determines, in a process of execution of the first function, a second function to be executed, which is called by the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of multiple nodes programmed by a visual programming manner; the writing module writes the second function into the first stack; the obtaining module obtains the second function from the first stack in a case where the first function is executed; and the returning execution module returns the second function as the first function to continue execution of the first function until the first stack is empty. By repeatedly reading and executing functions in the first stack, functions called by the read functions are put into the first stack to be read from the first stack and then executed, and the functions are continuously pushed into and popped out of the first stack until the first stack is empty, thereby solving the problem of stack overflow in execution of a node graph in a visual programming environment.
[0109] In one embodiment, the writing module 630 is specifically configured to:
[0110] in a case where the number of the second functions is at least two, sequentially write the second functions into the first stack in a reverse order of a calling sequence of the second functions by the first function.
[0111] In one embodiment, the writing module 630 is specifically configured to:
[0112] in a case where the number of the second functions is at least two, sequentially write the second functions into the second stack in a calling sequence of the second functions by the first function;
[0113] sequentially write the functions in the second stack into the first stack in an order from a top of the second stack to a bottom of the second stack.
[0114] In an embodiment, the execution module 610 is specifically configured to:
[0115] determine whether the input edge of the node corresponding to the first function is in a dead loop;
[0116] if yes, determine whether an execution condition is met;
[0117] execute the first function if the execution condition is met.
[0118] In an embodiment, the execution condition comprises that the current loop number is less than a set threshold.
[0119] In an embodiment, the execution module 610 is specifically configured to:
[0120] obtain the indication information associated with the first function in the first stack;
[0121] determine whether the input edge of the node corresponding to the first function is in a dead loop through the indication information.
[0122] In an embodiment, the writing module 630 is specifically configured to:
[0123] determine whether the input edge of the node corresponding to the second function is in a dead loop through the connection relationship between the nodes in the node graph;
[0124] if yes, write the second function and the indication information into the first stack, the indication information indicating that the input edge of the node corresponding to the second function is in a dead loop.
[0125] The function processing apparatus provided in the embodiments of the present disclosure can execute the function processing method provided in any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of the execution method.
[0126] It should be noted that each unit and module included in the above apparatus is only divided according to the function logic, but is not limited to the above division, as long as the corresponding function can be implemented; in addition, the specific name of each functional unit is only for convenient mutual distinction, and does not serve to limit the protection scope of the embodiments of the present disclosure.
[0127] FIG. 7 is a structural schematic diagram of an electronic device provided in an embodiment of the present disclosure. Referring to FIG. 7, a structural schematic diagram of an electronic device (for example, a terminal device or a server in FIG. 7) 500 suitable for implementing the embodiments of the present disclosure is shown.
[0128] An electronic device provided in an embodiment of the present disclosure comprises:
[0129] one or more processing apparatuses;
[0130] a storage storing one or more programs,
[0131] When the one or more programs are executed by the one or more processing apparatuses, the one or more processing apparatuses implement the function processing method provided by any of the embodiments of the present disclosure.
[0132] The terminal device in the embodiments of the present disclosure can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a vehicle terminal (for example, a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in FIG. 7 is merely an example, and should not bring any limitation to the function and use range of the embodiments of the present disclosure.
[0133] As shown in FIG. 7, the electronic device 500 can include a processing apparatus (for example, a central processing unit, a graphic processing unit, and the like) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing apparatus 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0134] Generally, the following devices can be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; a storage 508 including, for example, a magnetic tape, a hard disk, and the like; and a communication device 509. The communication device 509 can allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although FIG. 7 shows the electronic device 500 having various devices, it should be understood that it is not required to implement or have all the shown devices. More or less devices can be alternatively implemented or had.
[0135] According to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are executed.
[0136] 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.
[0137] The electronic device provided by the embodiments of the present disclosure and the function processing method provided by the above-mentioned embodiments belong to the same inventive concept, and the technical details not described in detail in the present embodiment can be referred to the above-mentioned embodiments, and the present embodiment has the same beneficial effects as the above-mentioned embodiments.
[0138] The embodiments of the present disclosure provide a computer storage medium, which stores a computer program, and the program is executed by a processor to implement the function processing method provided by the above-mentioned embodiments.
[0139] It should be noted that the computer readable medium of the present disclosure described above can be a computer readable signal medium or a computer readable storage medium or any combination of the above two.
[0140] The computer storage medium can be a storage medium of computer executable instructions, and the computer executable instructions are used to execute the method provided by the present disclosure when executed by a computer processor.
[0141] A computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a 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 the present disclosure, a computer readable storage medium can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, a computer readable signal medium can include a computer readable storage medium in baseband or propagated as a carrier wave in a propagated data signal, which can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable signal medium can be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0142] 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.
[0143] The computer readable medium described above can be included in the electronic device described above; alternatively, the computer readable medium can exist as a separate entity in which the electronic device is incorporated.
[0144] The computer readable medium described above carries one or more programs, which when executed by the electronic device, cause the electronic device to: acquire and execute a first function from a first stack; during execution of the first function, determine a second function to be executed called by the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of multiple nodes programmed by a visual programming method; write the second function into the first stack; acquire the second function from the first stack after execution of the first function; and return the second function as the first function to continue execution of the first function until the first stack is empty.
[0145] Computer program code for carrying out operations of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language 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).
[0146] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0147] The modules or units involved in the embodiments of the present disclosure can be implemented in the form of software, or can be implemented in the form of hardware. In some cases, the name of the module or unit does not constitute a limitation on the module itself.
[0148] The functions described above in the present disclosure can be performed at least in part by one or more hardware logic components. For example, non-limiting, exemplary types 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 chips (SOCs), complex programmable logic devices (CPLDs), etc.
[0149] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the above. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0150] According to one or more embodiments of the present disclosure, example 1 provides a function processing method, comprising:
[0151] Obtaining and executing a first function from a first stack;
[0152] During execution of the first function, determining a second function to be executed called by the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of multiple nodes programmed by a visual programming method;
[0153] Writing the second function into the first stack;
[0154] After the first function is executed, obtaining the second function from the first stack;
[0155] Returning the second function as the first function, and continuing to execute the first function until the first stack is empty.
[0156] According to one or more embodiments of the present disclosure, example 2 provides the method according to example 1,
[0157] the writing the second functions into the first stack comprises:
[0158] in a case where the number of the second functions is at least two, the writing the second functions into the first stack comprises:
[0159] According to one or more embodiments of the present disclosure, example 3, the method according to example 2,
[0160] the writing the second functions into the first stack comprises:
[0161] in a case where the number of the second functions is at least two, the writing the second functions into the first stack comprises:
[0162] in a case where the number of the second functions is at least two, the writing the second functions into the first stack comprises:
[0163] According to one or more embodiments of the present disclosure, example 4, the method according to example 1,
[0164] the executing the first function comprises:
[0165] determining whether an input edge of a node corresponding to the first function is in a dead loop;
[0166] if yes, determining whether an execution condition is met;
[0167] executing the first function if the execution condition is met.
[0168] According to one or more embodiments of the present disclosure, example 5, the method according to example 4,
[0169] the execution condition comprises that a current loop number is less than a set threshold.
[0170] According to one or more embodiments of the present disclosure, example 6, the method according to example 4,
[0171] the determining whether an input edge of a node corresponding to the first function is in a dead loop comprises:
[0172] obtaining indication information associated with the first function in a first stack;
[0173] determining whether an input edge of a node corresponding to the first function is in a dead loop through the indication information.
[0174] According to one or more embodiments of the present disclosure, example 7 provides a method according to example 1,
[0175] The writing of the second function into the first stack comprises:
[0176] Determining, through the connection relationship of each node in the node graph, whether the input edge of the second function corresponding node is in a dead loop;
[0177] If yes, writing the second function and indication information into the first stack, the indication information indicating that the input edge of the second function corresponding node is in a dead loop.
[0178] According to one or more embodiments of the present disclosure, example 8 provides a function processing apparatus, comprising:
[0179] An execution module, configured to acquire and execute a first function from a first stack;
[0180] A determination module, configured to determine, in the process of execution of the first function, a second function to be executed called by the first function, the first function and the second function being functions corresponding to different nodes in a node graph, the node graph being a graph composed of multiple nodes programmed through a visual programming mode;
[0181] A writing module, configured to write the second function into the first stack;
[0182] An acquisition module, configured to acquire the second function from the first stack in the case that the first function is executed;
[0183] A return execution module, configured to return the second function as the first function to continue to execute the first function until the first stack is empty.
[0184] According to one or more embodiments of the present disclosure, example 9 provides an electronic device, comprising:
[0185] One or more processing apparatuses;
[0186] A storage apparatus, configured to store one or more programs,
[0187] When the one or more programs are executed by the one or more processing apparatuses, the one or more processing apparatuses implement the function processing method according to any one of examples 1-7.
[0188] According to one or more embodiments of the present disclosure, example 10 provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute the function processing method according to any one of examples 1-7.
[0189] The above description merely illustrates the embodiments of the present disclosure and a principle of applied technologies. It should be understood by those skilled in the art that the disclosed scope of the present disclosure is not limited to the technical solutions formed by the specific combinations of the technical features described above, and should also cover other technical solutions formed by the combinations of the technical features described above or their equivalent features without departing from the concept disclosed above. For example, the technical solutions formed by the mutual replacement of the above-described features and the technical features with similar functions disclosed in the present disclosure (but not limited to) can be used.
[0190] Further, although operations are depicted in a particular order, this should not be understood as requiring the operations to be performed in the particular order shown or in a sequential order, and that certain operations can be performed in parallel or concurrently with other operations disclosed herein. Similarly, while operations have been depicted as following a specific sequence or order, this is not intended to mean that other specific sequences or orders can not be employed. In one aspect, the terms "first", "second", etc. can simply mean "first", "second", etc. of a certain element, and do not require or imply that the elements so described must be in a certain order or position. Also, the terms "first", "second", etc. can simply mean "at least one" of a certain element, and do not require or imply that the elements so described must be in a certain order or position. Also, the terms "first", "second", etc. can simply mean "one" of a certain element, and do not require or imply that the elements so described must be in a certain order or position. Furthermore, the use of the terms "top", "bottom", "front", "back", and the like with respect to a particular element does not limit the element to a particular orientation, but can be used herein for ease of description to describe the particular position of an element as it is depicted in one or more of the figures. It is to be understood that the terminology used herein is for the purpose of describing particular embodiments only, and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0191] Although the present disclosure has been described in terms of particular embodiments and illustrative figures, those of ordinary skill in the art will appreciate that many modifications to the disclosed embodiments can be made without deviating from the disclosure, including the use of alternative structural configurations and logical arrangements of the features described herein.
Claims
1. A function processing method, comprising: obtaining and executing a first function from a first stack; determining, during execution of the first function, a second function to be executed, which is called by the first function, the first function and the second function corresponding to different nodes in a node graph, the node graph being a graph composed of a plurality of nodes programmed by a visual programming method; writing the second function into the first stack; obtaining the second function from the first stack after execution of the first function; returning to continue execution of the first function until the first stack is empty, with the second function as the first function.
2. The method of claim 1, wherein, The writing of the second function into the first stack comprises: in a case where the number of the second functions is at least two, writing the second functions into the first stack in reverse order of the calling sequence of the second functions by the first function.
3. The method of claim 2, wherein, The writing of the second functions into the first stack in reverse order of the calling sequence of the second functions by the first function, in a case where the number of the second functions is at least two, comprises: in a case where the number of the second functions is at least two, writing the second functions into a second stack in the calling sequence of the second functions by the first function; and writing the functions in the second stack into the first stack in order from top to bottom of the second stack.
4. The method of any one of claims 1-3, wherein, The execution of the first function comprises: determining whether an input edge of a node corresponding to the first function is in a dead loop; if so, determining whether an execution condition is met; if the execution condition is met, executing the first function.
5. The method of claim 4, wherein, The execution condition comprises a current loop number being less than a set threshold.
6. The method of claim 4, wherein, The determination of whether the input edge of the node corresponding to the first function is in the dead loop comprises: obtaining indication information associated with the first function in the first stack; and determining, by using the indication information, whether the input edge of the node corresponding to the first function is in the dead loop.
7. The method of any one of claims 1-6, wherein, The writing of the second function into the first stack comprises: determining, by using a connection relationship between nodes in the node graph, whether an input edge of a node corresponding to the second function is in a dead loop; and if so, writing the second function and indication information into the first stack, the indication information indicating that the input edge of the node corresponding to the second function is in the dead loop. 8.A function processing apparatus, comprising: an execution module configured to obtain and execute a first function from a first stack; a determination module configured to determine, during execution of the first function, a second function to be executed, which is called by the first function, the first function and the second function corresponding to different nodes in a node graph, the node graph being a graph composed of a plurality of nodes programmed by a visual programming method; a writing module configured to write the second function into the first stack; an obtaining module configured to obtain the second function from the first stack after execution of the first function; a return execution module configured to return to continue execution of the first function until the first stack is empty, with the second function as the first function. 9.An electronic device, comprising: one or more processing apparatuses; a storage configured to store one or more programs, when the one or more programs are executed by the one or more processing apparatuses, cause the one or more processing apparatuses to implement the function processing method according to any one of claims 1-7.
10. A storage medium containing computer-executable instructions for performing the function processing method according to any one of claims 1-7 when executed by a computer processor.
Citation Information
Patent Citations
Method and device for establishing function stack, medium and electronic equipment
CN111209042A
Parameter transmission method and device, computer equipment and storage medium
CN112882695A
Function call stack backtracking method and device, program exception processing method and device, equipment and medium
CN113342431A
Protection of call stack
US20230185903A1