CN115576544A - Object instantiation method and device, storage medium and electronic device - Google Patents

Object instantiation method and device, storage medium and electronic device Download PDF

Info

Publication number
CN115576544A
CN115576544A CN202211158204.9A CN202211158204A CN115576544A CN 115576544 A CN115576544 A CN 115576544A CN 202211158204 A CN202211158204 A CN 202211158204A CN 115576544 A CN115576544 A CN 115576544A
Authority
CN
China
Prior art keywords
target
class
instantiation
instance
symbol table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211158204.9A
Other languages
Chinese (zh)
Inventor
路标
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd, Haier Uplus Intelligent Technology Beijing Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202211158204.9A priority Critical patent/CN115576544A/en
Publication of CN115576544A publication Critical patent/CN115576544A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The application discloses a method, a device, a storage medium and an electronic device for object instantiation, which relate to the technical field of smart homes, wherein the method for object instantiation comprises the following steps: acquiring a JavaScript object notation JSON code, wherein the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and an inheritance relationship between the classes; resolving the JSON code to load the target class from the JSON code; determining a target instantiation object corresponding to a target class in a target symbol table, wherein the target symbol table comprises the instantiation object corresponding to each class and identification information of each class, and the target symbol table is arranged in a memory management unit; and instantiating the target instantiation object.

Description

