Method, device, electronic device and storage medium for running building block code

By translating the building block code into the target language format, obtaining the target method from the target runtime, generating a program collection, and directly running it in the target run platform, the problem of low efficiency in executing the building block code in the existing technology is solved, and more efficient program execution is achieved.

CN119739389APending Publication Date: 2025-04-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311243569.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-25
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

Executing building block code in a target running platform based on the target language format is less efficient. The existing methods require the building block code to be translated into code in the auxiliary language format and interpreted and executed through the script interpreter in the auxiliary language format, resulting in high performance consumption.

Method used

By obtaining the building block code for the target controlled object, translating it into the target language format, and obtaining the target method identification corresponding to the target method from the target runtime corresponding to the target controlled object, generating a program set corresponding to the building block code, and directly running the program set in the target running platform, avoiding script interpreters in auxiliary language format.

Benefits of technology

It improves the efficiency of executing building block code, reduces the performance consumption when communicating with script interpreters in auxiliary language formats, and improves the efficiency of obtaining programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739389A_ABST
    Figure CN119739389A_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, electronic device and storage medium for running building block code. The method includes obtaining building block code for a target controlled object; translating the building block code into a target language format to obtain a target code, wherein the target code includes a target method identifier of the method called by the building block code; obtaining a target method corresponding to the target method identifier from a target runtime corresponding to the target controlled object; the target runtime includes methods available for calling by the target controlled object and method identifiers corresponding to each method; generating a program set corresponding to the building block code according to the target method and the target code; and running the program set so that the target controlled object acts according to the method called by the building block code. In the present application, the performance consumption when communicating with a script interpreter in an auxiliary language format is eliminated, the efficiency of obtaining the program set is improved, and thus the efficiency of executing the building block code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a method, device, electronic device and storage medium for running building block codes. Background Art

[0002] Usually, when executing the building block code in the target operation platform based on the target language format, the building block is first translated into an intermediate code, and then the intermediate code is executed by executing the dynamic code. However, the mainstream solution for executing dynamic code in the target operation platform is to embed a script interpreter in the auxiliary language format in the target operation platform, translate the building block code into a code in the auxiliary language format to generate an auxiliary language format script, and interpret the script in the auxiliary language format by the script interpreter in the auxiliary language format to achieve the purpose of executing the dynamic code. However, the efficiency of executing the building block code by this method is low. Summary of the invention

[0003] In view of this, embodiments of the present application provide a method, device, electronic device and storage medium for running building block codes.

[0004] In a first aspect, an embodiment of the present application provides a method for running a building block code, the method comprising: obtaining a building block code for a target controlled object; translating the building block code into a target language format to obtain a target code, the target code comprising a target method identifier of a method called by the building block code; obtaining a target method corresponding to the target method identifier from a target runtime corresponding to the target controlled object; the target runtime comprises methods available for calling by the target controlled object and method identifiers corresponding to each method; generating a program set corresponding to the building block code according to the target method and the target code; and running the program set so that the target controlled object acts according to the method called by the building block code.

[0005] In a second aspect, an embodiment of the present application provides a device for running building block codes, the device comprising: an acquisition module, used to acquire building block codes for a target controlled object; a translation module, used to translate the building block codes into a target language format to obtain a target code, the target code comprising a target method identifier of the method called by the building block code; a determination module, used to acquire a target method corresponding to the target method identifier from a target runtime corresponding to the target controlled object; the target runtime comprises methods that can be called by the target controlled object and method identifiers corresponding to each method; a generation module, used to generate a program set corresponding to the building block code according to the target method and the target code; and a running module, used to run the program set so that the target controlled object acts according to the method called by the building block code.

[0006] Optionally, the determination module is also used to obtain a target string template corresponding to the target controlled object, the target string template includes an update function and a target runtime corresponding to the target controlled object; write the target code into the target string template to obtain a target string; in response to satisfying a trigger condition corresponding to the update function in the target string, obtain a target method corresponding to the target method identifier from the target runtime through the update function in the target string.

[0007] Optionally, the determination module is further configured to fill the target code into a target field in the target string template to obtain a target string.

[0008] Optionally, the generation module is also used to compile the target method and the target code to obtain a program set corresponding to the building block code.

[0009] Optionally, the device further comprises a component acquisition module, which is used to create a dynamic object according to the target program set to obtain a target instance; and generate a target runtime component for the method called by the building block code according to the target instance.

[0010] Optionally, the component acquisition module is further used to associate the target runtime component with the target controlled object and display the target runtime component.

[0011] Optionally, the running module is further used to run the program set in response to the start of the life cycle of the target controlled object.

[0012] Optionally, the running module is also used to display an object display interface, which includes a start control; in response to a trigger operation on the start control, determine that the life cycle of the target controlled object begins; and display a screen of the target controlled object running according to the program set on the object display interface.

[0013] Optionally, the acquisition module is further configured to, in response to a selection operation on a preset building block code of the target controlled object, determine the preset building block code selected by the selection operation as the building block code of the target controlled object.

[0014] Optionally, the device also includes a prompt module, which is used to output an error prompt message if the compilation of the target method and the target code fails.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the above method.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, wherein the above method is executed when the program code is executed by a processor.

[0017] In a fifth aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the above method.

[0018] The embodiments of the present application provide a method, device, electronic device and storage medium for running building block codes. In the present application, the building block code for the target controlled object is translated into the target code in the target language format, and the target method called by the building block code is obtained from the target runtime corresponding to the target controlled object. Then, a program set is generated through the target method and the target code. The program set can be directly run in the target runtime platform based on the target language format, and there is no need to translate the building block code into the code in the auxiliary language format. Therefore, there is no need to translate the building block code through the script interpreter in the auxiliary language format, which saves the performance consumption when communicating with the script interpreter in the auxiliary language format, improves the efficiency of obtaining the program set, and thus improves the efficiency of executing the building block code. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 A schematic diagram showing an application scenario to which the embodiments of the present application are applicable;

[0021] Figure 2 A flowchart of a method for running building block codes proposed in one embodiment of the present application is shown;

[0022] Figure 3 A schematic diagram of a construction interface in an embodiment of the present application is shown;

[0023] Figure 4 A schematic diagram of a building block code display interface in an embodiment of the present application is shown;

[0024] Figure 5 A flowchart of a method for running building block codes proposed in one embodiment of the present application is shown;

[0025] Figure 6 A schematic diagram of a component display interface in an embodiment of the present application is shown;

[0026] Figure 7A schematic diagram showing another component display interface in an embodiment of the present application is shown;

[0027] Figure 8 A schematic diagram showing a process of creating a target runtime component in an embodiment of the present application is shown;

[0028] Fig. 9 A schematic diagram showing the life cycle of a controlled object in an embodiment of the present application is shown;

[0029] Fig.10 Shows Figure 3 A schematic diagram of the screen when the target controlled object is running;

[0030] Fig.11 A block diagram of a device for running building block codes proposed in one embodiment of the present application is shown;

[0031] Fig.12 A structural block diagram of an electronic device for executing a method for running building block codes according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. According to the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0033] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0035] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0036] It should also be noted that in the embodiments of the present application, the acquisition of building block code, target code and user-related information during runtime requires the user's permission or consent, and the collection, use, processing and storage of user information must comply with the regulations of the region.

[0037] like Figure 1 As shown, the application scenario applicable to the embodiment of the present application includes a terminal 20 and a server 10, and the terminal 20 and the server 10 are connected through a wired network or a wireless network. The terminal 20 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart home appliance, a vehicle terminal, an aircraft, a wearable device terminal, a virtual reality device, and other terminal devices that can display pages, or run other applications that can call page display applications (such as instant messaging applications, shopping applications, search applications, game applications, forum applications, map traffic applications, programming applications, etc.).

[0038] The server 10 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The server 10 may be used to provide services for applications running on the terminal 20.

[0039] Among them, the terminal 20 can send the building block code to the server 10, the server 10 can translate the building block code into the target language format to obtain the target code, and obtain the target method corresponding to the target method identifier from the target runtime corresponding to the target controlled object, and then generate a program set corresponding to the building block code according to the target method and the target code. Finally, the server 10 can return the program set to the terminal 20, and the terminal 20 can run the program set so that the target controlled object can act according to the method called by the building block code.

[0040] Among them, the terminal 20 may be installed with a target operating platform, which may be an operating platform based on the target language format. For example, the target operating platform can be a real-time 3D interactive content creation and operation platform, including all creators in game development, art, architecture, automobile design, film and television, using the target operating platform to turn creativity into reality. The target operating platform can provide a complete set of software solutions that can be used to create, operate and realize any real-time interactive 2D and 3D content, and the supported platforms include mobile phones, tablets, PCs, game consoles, augmented reality and virtual reality devices.

[0041] Building blocks (also called building block code) refer to the graphical expression of code. Building block programming refers to the logic of users assembling or assembling multiple building blocks.

[0042] In other embodiments, the terminal 20 may obtain the building block code and generate a program set according to the building block code according to the method of the present application, and then the terminal 20 may run the program set to make the target controlled object act according to the method called by the building block code.

[0043] It is worth mentioning that the method of running the building block code in the implementation of this application can be applied to the game scene to control the virtual objects in the game scene, wherein the virtual objects can be virtual characters, virtual vehicles, virtual props, etc. For example, the virtual vehicle in the game scene is the target controlled object, and the corresponding building block code can be configured for the virtual vehicle according to the method of this application, so that the vehicle can travel in the game scene according to the program set corresponding to the building block code. For another example, the virtual character in the game scene is the target controlled object, and the corresponding building block code can be configured for the virtual character according to the method of this application, so that the virtual character can perform corresponding actions (such as shooting, jumping or crawling, etc.) in the game scene according to the program set corresponding to the building block code.

[0044] For the convenience of description, in the following embodiments, the execution of the building block code by an electronic device is taken as an example for description.

[0045] See also Figure 2 , Figure 2 A flowchart of a method for running a building block code proposed in one embodiment of the present application is shown. The method can be applied to an electronic device, which can be Figure 1 The terminal 20 or the server 10 in the embodiment of the present invention comprises:

[0046] S110: Obtain a building block code for a target controlled object.

[0047] In this embodiment, the electronic device may be installed with a target operating platform based on a target language format, and the electronic device may obtain the building block code for the target controlled object through the target operating platform.

[0048] The target controlled object may refer to an object to be controlled. The object may be a created two-dimensional or three-dimensional virtual object, or a called existing virtual object. The virtual object may refer to a robot under the target operating platform, and the robot action may be controlled according to the code in the target operating platform.

[0049] Building block code uses graphic blocks (similar to building blocks that can be freely combined) to represent code concepts such as variables, logical expressions, loops, etc. It allows users to program directly according to programming principles without having to pay attention to grammatical details.

[0050] In some embodiments, the electronic device may display an input interface of the target operating platform, and S110 may include: in response to a code input operation for the target controlled object, obtaining the code input by the input operation as a building block code for the target controlled object. For example, if the target controlled object is a car, the user may input a building block code corresponding to the wheel size of the car, a building block code corresponding to the wheel speed, and a building block code corresponding to the wheel rotation direction, etc., in the input interface.

[0051] In another embodiment, the electronic device may display a building block code display interface of the target operating platform, and S110 may include: in response to a selection operation of a preset building block code of the target controlled object, determining the preset building block code selected by the selection operation as the building block code of the target controlled object.

[0052] The target operating platform can display a construction interface, which includes a menu bar and a control area. The menu bar can include a menu bar for the target controlled object (such as Figure 3 The vehicle model) displays the structural basis, actuators, sensors, and power devices. It is understandable that the options displayed in the menu bar may be different for different types of controlled objects. Figure 3 As shown, the target operating platform can display a construction interface 30. After the user clicks the structural basic option in the menu bar 301 in the construction interface 30, the control area 302 is as shown in FIG. Figure 3 As shown, the user can select the elements of the target controlled object in the control area 320 corresponding to the structural basis option. The elements involved may include basic blocks, 1 / 4 spheres, regular tetrahedrons, beveled bodies, corner cubes, R45 wheels, half bodies (half bodies may refer to half spheres), and L4 cylinders. When the target controlled object to be constructed is a vehicle, the control area 302 can also display the element detail control 3021 corresponding to the constructed part of the vehicle. The element detail control displays the number of each element in the constructed part of the vehicle. In addition, the control area 302 can also display the total number of elements corresponding to the vehicle ( Figure 3 ), the number of elements corresponding to the constructed parts of the vehicle ( Figure 3 45) and the total mass of the built parts of the vehicle ( Figure 3 84 in the example). The control area 302 may also display a save control 303, and the user clicks the save control 303 to save the currently constructed part.

[0053] After the target controlled object is constructed, the target operating platform may display a building block code display interface, which displays preset building block codes, so that the user can select the building block code corresponding to the target controlled object through the preset building block codes in the displayed building block code display interface.

[0054] like Figure 4 As shown, Figure 4 Shown Figure 3 The building block code display interface 40 corresponding to the vehicle in the example can display option controls corresponding to functions such as events, controls, calculations, variables, functions, PID, actuators, sensors, power units, image intelligence, image capture, keyboard events, and voice recognition. After the user clicks on an option control, the building block code display interface 30 can display the preset building block code under the function corresponding to the option control.

[0055] exist Figure 4 In the example, the block code display interface 40 also displays the block code corresponding to the vehicle (that is, the preset block code selected by the user for the vehicle). For example, when the target controlled object is a vehicle, the block code corresponding to the vehicle includes: the block code corresponding to the medium-sized LCD display 2 displaying large white fonts when starting to run, the block code corresponding to the medium-sized LCD display 2 clearing the screen and the medium-sized LCD display 2 printing "1" repeatedly, the block code corresponding to the four motors of the vehicle running if the keyboard "↑" is pressed, and the block code corresponding to the four motors of the vehicle running if the keyboard "←" is pressed, etc. Among them, editable variables can be provided in the preset block code so that the user can specify the variable value corresponding to the variable according to the needs, for example, Figure 4 In the encoder motor speed variable, the user can set the speed as required ( Figure 4 The selected speed is shown as 30RMP), and correspondingly, the variable value specified by the user for the variable is also part of the building block code.

[0056] S120: Translate the building block code into a target language format to obtain a target code, where the target code includes a target method identifier of the method called by the building block code.