Object instantiation method and device, storage medium and electronic device
Technical Field
The present application relates to the field of computers, and in particular, to a method, an apparatus, a storage medium, and an electronic apparatus for instantiating an object.
Background
For many companies, the "hot update" capability of the application program almost becomes a rigid requirement, and through the "hot update", online fault repair, immediate online operation activities, new requirement release and the like can be realized without re-release of the application program.
The related art proposes an overheat updating scheme, which mainly includes the following ways:
the first method is as follows: and product replacement, namely issuing the compiled product to the client to replace the old product.
The second method comprises the following steps: cross-platform dynamic execution capabilities utilizing JavaScript.
The third method comprises the following steps: and (3) converting the Dart source code into DSL JSON, issuing a JSON file to a client, and dynamically executing the code by the client through a preset actuator.
But the first mode can only be applied to Android platforms and cannot be applied to other platforms; the mode is heavily dependent on the JS framework. The built JS framework has certain overhead in interpretation and execution, cross-platform communication between the Flutter and the JS is required to be frequently carried out in operation, and certain performance overhead is also generated. The third method cannot guarantee the consistency with the characteristics of the Dart language.
Disclosure of Invention
The embodiment of the invention provides a method, a device, a storage medium and an electronic device for instantiating an object, which are used for at least solving the problem that the execution of dynamic codes in the related art is relatively complex.
According to an embodiment of the invention, a method for instantiation of an object is provided, which comprises the following steps: acquiring a JavaScript object notation JSON code, wherein the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relations among the classes; analyzing the JSON code to load a target class from the JSON code; determining a target instantiation object corresponding to the target class in a target symbol table, wherein the target symbol table comprises instantiation objects corresponding to each class and identification information of each class, and the target symbol table is arranged in a memory management unit; and instantiating the target instantiation object.
According to another embodiment of the present invention, there is provided an apparatus for instantiation of an object, including: the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a JavaScript object notation JSON code, the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relations among the classes; the first analysis module is used for analyzing the JSON code so as to load a target class from the JSON code; a first determining module, configured to determine a target instantiation object corresponding to the target class in a target symbol table, where the target symbol table includes an instantiation object corresponding to each of the classes and identification information of each of the classes, and the target symbol table is set in a memory management unit; the first instantiation module is used for instantiating the target instantiation object.
In an exemplary embodiment, the first parsing module includes: a first determining unit, configured to determine a parent class inherited by the target class; and the first loading unit is used for loading the target class under the condition that the parent class is determined to be completely loaded.
In an exemplary embodiment, the apparatus further comprises: a first loading module, configured to load each class before searching for a target instance class object corresponding to the target class in a target symbol table; and the first storage unit is used for correspondingly storing each class and a corresponding preset instance class object to the target symbol table according to a distributed storage form.
In an exemplary embodiment, the apparatus further includes: and the first creating module is used for creating the target class in the Dart source code unit according to the preset grammar of the target class before the JavaScript object notation JSON code is obtained.
In an exemplary embodiment, the first determining module includes: a first searching unit, configured to search the target instantiation object corresponding to the target class in the target symbol table by using the identification information of the target class.
In an exemplary embodiment, the first instantiation module includes: a first creating unit, configured to create an object-oriented target instance object of the target class in the memory management unit; a first pointing unit, configured to point a meta-class of the object-oriented target instance object to the target instantiation object; and the first filling unit is used for filling fields in the object-oriented target instance object by using the information in the target instantiation object.
In an exemplary embodiment, the Dart source code unit further includes: and each instantiation object corresponding to each class points to the object-oriented instance object in the memory management unit.
In an exemplary embodiment, the object-oriented instance object includes at least one of: the type of the object-oriented instance object; the type of the parent class inherited by the object-oriented instance object; a list of properties of the object-oriented instance object.
In an exemplary embodiment, the type of the object-oriented instance object includes at least one of: a base data type; the type of the element tree constructed in the user interface toolkit Flutter, or the type of the element of the tag; a data state type of a stateful component; a stateful component type; a stateless component type.
In an exemplary embodiment, the structure of the classes includes at least one of: a name; a directly inherited parent class; a mix-in list, wherein the mix-in list is used to inject other classes of features; an interface list; constructing a method list; a method list, wherein the method list includes static methods and example methods; a list of static attributes; a list of instance attributes; type (b).
In an exemplary embodiment, the structure of each of the classes is disposed in the memory management unit and is associated with an object-oriented instance object in the memory management unit.
According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to, when executed, perform the steps of any of the method embodiments described above.
According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
According to the method, a JavaScript object notation JSON code is obtained, wherein the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relations among the classes; analyzing the JSON code to load a target class from the JSON code; determining a target instantiation object corresponding to the target class in a target symbol table, wherein the target symbol table comprises instantiation objects corresponding to each class and identification information of each class, and the target symbol table is arranged in a memory management unit; and instantiating the target instantiation object. In the method, the Dart source code unit and the memory management unit comprise the meta-class structure, so that the correctness and the efficiency of the interpreter in interpreting and executing the dynamic code can be ensured, the instantiation objects are searched through the target symbol table, a large number of searching processes can be saved, and the consistency with the Dart language characteristics is ensured. Therefore, the problem of complex execution of the dynamic code in the related art can be solved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
FIG. 1 is a diagram illustrating a hardware environment for a method of instantiation of an object according to an embodiment of the present application;
FIG. 2 is a flow diagram of a method of object instantiation in accordance with an embodiment of the present invention;
FIG. 3 is a schematic diagram of a meta class system according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the type of InstanceOop according to an embodiment of the invention;
fig. 5 is a block diagram of an apparatus for instantiation of an object according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be implemented in sequences other than those illustrated or described herein. Moreover, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to one aspect of an embodiment of the present application, a method of object instantiation is provided. The method for instantiating the object is widely applied to full-House intelligent digital control application scenes such as intelligent homes (Smart Home), intelligent homes, intelligent Home equipment ecology, intelligent Home (Intelligent House) ecology and the like. Alternatively, in the present embodiment, the method of instantiating the object may be applied to the hardware environment formed by the terminal device 102 and the server 104 shown in fig. 1. As shown in fig. 1, the server 104 is connected to the terminal device 102 through a network, and may be configured to provide a service (e.g., an application service) for the terminal or a client installed on the terminal, set a database on the server or independent of the server, and provide a data storage service for the server 104, and configure a cloud computing and/or edge computing service on the server or independent of the server, and provide a data operation service for the server 104.
The network may include, but is not limited to, at least one of: wired networks, wireless networks. The wired network may include, but is not limited to, at least one of: wide area networks, metropolitan area networks, local area networks, which may include, but are not limited to, at least one of the following: WIFI (Wireless Fidelity), bluetooth. Terminal equipment 102 can be but not limited to be PC, the cell-phone, the panel computer, intelligent air conditioner, intelligent cigarette machine, intelligent refrigerator, intelligent oven, intelligent kitchen range, intelligent washing machine, intelligent water heater, intelligent washing equipment, intelligent dish washer, intelligent projection equipment, intelligent TV, intelligent clothes hanger, intelligent (window) curtain, intelligence audio-visual, smart jack, intelligent stereo set, intelligent audio amplifier, intelligent new trend equipment, intelligent kitchen guarding equipment, intelligent bathroom equipment, intelligence robot of sweeping the floor, intelligence robot of wiping the window, intelligence robot of mopping the ground, intelligent air purification equipment, intelligent steam ager, intelligent microwave oven, intelligent kitchen is precious, intelligent clarifier, intelligent water dispenser, intelligent lock etc..
The following description will first discuss the related technical terms in this embodiment:
object Oriented Programming (op) refers to Object Oriented Programming (a computer Programming architecture).
Flutter: the method is a Google open source construction User Interface (UI) toolkit, helps developers to efficiently construct multi-platform exquisite applications through a set of code base, and supports mobile, web, desktop and embedded platforms.
The Interpreter, also known as an Interpreter, is a computer program that can translate a high-level programming language directly, line by line, into a form that can be run. The interpreter does not translate the whole program at a time, just like a 'man in the middle', and when the program is run, the program is converted into another language and then runs, so that the program running speed of the interpreter is slow. It runs immediately each time it translates a row of program statements, then translates the next row, then runs, and so on.
And (6) Dart: was developed by google as a computer programming language, and was later recognized as a standard by Ecma (Ecma-408). It is used for the development of the fields of web, server, mobile application, internet of things and the like. It is open source software under a loose open source license (modified BSD certificate). Dart is an object-oriented, class-defined, single-inheritance language. Its syntax is similar to the C language and can be translated into JavaScript, supported interfaces (interfaces), hybrids (mixins), abstract classes (abstract classes), materialized generalizations (differentiated genetics), optional types (optional type) and sound type system.
key-value: the distributed storage system has the advantages of high query speed, large data storage amount and high support for concurrency, is very suitable for query through a main key, but cannot perform complex condition query.
Instantiation: refers to the process of creating objects with classes referred to as instantiation in object-oriented programming.
Base class: in object-oriented design, class types, defined to contain the commonality of all entities, are referred to as "base classes".
JSON (JavaScript Object Notation, JS Object Notation): is a lightweight data exchange format.
runtime memory management, runtime refers to the state of a program running (cc or being executed). That is, when you open a program to run on a computer, that program is at run time. In some programming languages, certain reusable programs or instances are packaged or reconstructed into a "runtime". These instances may be linked or called by any program as they are running.
An embodiment of the present invention provides a method for instantiating an object, and fig. 2 is a flowchart of a method for instantiating an object according to an embodiment of the present invention, where as shown in fig. 2, the flowchart includes the following steps:
step S202, a JavaScript object notation JSON code is obtained, wherein the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relations among the classes;
step S204, analyzing the JSON code to load a target class from the JSON code;
step S206, determining a target instantiation object corresponding to the target class in a target symbol table, wherein the target symbol table comprises the instantiation object corresponding to each class and the identification information of each class, and the target symbol table is arranged in the memory management unit;
step S208, instantiate the target instantiation object.
Alternatively, the JSON code may be dynamic code.
Optionally, the memory management unit and the Dart source code unit may be units in a meta system, the structure of the meta system is shown in fig. 3, and the structure of a class is represented by InstanceClass in the meta system; the name field represents the name of the class; superClass represents a parent class directly inherited by the class and points to an InstanceClass object of the parent class; mixins represents a mixing list of the class and is an InstanceClass array; (mix-in "mixin" is a Dart language property, and by mixing in, properties of one class can be injected into another class); the instances represents the interface list of the implementation, and is an InstanceClass array; constractors represent a list of construction methods for the class; methods represent a list of methods of this class, including static methods and instance methods, static fields represent a list of static properties; fields represents the list of instance properties; the oopType indicates which type the instance object of the class belongs to (as shown in fig. 4).
Optionally, in the meta-class system, instanceOop is used to represent the instance object, metaClass represents the type of the object and is a reference to InstanceClass of the class object, parentsstance represents its parent class instance and is a reference to parent class instance InstanceOop, and fields represents the attribute list of the object.
As shown in fig. 4, instanceOop is classified into the following types:
ClayData is a basic data type;
constructing elements of an element tree or widget in the library element, namely Fluter;
ClayState is the data state of the stateful component;
ClayStateful Widget is a stateful component;
ClayStateless Widget is a stateless component.
Alternatively, it may be that the backend server converts the Dart source code into JSON code (e.g., DSL JSON code). The method can be implemented by the steps that the front-end APP obtains DSL JSON codes to analyze, and class loading is carried out.
The execution subject of the above steps may be a terminal, a server, a specific processor provided in the terminal or the server, or a processor or a processing device provided relatively independently from the terminal or the server, but is not limited thereto.
Through the steps, a JavaScript object notation JSON code is obtained, wherein the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relations among the classes; analyzing the JSON code to load a target class from the JSON code; determining a target instantiation object corresponding to the target class in a target symbol table, wherein the target symbol table comprises instantiation objects corresponding to each class and identification information of each class, and the target symbol table is arranged in a memory management unit; and instantiating the target instantiation object. In the method, the Dart source code unit and the memory management unit comprise the meta-class structure, so that the correctness and the efficiency of the interpreter in interpreting and executing the dynamic code can be ensured, the instantiation objects are searched through the target symbol table, a large number of searching processes can be saved, and the consistency with the Dart language characteristics is ensured. Therefore, the problem of complex execution of the dynamic code in the related art can be solved.
In one exemplary embodiment, parsing the JSON code to load the target class includes:
s1, determining a parent class inherited by a target class;
and S2, loading the target class under the condition that the parent class is determined to be loaded completely.
Optionally, the class loading process is a process of building an InstanceClass object. For example, when loading the Student class, the name is "Student", the parent class is "Person", and at this time, if the "Person" class is not loaded yet, the "Person" class is loaded preferentially, and then the "Student" class is loaded continuously.
In an exemplary embodiment, before looking up the target instance class object corresponding to the target class in the target symbol table, the method further includes:
s1, loading each class;
s1, correspondingly storing each class and a corresponding preset instance class object to a target symbol table according to a distributed storage mode.
Optionally, for example, after the class loading is completed, the InstanceClass object corresponding to each class is stored in the target symbol table in a key-value form, where key is the class name and value is the InstanceClass object.
In an exemplary embodiment, before obtaining the JavaScript object notation JSON code, the method further includes:
s1, creating a target class in a Dart source code unit according to a preset grammar of the target class.
As shown in fig. 3, a Student instance is created in the Dart source code through a Student () syntax, and the Dart source code unit includes three classes Object (base classes of all classes in the Dart language), person (self-defined class) and Student (self-defined class), where Person inherits from Object and Student inherits from Person.
In one exemplary embodiment, determining a target instantiation object corresponding to a target class in a target symbol table comprises:
s1, searching a target instantiation object corresponding to the target class in a target symbol table by using the identification information of the target class.
For example, in the memory management unit Runtime, through the "Student" symbol, the corresponding InstanceClass object is looked up in the symbol table.
In one exemplary embodiment, instantiating the target instantiation object includes:
s1, creating an object-oriented target instance object of a target class in a memory management unit;
s2, pointing the meta-class of the object-oriented target instance object to a target instantiation object;
and S3, filling fields in the object instance object facing the object by using the information in the object instantiation object.
For example, an InstanceOop object is constructed, metaClass of the InstanceOop object is pointed to the InstanceClass object, and other fields of the InstanceOop are filled according to other types of information in the InstanceClass.
In an exemplary embodiment, the Dart source code unit further includes:
and each class corresponds to an instantiation object, wherein the instantiation object corresponding to each class points to an object-oriented instance object in the memory management unit. For example, "Instance of Object", "Instance of Person", "Instance of Student" as shown in FIG. 3.
In one exemplary embodiment, the object-oriented instance object includes at least one of:
type of object-oriented instance object;
the type of the parent class inherited by the object-oriented instance object;
a list of properties of the object-oriented instance object.
For example, the Object-oriented Instance Object instanceOop as shown in FIG. 3 includes "Instance of Object", "Instance of Person", "Instance of Student", and "Instance of Student" each includes metaClass, parentionInstance, fields. The explanation of each attribute is described in detail in the above embodiments.
In one exemplary embodiment, the type of the object-oriented instance object includes at least one of:
a base data type;
the type of the element tree constructed in the user interface toolkit Flutter, or the type of the element of the tag;
a data state type of a stateful component;
a stateful component type;
a stateless component type.
For example, as shown in fig. 3, the type of the object-oriented instance object InstanceOop is: clayData, clayElement, flutter, clayState, clayStateUWidget, and ClayStateless Widget. The explanation of each type is described in detail in the above embodiments.
In one exemplary embodiment, the structure of the class includes at least one of:
a name;
a directly inherited parent class;
a blend list, wherein the blend list is used to inject other classes of features;
an interface list;
constructing a method list;
a method list, wherein the method list includes static methods and example methods;
a list of static attributes;
a list of instance attributes;
type (b).
For example, as shown in FIG. 3, instanceclass-like structures include: the name field represents the name of the class; superClass represents a parent class directly inherited by the class and points to an InstanceClass object of the parent class; mixins represents a mixing list of the class and is an InstanceClass array; (mix-in "mixin" is a Dart language property, and by mixing in, properties of one class can be injected into another class); the instances represents the interface list of the implementation, and is an InstanceClass array; the constraints represents the construction method list of the class, the methods represents the method list of the class, and static methods and instance methods static fields represent the static attribute list; fields represents the list of instance properties.
In an exemplary embodiment, the structure of each class is disposed in the memory management unit and is associated with an object-oriented instance object in the memory management unit, as specifically shown in fig. 3.
The present invention will now be described with reference to specific embodiments, which mainly include the design of meta-system, as shown in fig. 3, the design principle of meta-system includes:
1) And (3) loading of the class:
the Dart source code comprises three classes of Object (base classes of all classes in the Dart language), person (custom class) and Student (custom class), wherein the Person inherits the Object, the Student inherits the Object from the Person rear end, converts the Dart source code into DSL JSON front end App to obtain JSON and analyze the JSON, and the loading process of the class loading is the process of constructing an instanceClass Object. For example, when loading the Student class, the name is "Student", the parent class is "Person", and at this time, if the "Person" class is not loaded yet, the "Person" class is loaded preferentially, and then the "Student" class is loaded continuously. After the class loading is completed, the InstanceClass object corresponding to each class is stored into the symbol table in a key-value form, wherein the key is the class name, and the value is the InstanceClass object.
2) Instantiation:
in the Dart source code, a Student instance runtime is created through Student () syntax, a Student symbol is searched in a symbol table, a corresponding instanceClass object is searched to construct an instanceOop object, a metaClass of the instanceOop object points to the instanceClass object, and other fields of the instanceOop are filled according to other types of information in the instanceClass.
In summary, the key point of this embodiment lies in the structural design of the meta-system in the Runtime (Runtime) system in the Flutter dynamic technology, and the structure shown in fig. 3 can ensure the correctness and efficiency of the interpreter when interpreting and executing the dynamic code, and save a large number of search processes by directly referring to the substitute symbol for searching, thereby effectively improving the execution efficiency, and simultaneously ensuring the consistency with the characteristics of Dart language. Moreover, when an instance object is created, the embodiment creates an instance object of each node in the inheritance chain according to the inheritance information of the class and establishes the inheritance relationship, so that the parent class property is not filled into the subclass, and the complexity of constructing an instance is greatly reduced.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention or portions thereof contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
In this embodiment, a device for instantiating an object is further provided, where the device is used to implement the foregoing embodiment and preferred embodiments, and the description of the device that has been already described is omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 5 is a block diagram of an apparatus for instantiating an object according to an embodiment of the present invention, as shown in fig. 5, the apparatus including:
a first obtaining module 52, configured to obtain a JavaScript object notation JSON code, where the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit includes multiple classes and an inheritance relationship between the multiple classes;
a first parsing module 54, configured to parse the JSON code to load a target class from the JSON code;
a first determining module 56, configured to determine a target instantiated object corresponding to the target class in a target symbol table, where the target symbol table includes instantiated objects corresponding to each of the classes and identification information of each of the classes, and the target symbol table is set in the memory management unit;
a first instantiation module 58, configured to instantiate the target instantiation object.
In an exemplary embodiment, the first parsing module includes:
a first determining unit, configured to determine a parent class inherited by the target class;
and the first loading unit is used for loading the target class under the condition that the parent class is determined to be completely loaded.
In an exemplary embodiment, the apparatus further includes:
a first loading module, configured to load each class before searching for a target instance class object corresponding to the target class in a target symbol table;
and the first storage unit is used for correspondingly storing each class and a corresponding preset instance class object to the target symbol table according to a distributed storage mode.
In an exemplary embodiment, the apparatus further includes:
and the first creating module is used for creating the target class in the Dart source code unit according to the preset grammar of the target class before the JavaScript object notation JSON code is obtained.
In an exemplary embodiment, the first determining module includes:
a first searching unit, configured to search the target instantiation object corresponding to the target class in the target symbol table by using the identification information of the target class.
In an exemplary embodiment, the first instantiation module includes:
a first creating unit, configured to create an object-oriented target instance object of the target class in the memory management unit;
a first pointing unit, configured to point a meta-class of the object-oriented target instance object to the target instantiation object;
and the first filling unit is used for filling fields in the object-oriented target instance object by using the information in the target instantiation object.
In an exemplary embodiment, the Dart source code unit further includes:
and each instantiation object corresponding to each class points to the object-oriented instance object in the memory management unit.
In an exemplary embodiment, the object-oriented instance object includes at least one of:
the type of the object-oriented instance object;
the type of the parent class inherited by the object-oriented instance object;
a list of properties of the object-oriented instance object.
In an exemplary embodiment, the type of the object-oriented instance object includes at least one of:
a base data type;
the type of the element tree constructed in the user interface toolkit Flutter, or the type of the element of the tag;
a data state type of a stateful component;
a stateful component type;
a stateless component type.
In an exemplary embodiment, the structure of the classes includes at least one of:
a name;
a directly inherited parent class;
a mix-in list, wherein the mix-in list is used to inject other classes of features;
an interface list;
constructing a method list;
a method list, wherein the method list includes static methods and example methods;
a list of static attributes;
a list of instance attributes;
type (b).
In an exemplary embodiment, the structure of each of the classes is disposed in the memory management unit and is associated with an object-oriented instance object in the memory management unit.
The foregoing is only a preferred embodiment of the present application and it should be noted that, as will be apparent to those skilled in the art, numerous modifications and adaptations can be made without departing from the principles of the present application and such modifications and adaptations are intended to be considered within the scope of the present application.