[0057] In this embodiment, the electronic device can call a language compiler, and can translate the building block code into a code in a target language format through the language compiler to obtain a target code. The electronic device can also store a code mapping library, which includes codes in a target language format corresponding to different building block codes, and obtain the code in the target language format of the building block code for the target controlled object from the code mapping library as the target code. Among them, the target language format can be a strongly typed language, and the strong type in the strongly typed language means that the type of any object expressed in the program must be determined at compile time. Strongly typed languages ​​include Java, Apex, Python, C#, etc.

[0058] In some implementations, after translating the building block code into the target code in the target language format, the target code may be subjected to syntax checking. If the target code does not have syntax errors, the target code is used to execute the subsequent steps. If the target code has syntax errors, an error message indicating that the target code has syntax errors is output, and the subsequent steps are not executed, so as to prompt the user to repair the target code with syntax errors or to re-acquire the building block code for the target controlled object.

[0059] The method called by the building block code refers to the method or function of controlling the action of the target controlled object according to the building block code. For example, if the target controlled object is controlled to move forward 30m according to the building block code, the method called by the building block code refers to the method or function of controlling the target controlled object to move forward. The method called in a building block code can be one or more, which is not specifically limited here.

[0060] S130 , obtaining a target method corresponding to the target method identifier from a target runtime corresponding to the target controlled object.

[0061] The target runtime includes the methods that can be called by the target controlled object and the method identifiers corresponding to each method.

[0062] In this embodiment, a controlled object may correspond to a runtime, which includes methods that can be called by the controlled object and method identifiers corresponding to each method. The controlled object may include multiple components, and the methods that can be called by the controlled object may include methods that can be called by each component in the controlled object. Among them, the method that can be called by each component refers to a function or method that controls the action of the component. For example, if the action of component a is bending, the method called by component a is the method or function of bending a.

[0063] In this embodiment, a category of controlled objects may correspond to a runtime, which includes methods that can be called by each controlled object under the category and method identifiers corresponding to each method, wherein the methods called by different controlled objects of the same category may be the same. For example, if controlled object a1 and controlled object a2 are controlled objects of the same category, then the methods that can be called by controlled object a1 include 10, and the methods that can be called by controlled object a2 include 10, and the methods that can be called by controlled object a1 and controlled object a2 are the same.

[0064] When the runtime corresponding to the target controlled object is used as the target runtime, the target runtime includes the methods that can be called by the target controlled object and the method identifiers corresponding to each method. It can be understood that since the actions that can be performed or the functions that can be realized by different controlled objects are different, the methods that can be called by different controlled objects are different. In other words, the runtimes corresponding to different controlled objects may be different. It is worth mentioning that the runtime corresponding to the controlled object can also include the attribute information of the controlled object. The controlled object can include multiple components, and the attribute system information of the controlled object can include the component attribute information of each component in the controlled object. At this time, the target runtime corresponding to the target controlled object also includes the attribute information of the target controlled object. Among them, the attribute information of the target controlled object can include the size, name, logo, quality, material and color of the target controlled object. The attribute information of the component also refers to the size, name, logo, quality, material and color of the component.

[0065] Optionally, S130 may include: obtaining a target string template corresponding to the target controlled object, the target string template including an update function and a target runtime corresponding to the target controlled object; writing a target code into the target string template to obtain a target string; in response to satisfying a trigger condition corresponding to the update function in the target string, obtaining a target method corresponding to the target method identifier from the target runtime through the update function in the target string.

[0066] A string template refers to a template set for a controlled object. The string template may include the runtime of the controlled object. In some embodiments, a controlled object may correspond to a string template. Different controlled objects may correspond to different string templates. The string template corresponding to the target controlled object is used as the target string template. In other embodiments, a category of controlled objects may correspond to the same string template. The string template corresponding to the category to which the target controlled object belongs is used as the target string template. After determining the target string template, the target code may be written into the target string template to obtain the target string.

[0067] The update function is a function used to trigger the acquisition of the target method corresponding to the target method identifier from the target runtime. The trigger condition corresponding to the update function is the condition that triggers the update function to run. The trigger condition can be that the time from the last run reaches a preset time interval or a target event occurs, where the preset time interval can be a value set based on demand, and the target event can be an event set based on demand, for example, the target event can be clicking the space bar on the keyboard or starting the target runtime platform each time.

[0068] When writing the target code into the target string template, the target code may be written into a specific position in the target string template, so the target runtime and update function in the target string template will not be changed when the target code is written into the target string template. For example, the target code may be filled into the target field in the target string template to obtain the target string. The target field may be a field filled with the target code, and the target field may be, for example, an identifier or a space.

[0069] It is worth mentioning that the runtime can be in the runtime field of the string template. Users can set the location of the runtime field based on their needs, for example, the runtime field is at the very end or the very top of the string template.

[0070] When the trigger condition corresponding to the update function in the target string is met, the update function can automatically determine that the target method corresponding to the target controlled object can be obtained. At this time, the target method corresponding to the target method identifier is obtained from the target runtime of the target string through the update function in the target string.

[0071] For example, the string template of the controlled object corresponding to category B is:

[0072] string robotTemplate="

[0073] class Robot{

[0074] public void Update() {

[0075] ${0}

[0076] }

[0077] }";

[0078] The update function is Update function, the return type of the update function is void, and {${0}} is the target field. The target code can be filled into {${0}}, and ${0} can be replaced by the target code to obtain the target string. The runtime is not shown in the string template.

[0079] When the target code is "print("Hello, world!")", fill the target code "print("Hello, world!")" into the above string template, and the target string obtained is as follows:

[0080] string robotCode="

[0081] class Robot{

[0082] public void Update() {

[0083] print("Hello, world!")

[0084] }

[0085] }";

[0086] At this time, it is determined that the target method identifier is "print", and the print method corresponding to "print" can be obtained from the runtime corresponding to the target controlled object as the target method.

[0087] S140: Generate a program set corresponding to the building block code according to the target method and the target code.

[0088] After obtaining the target method and the target code, a set of programs that can be run on the target operating platform can be generated according to the target method and the target code.

[0089] Optionally, the target method and the target code may be compiled to obtain a program set corresponding to the building block code. The tool used to compile the target method and the target code may be the Roslyn compilation framework of .NET.

[0090] Since the target code includes the target method identifier of the building block code calling method, but does not include the building block code calling method, the compilation result obtained by directly compiling the target code does not include the code corresponding to the building block code calling method. At this time, when running the program set determined according to the compilation result corresponding to the compiled target code, the target controlled object cannot output the correct action or cannot act. Therefore, it is necessary to compile the building block code calling method (target method) and the target code at the same time, and obtain the program set corresponding to the building block code according to the compilation results corresponding to the target method and the target code. The program set corresponding to the building block code includes the code corresponding to the building block code calling method. At this time, when running the program set determined according to the compilation results corresponding to the target code and the target method, the target controlled object can output the correct action.

[0091] In some embodiments, when the target code is filled into the string template corresponding to the target controlled object to obtain the target string, the target string can be compiled to form a program set corresponding to the building block code.

[0092] Optionally, the method may further include: if the compilation of the target method and the target code fails, outputting an error prompt message.

[0093] During the compilation process of the target method and the target code, the target method and the target code can be syntax checked. If the target method and the target code do not have syntax errors, a program collection is obtained according to the compilation results corresponding to the target method and the target code. If the target method or the target code has syntax errors, it is determined that the compilation of the target method and the target code has failed, the compilation process can be stopped, and the subsequent process will not be continued. At the same time, an error prompt message indicating that the compilation results corresponding to the target method and the target code have syntax errors can be output to prompt the user to repair the compilation results with syntax errors (target methods with syntax errors or target codes with syntax errors) or re-acquire the building block code for the target controlled object.

[0094] S150, running the program set to make the target controlled object act according to the method called by the building block code.

[0095] After obtaining the program set corresponding to the building block code, the program set corresponding to the building block code can be directly run through the target operation platform. When the target operation platform runs the program set corresponding to the building block code, the target controlled object acts according to the method called by the building block code.

[0096] For example, the target controlled object is a robot dog, and the building block code of the target controlled object is used to control the robot dog to do a somersault. The methods called by the building block code of the robot dog include "jumping" and "flipping". A program set is generated according to the building block code of the robot dog, and the target running platform runs the program set. The robot dog outputs a somersault action according to the "jumping" and "flipping" actions.

[0097] As mentioned above, the runtime of the controlled object may also include the attribute information of the controlled object. Therefore, the acquired building block code may also include a query code for the attribute information of the target controlled object. When the program set corresponding to the building block code is run, the attribute information of the target controlled object is queried and output.

[0098] In this embodiment, the building block code for the target controlled object is translated into the target code in the target language format, and the target method called by the building block code is obtained from the target runtime corresponding to the target controlled object, and then a program collection is generated through the target method and the target code. The program collection can be directly run in the target runtime platform based on the target language format, and there is no need to translate the building block code into the code in the auxiliary language format. Therefore, there is no need to translate the building block code through the script interpreter in the auxiliary language format, which saves the performance consumption when communicating with the script interpreter in the auxiliary language format, improves the efficiency of obtaining the program collection, and then improves the efficiency of executing the building block code.

[0099] At the same time, the compilation phase of the code in C# language format can check the code in advance and provide more code error information to the user to modify the code. At the same time, in this embodiment, there is no need to introduce a script compiler in Lua language format (that is, the aforementioned auxiliary language format), and there is no need to encapsulate the LUA virtual machine and its calling environment. The performance is good and the package size is small, which makes the debugging efficiency of developers higher.

[0100] Before running the program set, the target code and the target method in the target runtime will be compiled. During the compilation process, syntax checking will be performed. If the compilation is successful, the program set corresponding to the target code and the target method will continue to be executed. If the compilation fails (for example, there is a syntax error), the subsequent process will be interrupted immediately and an error prompt message will be output so that the user can solve the error more conveniently and quickly. At the same time, it also avoids adding additional user interactions to prompt the user that the code is wrong and that additional code is needed to restore the execution environment to the situation before the user code is executed when running the program set corresponding to the compilation result with syntax errors, thereby reducing the time for the block code processing and improving the efficiency of running the block code.

[0101] Since the target language type is a strongly typed language, there will be a complete compilation process, which can check the syntax legality of the target code and give specific error prompt information, and can also provide users with code suggestions for error prompt information through static code analysis. This reduces the time and cost of obtaining error prompt information and code suggestions, and improves the efficiency of obtaining error prompt information and code suggestions.

[0102] In the related art, by translating the building block code into a weak language type such as a script and then running it, if the user enters the wrong parameter type on the building block, or a syntax error occurs during the building block translation process, or a non-existent API is called, or there is an error during the runtime, the error can only be located after running the translated code, which will result in a lot of additional user interactions to prompt the user that the code is wrong, and at the same time, the execution environment needs to be restored to before the execution of the translated code, and there is no effective error prompt, which will cause the user to spend a long time to locate the error and solve the code error. In the solution of the present application, the building block code is translated into a target language format of a strong language type, and there is a compilation process before running. During the compilation process, the errors in the code can be automatically located and effective error prompt information can be generated. The error prompt information can include the type of error, thereby facilitating users to solve the errors in the code in a targeted manner.

[0103] See also Figure 5 , Figure 5 A flowchart of a method for running a building block code proposed in another embodiment of the present application is shown. The method can be applied to an electronic device, which can be Figure 1 The terminal 20 or the server 10 in the embodiment of the present invention comprises:

[0104] S210, obtaining a building block code for a target controlled object; translating the building block code into a target language format to obtain a target code; obtaining a target method corresponding to a target method identifier from a target runtime corresponding to the target controlled object; and generating a program set corresponding to the building block code according to the target method and the target code.

[0105] The description of S210 refers to the description of S110 to S140 above, and will not be repeated here.

[0106] S220, creating a dynamic object according to the target program set to obtain a target instance; and generating a target runtime component for the method called by the building block code according to the target instance.

[0107] In this embodiment, a dynamic object can be created according to a target program set by reflection technology to obtain a created target instance. In the past, the generation of objects needed to be compiled and generated according to a clear object definition, while the user logic inside the controlled object was not fixed and was input by the user. Taking the update function of the above-mentioned controlled object as an example, after obtaining the target string containing the target code corresponding to the building block code of the target controlled object, the program set was obtained by compiling this target string. If the target string is changed for compilation, a different program set can be obtained. The reflection technology can dynamically generate objects from the program set just compiled, thereby obtaining a target instance.

[0108] In some embodiments, if the dynamic object is successfully created according to the target program set through reflection technology, the created object is obtained as the target instance. If the dynamic object is failed to be created according to the target program set through reflection technology, the subsequent process is stopped and a prompt message is output to prompt the user that the creation of the target instance has failed, so as to re-acquire the building block code for the target controlled object.

[0109] After obtaining the target instance, the target instance can be used as a resident object in the target runtime platform, thereby obtaining the target runtime component.

[0110] S230: Associating the target runtime component with the target controlled object, and displaying the target runtime component.

[0111] After obtaining the target runtime component, the target runtime component can be associated with the target controlled object, and the target runtime component can be displayed so that the user can view the associated target controlled object through the displayed target runtime component. Generally speaking, the target operation platform displays the default component for the target controlled object, and the default component can include the structure information and attribute information of the configured target controlled object, wherein the structure information of the target controlled object can refer to the various components for constructing the target controlled object, the setting positions of the various components, and the setting position of the target controlled object, etc.

[0112] If the method called by the building block code includes the method corresponding to the default component, the target runtime component obtained according to the building block code is different from the default component, that is, when the target runtime component is displayed, the default component will also be displayed on the target runtime platform.

[0113] like Figure 6 As shown, the electronic device outputs a component display interface 70 of the target operating platform. The component display interface displays the default components corresponding to the target controlled object. After creating the target runtime component and associating the target runtime component with the target controlled object, the component display interface 70 is as shown in FIG. Figure 7 As shown, the component display interface 70 also displays the target runtime components of the target controlled object.

[0114] In this embodiment, the process of creating the target runtime component is as follows: Figure 8 As shown, first, the building block code of the target controlled object is obtained, and the building block code is translated into the target code in the target language format. If there is a syntax error in the target code, the translation error is determined. At this time, the creation of the target runtime component can be stopped, and an error prompt message indicating that there is a syntax error in the target code is output. If the translation is correct, the target code and the target method in the target runtime of the target controlled object are compiled.

[0115] During the compilation process of the target method and the target code in the target runtime, if the compilation results corresponding to the target method and the target code in the target runtime indicate a syntax error, the creation process of the target runtime component is stopped and a compilation error prompt message is output; if the compilation results corresponding to the target method and the target code in the target runtime do not have a syntax error, the compilation is completed to obtain a program assembly.

[0116] Afterwards, the target instance corresponding to the program collection is created through reflection technology. If the creation fails, the creation process of the target runtime component is stopped and a creation failure prompt message is output. If the creation is successful, the target instance is added to the target operating platform as a permanent object. If the addition fails, the creation process of the target runtime component is stopped and an addition failure prompt message is output. If the addition is successful, the target runtime component is obtained.

[0117] S240 . In response to the life cycle of the target controlled object starting, run the program set.

[0118] The target controlled object has a life cycle. After the life cycle of the target controlled object begins, the program set is run. After the program set is generated according to the target controlled object, the controlled object is consistent with the model objects in other target operating platforms, and both have a life cycle, which is controlled by the life cycle management of the target operating platform.

[0119] The target operating platform manages the life cycle of each controlled object through its own update function. When the update function of the target operating platform is started, the life cycle of the controlled object begins. The program set of each controlled object is run through the update function, so that each controlled object acts according to the method called by its own building block code. At this point, the purpose of dynamically executing the building block code set by the user is achieved.

[0120] like Fig. 9 As shown, at the beginning of the life cycle of the target operating platform, the program set of the controlled object starts to run to realize the operation of the target controlled object.

[0121] As an implementation, before S240, the method may further include: displaying an object display interface, the object display interface including a start control; and determining that the life cycle of the target controlled object begins in response to a trigger operation on the start control. That is, when the trigger operation on the start control is detected, an update function of the target operating platform is started.

[0122] Optionally, after S240, the method may further include: displaying a screen of the target controlled object running according to the program set on the object display interface. The screen of the target controlled object running according to the program set may be directly displayed on the object display interface, so that the user can view the operation process of the target controlled object through the screen of the target controlled object running according to the program set.

[0123] like Fig.10 As shown, Fig.10 The object display interface 50 is shown Figure 3 The vehicles in Figure 2 The object display interface 50 may also include a save control 501. During or after the vehicle is running according to the program set corresponding to the building block code, the user can select the control 501, and the target application platform can save the screen of the vehicle running according to the program set corresponding to the building block code.

[0124] In this embodiment, a target runtime component is generated according to a program set corresponding to the building block code, and the target runtime component is displayed, so that the user can directly view the target runtime component. At the same time, the target controlled object has a life cycle. At the beginning of the life cycle, the program set is run to realize the automatic operation of the target controlled object, thereby realizing the life cycle management of the target controlled object in the target application platform.

[0125] See also Fig.11 , Fig.11 A block diagram of a device for running building block codes proposed in one embodiment of the present application is shown, and the device 1100 includes:

[0126] An acquisition module 1110 is used to acquire a building block code for a target controlled object;

[0127] A translation module 1120 is used to translate the building block code into a target language format to obtain a target code, wherein the target code includes a target method identifier of a method called by the building block code;

[0128] The determination module 1130 is used to obtain a target method corresponding to a target method identifier from a target runtime corresponding to a target controlled object; the target runtime includes methods available for calling by the target controlled object and method identifiers corresponding to each method;

[0129] A generating module 1140, for generating a program set corresponding to the building block code according to the target method and the target code;

[0130] The running module 1150 is used to run the program set so that the target controlled object can act according to the method called by the building block code.

[0131] Optionally, the determination module 1130 is also used to obtain a target string template corresponding to the target controlled object, the target string template including an update function and a target runtime corresponding to the target controlled object; write the target code into the target string template to obtain a target string; in response to satisfying a trigger condition corresponding to the update function in the target string, obtain a target method corresponding to the target method identifier from the target runtime through the update function in the target string.

[0132] Optionally, the determination module 1130 is further configured to fill the target code into a target field in the target string template to obtain a target string.

[0133] Optionally, the generation module 1140 is further used to compile the target method and the target code to obtain a program set corresponding to the building block code.

[0134] Optionally, the device further comprises a component acquisition module, which is used to create a dynamic object according to the target program set to obtain a target instance; and generate a target runtime component for the method called by the building block code according to the target instance.

[0135] Optionally, the component acquisition module is further used to associate the target runtime component with the target controlled object and display the target runtime component.

[0136] Optionally, the running module 1150 is further configured to run a program set in response to the start of the life cycle of the target controlled object.

[0137] Optionally, the running module 1150 is also used to display an object display interface, which includes a start control; in response to a trigger operation on the start control, determine that the life cycle of the target controlled object begins; and display a screen of the target controlled object running according to the program set on the object display interface.

[0138] Optionally, the acquisition module 1110 is further configured to, in response to a selection operation on a preset building block code of the target controlled object, determine the preset building block code selected by the selection operation as the building block code of the target controlled object.