Claims (14)

1. A method of object instantiation, comprising:
acquiring a JavaScript object numbered notation JSON code, wherein the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relationships among the classes;
analyzing the JSON code to load a target class from the JSON code;
determining a target instantiation object corresponding to the target class in a target symbol table, wherein the target symbol table comprises instantiation objects corresponding to each class and identification information of each class, and the target symbol table is arranged in a memory management unit;
and instantiating the target instantiation object.
2. The method of claim 1, wherein parsing the JSON code to load the target class comprises:
determining a parent class inherited by the target class;
and loading the target class under the condition that the parent class is determined to be loaded completely.
3. The method of claim 1, wherein prior to looking up a target instance class object corresponding to the target class in a target symbol table, the method further comprises:
loading each of the classes;
and correspondingly storing each class and the corresponding preset instance class object to the target symbol table according to a distributed storage form.
4. The method of claim 1, wherein before obtaining JavaScript object notation JSON code, the method further comprises:
and creating the target class in the Dart source code unit according to the preset grammar of the target class.
5. The method of claim 1, wherein determining a target instantiation object corresponding to the target class in a target symbol table comprises:
and searching the target instantiation object corresponding to the target class in the target symbol table by using the identification information of the target class.
6. The method of claim 1, wherein instantiating the target instantiation object comprises:
creating an object-oriented target instance object of the target class in the memory management unit;
pointing the meta-class of the object-oriented target instance object to the target instantiation object;
and filling fields in the object-oriented target instance object with the information in the target instantiation object.
7. The method of claim 1, wherein the Dart source code unit further comprises:
and each instantiation object corresponding to each class, wherein each instantiation object corresponding to each class points to an object-oriented instance object in the memory management unit.
8. The method of claim 7, wherein the object-oriented instance object comprises at least one of:
a type of the object-oriented instance object;
the type of the parent class inherited by the object-oriented instance object;
a list of properties of the object-oriented instance object.
9. The method of claim 7, wherein the type of the object-oriented instance object comprises at least one of:
a base data type;
the type of the element tree constructed in the user interface toolkit Flutter, or the type of the element of the tag;
a data state type of a stateful component;
a stateful component type;
a stateless component type.
10. The method of claim 1, wherein the structure of the class comprises at least one of: a name;
a directly inherited parent class;
a drop-in list, wherein the drop-in list is used to inject other classes of features;
an interface list;
constructing a method list;
a method list, wherein the method list includes static methods and instance methods;
a list of static attributes;
a list of instance attributes;
type (b).
11. The method of claim 10, wherein the structure of each class is located in the memory management unit and is associated with an object-oriented instance object in the memory management unit.
12. An apparatus for instantiation of an object, comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a JavaScript object notation JSON code, the JSON code is obtained by converting a target Dart source code in a Dart source code unit based on a computer programming language, and the Dart source code unit comprises a plurality of classes and inheritance relations among the classes;
the first analysis module is used for analyzing the JSON code so as to load a target class from the JSON code;
a first determining module, configured to determine an instantiated target object corresponding to the target class in a target symbol table, where the target symbol table includes instantiated objects corresponding to each of the classes and identification information of each of the classes, and the target symbol table is set in a memory management unit;
the first instantiation module is used for instantiating the target instantiation object.
13. A computer-readable storage medium, comprising a stored program, wherein the program when executed performs the method of any of claims 1 to 11.
14. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 11 by means of the computer program.
CN202211158204.9A 2022-09-22 2022-09-22 Object instantiation method and device, storage medium and electronic device Pending CN115576544A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211158204.9A CN115576544A (en) 2022-09-22 2022-09-22 Object instantiation method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211158204.9A CN115576544A (en) 2022-09-22 2022-09-22 Object instantiation method and device, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN115576544A true CN115576544A (en) 2023-01-06