[0139] Optionally, the device also includes a prompt module, which is used to output an error prompt message if the compilation of the target method and the target code fails.

[0140] It should be noted that the device embodiment in the present application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.

[0141] Fig.12 A structural block diagram of an electronic device for executing a method for running a building block code according to an embodiment of the present application is shown. The electronic device may be Figure 1 The terminal 20 or the server 10, etc., need to be explained that, Fig.12 The computer system 1200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0142] like Fig.11As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1202 or the program loaded from the storage part 1208 to the random access memory (RAM) 1203, such as executing the method in the above embodiment. In RAM 1203, various programs and data required for system operation are also stored. CPU 1201, ROM 1202 and RAM 1203 are connected to each other through bus 1204. Input / output (I / O) interface 1205 is also connected to bus 1204.

[0143] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0144] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1209, and / or installed from a removable medium 1211. When the computer program is executed by a central processing unit (CPU) 1201, various functions defined in the system of the present application are executed.

[0145] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0146] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0147] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0148] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium carries computer-readable instructions, and when the computer-readable storage instructions are executed by a processor, the method in any of the above embodiments is implemented.

[0149] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method in any of the above embodiments.

[0150] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0151] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable an electronic device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation method of the present application.

[0152] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary techniques in the art that are not disclosed in the present application. It should be understood that the present application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for running a building block code, characterized in that: The method comprises: Obtain the building block code for the target controlled object; Translating the building block code into the target language format to obtain a target code, wherein the target code includes a target method identifier of the method called by the building block code; Acquire a target method corresponding to the target method identifier from a target runtime corresponding to the target controlled object; the target runtime includes methods available for calling by the target controlled object and method identifiers corresponding to each method; According to the target method and the target code, a program set corresponding to the building block code is generated; The program set is run to make the target controlled object act according to the method called by the building block code.

2. The method according to claim 1, characterized in that The step of acquiring the target method corresponding to the target method identifier from the target runtime corresponding to the target controlled object includes: Acquire a target string template corresponding to the target controlled object, wherein the target string template includes an update function and a target runtime corresponding to the target controlled object; Writing the target code into the target string template to obtain a target string; In response to satisfying a trigger condition corresponding to the update function in the target character string, a target method corresponding to the target method identifier is obtained from the target runtime through the update function in the target character string.

3. The method according to claim 2, characterized in that The step of writing the target code into the target character string template to obtain the target character string comprises: The target code is filled into the target field in the target character string template to obtain the target character string.

4. The method according to claim 1, characterized in that: The step of generating a program set corresponding to the building block code according to the target method and the target code includes: The target method and the target code are compiled to obtain a program set corresponding to the building block code.

5. The method according to claim 1, characterized in that: After generating a program set corresponding to the building block code according to the target method and the target code, the method further includes: Create a dynamic object according to the target program set to obtain a target instance; A target runtime component for the method called by the building block code is generated according to the target instance.

6. The method according to claim 5, characterized in that: After generating a target runtime component for the method called by the building block code according to the target instance, the method further includes: The target runtime component is associated with the target controlled object, and the target runtime component is displayed.

7. The method according to claim 1, characterized in that: The running of the program set comprises: In response to the life cycle of the target controlled object starting, the program set is run.

8. The method according to claim 7, characterized in that: In response to the life cycle of the target controlled object starting, before running the program set, the method includes: Display an object display interface, wherein the object display interface includes a start control; In response to a trigger operation on the start control, determining that the life cycle of the target controlled object begins; In response to the life cycle of the target controlled object starting, after running the program set, the method further includes: The object display interface displays a screen showing the target controlled object running according to the program set.

9. The method according to claim 1, characterized in that: The step of obtaining the building block code for the target controlled object includes: In response to a selection operation on a preset building block code of the target controlled object, the preset building block code selected by the selection operation is determined as the building block code of the target controlled object.

10. The method according to claim 4, characterized in that: The method further comprises: If the compilation of the target method and the target code fails, an error message is output.

11. A device for running building block code, characterized in that: The device comprises: An acquisition module, used to acquire a building block code for a target controlled object; A translation module, used for translating the building block code into the target language format to obtain a target code, wherein the target code includes a target method identifier of a method called by the building block code; A determination module, configured to obtain a target method corresponding to the target method identifier from a target runtime corresponding to the target controlled object; the target runtime includes methods available for invocation by the target controlled object and method identifiers corresponding to each method; A generation module, used to generate a program set corresponding to the building block code according to the target method and the target code; The running module is used to run the program set so that the target controlled object can act according to the method called by the building block code.

12. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to execute the method according to any one of claims 1-10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 10.

14. A computer program product or a computer program, characterized in that The computer program product or computer program includes computer instructions, which are stored in a computer-readable storage medium; a processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method as described in any one of claims 1-10.