Family

ID=84581574

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211158204.9A Pending CN115576544A (en) 2022-09-22 2022-09-22 Object instantiation method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN115576544A (en)

Similar Documents

Publication Publication Date Title
US9372688B1 (en) Automatic discovery of a JavaScript API
US10209968B2 (en) Application compiling
US20160139894A1 (en) Method for constructing a graph data structure
US10949171B1 (en) Tools, mechanisms, and processes for transforming modules for an application into pluggable modules
US20160103660A1 (en) Metadata based eventing
CN108920566B (en) Method, device and equipment for operating SQLite database
CN112506602A (en) Page generation method and device, electronic equipment and computer readable medium
CN110727429B (en) Front-end page generation method, device and equipment
CN113296758B (en) Front-end component library construction method and device and storage medium
CN112818176B (en) Data processing method, device, equipment and storage medium
US11275567B1 (en) Making communication interfaces pluggable by using mechanisms comprising of exchange/broker for communication interfaces
Miravet et al. Framework for the declarative implementation of native mobile applications
US10802855B2 (en) Producing an internal representation of a type based on the type's source representation
CN112068879A (en) Method and device for constructing client application development framework based on configuration
US10922107B2 (en) Apparatus and method for realizing runtime system for programming language
CN115576544A (en) Object instantiation method and device, storage medium and electronic device
Franchi A domain specific language approach for agent-based social network modeling
CN115964042A (en) Menu generation method and device, storage medium and electronic equipment
CN115576602A (en) Method for realizing entity class conversion, storage medium and electronic device
CN111124386B (en) Animation event processing method, device, equipment and storage medium based on Unity
CN115047778A (en) Control method and device for intelligent equipment, storage medium and electronic device
CN115756596A (en) Object calling method and device depending on package, storage medium and electronic device
CN109542413B (en) Data processing method and device, storage medium and electronic device
CN113971028A (en) Data processing method, device, equipment, storage medium and computer program product
CN116112353A (en) Method, control device and computer readable storage medium for gateway modification request body

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination