Disclosure of Invention
In view of the foregoing, it is desirable to provide a compiling method, a calling method, an apparatus, a device, and a program product that can classify parameters at compile time, simplify encoding, and improve the running efficiency of classifying parameters.
In a first aspect, the present application provides a compiling method for classification parameters, the method comprising:
Acquiring a parameter wrapper obtained by packaging parameters to be called at the compiling period, wherein the parameter wrapper comprises a parameter type;
classifying parameters to be called packaged by the parameter packager through a recursive template function and a parameter type at the compiling period to obtain at least one multi-element group, instantiating the at least one multi-element group to obtain each instantiated parameter collector, and storing one type of parameters to be called in each multi-element group.
In one embodiment, before the obtaining the parameter wrapper obtained by packaging the parameter to be invoked, the method includes:
and packaging the parameters to be called to obtain a parameter wrapper comprising the reference information of the parameters to be called and the parameter types, wherein the parameter types are reserved only in compiling.
In one embodiment, the classifying the parameters to be invoked packaged by the parameter wrapper through the recursive template function and the parameter type to obtain at least one multi-tuple, and instantiating the at least one multi-tuple to obtain each instantiated parameter collector includes:
Based on the parameter wrapper, storing parameters to be called into a target parameter part;
Acquiring a current parameter to be called from the target parameter part, and instantiating the tuple part to obtain a current instantiated parameter collector after adding the current parameter to be called to the tuple part based on the parameter type;
generating a next parameter calling function based on the remaining parameters to be called of the target parameter part;
and acquiring a next parameter to be called from the target parameter part based on the next parameter calling function as a current parameter to be called, continuously executing the step of adding the current parameter to be called to the tuple part based on the parameter type, instantiating the tuple part to obtain a current instantiated parameter collector until the parameter to be called of the target parameter part is classified, generating a termination condition, and acquiring each instantiated parameter collector.
In one embodiment, the adding the current parameters to be invoked to the tuple portion based on the parameter type includes:
When the current parameter to be called is a first parameter to be called, adding the current parameter to be called into an empty tuple of the tuple part based on the parameter type of the current parameter to be called to obtain a first target tuple, and modifying the parameter type of the first target tuple;
When the current parameter to be called is not the first parameter to be called and the parameter types of the tuples in the instantiated tuple part are different from the type of the current parameter to be called, adding the current parameter to be called into a new empty tuple of the tuple part to obtain a second target tuple based on the parameter type of the current parameter to be called, and modifying the parameter type of the second target tuple;
and adding the current parameter to be called into a third target tuple in the instantiated tuple part when the current parameter to be called is not the first parameter to be called and the parameter type of the third target tuple in the instantiated tuple part is the same as the type of the current parameter to be called.
In one embodiment, the method further comprises:
instantiating a user program for invoking each instantiated parameter collector;
Instantiating calling functions of corresponding types based on the at least one multi-element group to obtain instantiated parameter executors, wherein the calling functions in the instantiated parameter executors are used for calling the parameters to be called of the corresponding types;
compiling results are obtained based on the instantiated user program, the instantiated parameter collector and the instantiated parameter executor.
In one embodiment, instantiating the calling function of the corresponding type based on the at least one multi-element group to obtain each instantiated parameter executor includes:
Acquiring a current multi-tuple from the tuple part, and calling a template function in a parameter executor based on the current multi-tuple;
instantiating the template function based on the current multi-tuple to obtain a calling function, and obtaining an instantiated parameter executor based on the calling function;
And acquiring the next multi-tuple as the current multi-tuple, and continuing to execute the step of calling the template function in the parameter executor through the current multi-tuple until the multi-tuple is processed.
In one embodiment, before instantiating the user program, the method further includes:
configuring the calling sequence and calling condition of each instantiated parameter executor in the user program;
And acquiring the configured user program.
In a second aspect, the present application further provides a classification parameter calling method, where the method includes:
and calling each instantiated parameter collector obtained based on the compiling method of the classification parameters in any one embodiment to obtain at least one multi-element group, wherein each multi-element group stores a collected class of parameters to be called, and the types of the parameters to be called corresponding to each multi-element group are different.
In one embodiment, the invoking each instantiated parameter collector results in at least one tuple comprising:
acquiring a current parameter to be called, and calling a current instantiated parameter collector to process the current parameter to be called to obtain a current multi-element group;
acquiring a next parameter collector as a currently instantiated parameter collector;
And transmitting the remaining parameters to be called to the current instantiated parameter collector, and continuously executing the step of acquiring the current parameters to be called until the termination condition of the instantiated parameter collector is met, and acquiring the obtained multi-element group.
In one embodiment, the invoking each instantiated parameter collector to obtain at least one tuple further includes:
And circularly calling each instantiated parameter collector through the instantiated user program to obtain at least one multi-element group, wherein the instantiated user program is triggered based on the interface calling instruction after receiving the interface calling instruction.
In one embodiment, the method further comprises:
And sequentially calling each instantiated parameter executor through the instantiated user program, and processing the multiple groups of the corresponding parameter types to obtain a calling result.
In one embodiment, the termination condition of the instantiated parameter collector is the parameter collector termination condition function, and the parameter collector termination condition function is generated after all parameters to be called of the target parameter part are classified when the parameter collector compiles.
In a third aspect, the present application also provides a compiling apparatus for classifying parameters, the apparatus comprising:
The parameter wrapper obtaining module is used for obtaining a parameter wrapper obtained by packaging parameters to be called at the compiling period, and the parameter wrapper comprises a parameter type;
and the parameter collector instantiation module is used for classifying parameters to be called, which are packaged by the parameter wrapper, through a recursive template function and a parameter type at the compiling period to obtain at least one multi-element group, instantiating the at least one multi-element group to obtain each instantiated parameter collector, and storing one type of parameters to be called in each multi-element group.
In a fourth aspect, the present application further provides a classification parameter calling device, where the device includes:
And the parameter collector calling module is used for calling the instantiated parameter collectors obtained by the compiling device based on the classification parameters in any one embodiment to obtain at least one multi-element group, wherein the collected parameters to be called are stored in each multi-element group, and the types of the parameters to be called corresponding to each multi-element group are different.
In a fifth aspect, the present application also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of the method described in any one of the embodiments above when the computer program is executed by the processor.
In a sixth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method described in any of the embodiments above.
The compiling method, the calling method, the device, the equipment and the program product for classifying parameters, the compiling method, the compiling device, the calling device, the computer equipment and the computer program product for classifying parameters acquire the parameter wrapper obtained by packaging the parameters to be called at the compiling period, the parameter wrapper comprises a parameter type, the parameters to be called packaged by the parameter wrapper are classified by a recursive template function and the parameter type at the compiling period to obtain at least one multi-element group, the at least one multi-element group is instantiated to obtain each instantiated parameter collector, and one class of parameters to be called is stored in each multi-element group, so that the classification of the parameters to be called is realized at the compiling period, the coding is simplified, and the running efficiency is improved.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The compiling method of the classification parameters provided by the embodiment of the application can be applied to an application environment shown in figure 1. The compiler in this embodiment includes a parameter wrapper, a parameter collector, a parameter executor, and a logic executor. The parameter wrapper is used for adding additional compiling time information for the parameters to be called, wherein the compiling time information comprises parameter types, and the parameter types are used for calling parameter classification. After the calling parameters are packaged, the parameters are transferred to a parameter collector for processing. The parameter collector is a recursive template function which classifies one parameter to be called at a time and recursively transmits the remaining parameters to be called to itself until all parameters to be called are classified, and the termination recursion condition of the parameter collector is satisfied. At this time, the parameter set is stored in the tuples, and the parameter collector satisfying the condition of terminating the recursion passes the target type of tuples to the parameter executor. At this point, the template-based meta-programming method has recursively derived all parameter types and all calling functions that ultimately need to be called.
In the actual code running process, the parameter executor can be dynamically bound with specific calling functions. The logic executor is responsible for calling the parameter executor method according to the expected logic of the user, and the method can change the execution sequence or select not to call in some cases, so that the binding between parameter transmission and calling is stripped, and the instantiated logic executor is an instantiated user program for facilitating understanding. The compiler realizes parameter compiling time classification, and the logic operation determines parameter calling.
In an exemplary embodiment, as shown in fig. 2, a compiling method of classification parameters is provided, including the following steps 202 to 204. Wherein:
S202, acquiring a parameter wrapper obtained by packaging parameters to be called at the compiling period, wherein the parameter wrapper comprises a parameter type.
Parameter wrappers are used to package different types of parameters and may be referred to as parameter wrapper classes. The application corresponding to the target is actually stored in the parameter wrapper, and the parameter type is reserved only in the compiling period, and the parameter wrapper type information can be also called wrapper type information.
In one optional embodiment, before the parameter wrapper obtained by packaging the parameter to be invoked is obtained, the parameter wrapper comprises packaging the parameter to be invoked to obtain the parameter wrapper comprising the reference information of the parameter to be invoked and the parameter type, wherein the parameter type is only reserved in compiling.
Specifically, referring to fig. 3, fig. 3 is a schematic diagram of parameter wrapper compiling information and a memory layout in an embodiment, in which the wrapper class conforms to a zero-overhead abstract design rule, and the memory layout only includes reference information of a parameter to be invoked, for example, an address of the parameter to be invoked, so that the memory occupancy is only that the address of the parameter to be invoked occupies memory, and the runtime overhead is equal to the parameter to be invoked, that is, the memory occupancy in the runtime is the parameter to be invoked. And only parameter wrapper class information, i.e. parameter types, is reserved at compile time, which are compile symbols, no memory occupancy, and only exist at compile time.
S204, classifying parameters to be called packaged by the parameter wrapper through a recursive template function and a parameter type at the compiling period to obtain at least one multi-element group, instantiating the at least one multi-element group to obtain each instantiated parameter collector, and storing one type of parameters to be called in each multi-element group.
The recursive template function is realized based on a template element programming technology, and is used for classifying and collecting parameters to be called packaged by different parameter packagers and calling corresponding processing functions.
Alternatively, the recursive template function is a variable parameter template that may receive any number of parameters to be invoked. Referring to fig. 4, fig. 4 is a schematic diagram of a recursive template function in one embodiment, where the parameter list includes two parts, a first part is a tuple part and a second part is a target parameter part.
Where the tuple portion implements parameter collection to be invoked, the tuple portion of the recursive template function may include at least one tuple (i.e., generic tuple 1, generic tuple 2, etc. in fig. 4), optionally the number of tuples may be set at initialization, the number of tuples being based on the number of parameter types corresponding to the parameter wrapper, e.g., equal to each other. Each tuple in the tuple portion is responsible for the collection of one parameter type. The tuple changes its type when the parameters are collected, so this operation must be implemented using a compile-time syntax. The tuple can comprise a tuple and a tuple, wherein the tuple stores one parameter, the tuple stores a plurality of parameters, and the tuple store the same type of parameters to be called.
The target parameter part is used for dividing the parameter to be called into a parameter to be called (i.e. the target parameter in fig. 4) of the current processing and a parameter to be called of the next processing (i.e. the remaining parameters to be processed in fig. 4) of the recursive call. Because in the recursive template function only one classification of parameters to be invoked is processed at a time. When each specific parameter to be called is processed, the condition processing should be realized by using the compiling period grammar, so that useless code expansion generated by unnecessary code calling is avoided. The parameters to be called in the target parameter portion may be of various types, for example, the parameters to be called may be of the same type, or the parameters to be called may be of different types. Wherein the number of types of parameters to be invoked is less than or equal to the number of tuples of the tuple portion.
The recursive template function in this embodiment classifies only one parameter to be invoked at a time, and obtains a corresponding instantiated parameter collector, specifically, after classifying the parameter to be invoked into a corresponding tuple, instantiating the tuple to obtain a corresponding instantiated parameter collector, and finally obtaining a plurality of instantiated parameter collectors to complete classification of the parameter to be invoked, and then, when running, directly invoking the instantiated parameter collectors, so as to obtain the classified parameter to be invoked.
The compiling method of the classifying parameters obtains the parameter wrapper obtained by packaging the parameters to be invoked at the compiling period, the parameter wrapper comprises the parameter types, the parameters to be invoked packaged by the parameter wrapper are classified by the recursive template function and the parameter types at the compiling period to obtain at least one multi-element group, the at least one multi-element group is instantiated to obtain each instantiated parameter collector, and one class of parameters to be invoked is stored in each multi-element group, so that the classification of the parameters to be invoked is realized at the compiling period, the coding is simplified, and the running efficiency is improved.
In an alternative embodiment, as shown in connection with fig. 5, fig. 5 is a flowchart illustrating an exemplary step of instantiating a parameter collector in an embodiment, where the step of categorizing parameters to be invoked in a parameter wrapper by a recursive template function and a parameter type to obtain at least one tuple, and instantiating the at least one tuple to obtain each instantiated parameter collector includes:
s502, storing parameters to be called into a target parameter part based on the parameter wrapper.
The parameters to be invoked packaged by each parameter wrapper are stored in a target parameter portion, and as described in connection with fig. 6, fig. 6 is a schematic diagram of a type of parameter to be invoked, where the target parameter portion of the parameter list includes each parameter wrapper class, according to an embodiment. Two types of parameter wrappers are included in FIG. 6, namely parameter wrapper A and parameter wrapper B, parameter 1 int and parameter 2double belong to the same parameter type, and parameter 3 bol belongs to another parameter type.
S504, acquiring a current parameter to be called from the target parameter part, and after adding the current parameter to be called to the tuple part based on the parameter type, instantiating the tuple part to obtain a current instantiated parameter collector.
Wherein, in general, the null tuple is one of the entries called by default for the first recursion. For example, the initialized tuple part is recursively called, the current parameters to be called are obtained from the target parameter part, and the current parameters to be called are added to the tuple part based on the parameter type to realize the recursion call, and the tuple part is transformed into various types of tuples. A plurality of groups, i.e. a plurality of objects with the same type of parameters to be called collected for temporary storage. The type of transformation is also a main feature of interface element programming and distinguishing from common runtime code, and any type of transformation cannot be realized through runtime code in static type system languages.
The recursive template function will be classified according to the type provided by the parameter packager, which requires that the incoming parameters be parameter packaged or unwrapped. The wrapped parameters retain the original data references and are additionally accompanied by specific wrapper class information, i.e., parameter types. After the recursive template function performs type comparison on the first parameter to be called, the parameter is determined to be connected in a specific tuple according to the comparison result, and then the tuple part is instantiated to obtain a corresponding instantiated parameter collector.
The method comprises the steps of adding a current to-be-called parameter to a tuple part based on a parameter type, wherein the method comprises the steps of obtaining a first target tuple by adding the current to-be-called parameter to an empty tuple of the tuple part based on the parameter type of the current to-be-called parameter when the current to-be-called parameter is the first to-be-called parameter, and modifying the parameter type of the first target tuple, and adding the current to-be-called parameter to a new empty tuple of the tuple part based on the parameter type of the current to-be-called parameter when the current to-be-called parameter is not the first to-be-called parameter and the parameter type of each tuple in the instantiated tuple part is different from the parameter type of the current to-be-called parameter when the current to-be-called parameter is not the first to-be-called parameter, and the current to-be-called parameter is the same as the parameter type of the current to-be-called parameter.
And under the condition that the current parameter to be called is the first parameter to be called, directly storing the current parameter to be called into a first empty tuple of the tuple part to obtain a first target tuple, and modifying the parameter type of the first target tuple.
And if the current parameter to be called is not the first parameter to be called, determining whether a third target tuple with the same parameter type as the current parameter to be called exists in the target tuple part, if so, directly adding the parameter to be called into the third target tuple, and if not, storing the current parameter to be called into a second empty tuple of the tuple part to obtain a second target tuple, and modifying the parameter type of the second target tuple.
S506, generating a next parameter calling function based on the remaining parameters to be called of the target parameter part.
S508, obtaining a next parameter to be called from the target parameter part based on the next parameter calling function as a current parameter to be called, continuously executing the step of adding the current parameter to be called to the tuple part based on the parameter type, instantiating the tuple part to obtain a current instantiated parameter collector until the parameters to be called of the target parameter part are classified, generating a termination condition, and obtaining the instantiated parameter collectors.
After the current parameters to be called are processed, the recursive template function generates a next parameter calling function based on the remaining parameters to be called in the target parameter part, then acquires the next parameter to be called from the target parameter part based on the next parameter calling function as the current parameters to be called, and continues to execute the steps. And finally, after all parameters to be called of the target parameter part are classified, generating a termination condition, wherein the recursive termination function is responsible for reserving the parameters to be called transmitted in a recursion mode. The recursive template termination function transfers the collected classified parameters to be called to the corresponding functions in the parameter executor.
For ease of understanding, as shown in connection with FIG. 7, FIG. 7 is a workflow diagram of tuple type transformation with recursive call type in one embodiment. The method comprises the steps of firstly using a zero-tuple A and a zero-tuple B to instantiate a parameter collector, then processing a first parameter to be invoked, changing the zero-tuple A into a tuple A1tupe < int > according to a parameter type, then using a tuple A1 and a zero-tuple B to instantiate the parameter collector, acquiring the next parameter based on a parameter invoking function, namely processing the 2 nd parameter to be invoked, changing the tuple A1 into a tuple A2tupe < int, double > according to the parameter type, using the tuple A2 and the zero-tuple B to instantiate the parameter collector, then continuing processing the 3 rd parameter, changing the zero-tuple B into a tuple B1tupe < bool > according to the parameter type, then using the tuple A2 and the tuple B1 to instantiate the parameter collector, entering a termination condition after no parameter is processable, and subsequently using the tuple A2 and the tuple B1 to instantiate the parameter executor.
In the above embodiment, the collection of the compile-time classification of the different types of parameters is realized by the template element programming technology, and the more general function calling method of parameter binding delay calling is realized. The method improves maintainability and readability of codes, reduces logic overhead of parameter classification to a compiling period, does not need running overhead, and has wide application prospect in library programming.
In one optional embodiment, the method further comprises the steps of instantiating a user program, wherein the user program is used for calling each instantiated parameter collector, instantiating calling functions of corresponding types based on at least one multi-element group to obtain each instantiated parameter executor, wherein the calling functions in each instantiated parameter executor are used for calling parameters to be called of corresponding types, and obtaining compiling results based on the instantiated user program, each instantiated parameter collector and each instantiated parameter executor.
Wherein the user program may be for defining the execution order of the subject logic, invoking the instantiated parameter collector and the instantiated parameter executor, respectively, according to the designer's predetermined logic. The designer may design the execution logic as desired.
The parameter executor is a function for processing the classified parameters to be called, and the parameter executor can store a function pointer and transfer the classified parameters to be called to the corresponding calling function through the function pointer, so that the parameters to be called can be processed through the calling function.
The parameter executor parameter acceptance comprises any number and any type of tuples, unpacks the tuples inside the parameter executor and transmits the parameters to the target calling function, so that the compiling period and the running period calling are flexibly supported.
In this embodiment, the instantiated user program may call each instantiated parameter collector in a circulating manner to implement classification of parameters, and subsequently call each instantiated parameter executor corresponding to each parameter type to process the classified parameter to be called, so as to complete call of the parameter to be called.
In one optional embodiment, before instantiating the user program, the method further comprises the steps of configuring the calling sequence and the calling condition of each instantiated parameter executor in the user program, and acquiring the configured user program.
The user program in this embodiment may invoke an instantiated parameter actuator. The call sequence of the instantiated parameter executors is the call sequence of each instantiated parameter executor, and the call sequence of each parameter executor can be defined in the user program. The calling condition comprises that the instantiated parameter executor is called or not called, and the calling condition of each parameter executor can be set in the user program.
The method can change the calling sequence of the parameter executor or select that the parameter executor does not call under certain conditions, thereby stripping the binding of parameter transmission and calling.
In one alternative embodiment, the step of instantiating the calling function of the corresponding type to obtain each instantiated parameter executor based on at least one tuple comprises the steps of obtaining a current tuple from a tuple part and calling a template function in the parameter executor based on the current tuple, instantiating the template function based on the current tuple to obtain a calling function and obtaining an instantiated parameter executor based on the calling function, obtaining a next tuple as the current tuple, and continuing to execute the step of calling the template function in the parameter executor through the current tuple until all the tuples are processed.
Specifically, in conjunction with fig. 8, fig. 8 is a flowchart of a function-specific procedure for parameter transfer of a parameter executor multi-tuple, where the multi-tuple portion includes a plurality of multi-tuples, each multi-tuple is called by a calling function, so that a template function inside the parameter executor can be called by using a specific multi-tuple, for example, a template function inside the parameter executor is called based on a current multi-tuple, for example, a function pointer inside the parameter executor is determined based on the current multi-tuple, then a template function inside the parameter executor is called based on the function pointer, a calling function is obtained based on the current multi-tuple, for example, the parameter executor instantiates a function supporting the multi-tuple, the parameter executor stores the packaged calling function, and then processes the next multi-tuple until each multi-tuple is processed, that is, each instantiated parameter executor is stored as the specific calling function, and instantiation of each parameter executor is achieved.
For ease of understanding, fig. 9 and 10 are combined, where fig. 9 is a compile-time flow diagram in one embodiment, and fig. 10 is a schematic diagram of processing different types of parameters by a template element programming technique in one embodiment.
In fig. 9, at compile time, parameters to be invoked are first packaged to obtain parameter wrappers, each parameter wrapper includes a parameter type and a reference to the parameters to be invoked, and the parameter type exists only at the compile time and is a compile symbol.
Then compiling the current target interface, instantiating the user program, then instantiating a specific parameter collector, generating a target calling function of the next parameter, instantiating the parameter executor based on the multiple groups obtained by the last instantiated parameter collector until the termination condition of the parameter collector is met, judging whether all interfaces are compiled completely, if not, acquiring the next interface, continuing the compiling process, namely instantiating the user program and the like, so as to complete the compiling of the interfaces.
In connection with fig. 10, first, a parameter wrapper packages parameters to be invoked to obtain parameter wrappers corresponding to the parameters to be invoked, where the parameter wrappers include parameter types. The user program is then instantiated for the first time, so that a logic executor is obtained, that is, the instantiated compile-time objective function C is obtained, that is, the instantiated user program, wherein the objective function C is also the user program.
Instantiating the compiling period objective function cluster D for the second time to finally obtain each instantiated parameter collector, wherein the objective function cluster D comprises each parameter collector for parameter classification to be called, according to the method, the parameters to be invoked corresponding to the parameter wrappers are classified in sequence until the termination condition of the parameter collector is met, and the final tuple cluster An and tuple cluster Bm are obtained. The procedure of recursive call is shown in fig. 7, and will not be described here.
The third instantiation is a parameter executor, that is, the compile-time objective functions E and F, where only the parameter executor includes two objective functions E and F in the present application is described as an example, and in other embodiments, the number of objective functions corresponding to the parameter executor may be other values, which is not limited in detail herein.
In an exemplary embodiment, as shown in fig. 11, a method for invoking classification parameters is provided, including the following step 1102. Wherein:
And S1102, calling the instantiated parameter collectors to obtain at least one multi-element group, wherein each multi-element group stores a collected type of parameters to be called, and the types of the parameters to be called corresponding to each multi-element group are different.
The embodiment is a processing procedure in the running process, and when in the running process, each instantiated parameter collector is called to obtain at least one multi-tuple, and because each instantiated parameter collector is used for classifying one parameter to be called, when in the running process, the instantiated parameter collectors are executed in sequence, so that the classification of the calling parameters can be realized.
The result of the classification is at least one multi-element group, each multi-element group can comprise at least one parameter to be called, and the types of the parameters to be called corresponding to each multi-element group are different.
The parameter wrapper obtained by packaging the parameters to be called is obtained at the compiling period, the parameter wrapper comprises the parameter types, the parameters to be called packaged by the parameter wrapper are classified through the recursive template function and the parameter types at the compiling period to obtain at least one multi-element group, the at least one multi-element group is instantiated to obtain each instantiated parameter collector, and one class of parameters to be called is stored in each multi-element group, so that the classification of the parameters to be called is realized at the compiling period, the parameter collectors are directly called to obtain the parameter classification result at the running period, the coding is simplified, and the running efficiency is improved.
In one optional embodiment, calling each instantiated parameter collector to obtain at least one multi-element group comprises the steps of obtaining a current parameter to be called, calling the current instantiated parameter collector to process the current parameter to be called to obtain a current multi-element group, obtaining a next parameter collector to serve as the current instantiated parameter collector, transmitting the remaining parameter to be called to the current instantiated parameter collector, and continuing to execute the step of obtaining the current parameter to be called until the termination condition of the instantiated parameter collector is met, and obtaining the obtained multi-element group.
Specifically, an instantiated parameter collector for processing a first parameter is called at running, then the remaining parameters are transferred to a next instantiated parameter collector to obtain a current multi-element group, the next parameter collector is continuously obtained as the current instantiated parameter collector until the termination condition of the instantiated parameter collector is met, and the obtained multi-element group is obtained.
Optionally, the termination condition of the instantiated parameter collector is a parameter collector termination condition function, and the parameter collector termination condition function is generated after all parameters to be called of the target parameter part are classified when the parameter collector compiles.
In one alternative embodiment, invoking each instantiated parameter collector to obtain at least one tuple further comprises invoking each instantiated parameter collector through an instantiated user program loop to obtain at least one tuple, wherein the instantiated user program is triggered based on the interface invocation instruction after receiving the interface invocation instruction.
In one optional embodiment, the method further comprises the step of calling each instantiated parameter executor in turn through the instantiated user program, and processing the multiple groups of the corresponding parameter types to obtain a calling result.
Referring to fig. 12, fig. 12 is a workflow diagram of an instantiated user program in an embodiment, after an interface is triggered, an instantiated user program is called first, each instantiated parameter collector is circularly called through the instantiated user program to obtain at least one multi-element group, so that each parameter to be called is collected in a classified manner, each instantiated parameter executor is sequentially called through the instantiated user program, and a call result is obtained by processing the multi-element group of the corresponding parameter type.
Referring to fig. 13, fig. 13 is a runtime workflow diagram in an embodiment, where the process of circularly calling each instantiated parameter collector by the instantiated user program to obtain at least one tuple includes calling an instantiated parameter collector that processes a first parameter, then transferring the remaining parameters to a next instantiated parameter collector, determining whether a termination condition function of the instantiated parameter collector is satisfied, if yes, continuing to use the tuple after parameter collection to call the instantiated parameter executor, and finally calling the instantiated parameter executor according to the instantiated user program.
For convenience of understanding, referring to fig. 14, the input and output parameters are respectively classified in a remote procedure call, the input parameter is serialized and the output parameter is deserialized, and two parameter executors can be defined, namely, the serialized executor and the deserialized executor are defined, and parameters are transferred in a parameter collector end processing function, and the specific procedure comprises the steps of calling a logic executor with 5 specific parameter instantiations, namely, an instantiated user program, calling a parameter collector with 1 st parameter processing, transferring the rest 4 parameters to the parameter collector with the next specific instantiation, calling a parameter collector with 2 nd parameter processing, transferring the rest 3 parameters to the parameter collector with the next specific instantiation, calling the parameter collector with the 3 rd parameter processing, transferring the rest 2 parameters to the parameter collector with the next specific instantiation, calling the parameter collector with the 4 th parameter processing, transferring the rest 1 parameter to the parameter collector with the next specific instantiation, waiting for the subsequent parameter to be subjected to the subsequent parameter instantiation to be processed in the specific instantiation, and waiting for the subsequent parameter to be transferred in the subsequent parameter instantiation to the subsequent parameter collector with the next specific instantiation, and waiting for the subsequent parameter to be subjected to the subsequent parameter to the subsequent instantiation is performed in the frame. The parameter collectors used in the calling process are all instantiated parameter collectors, and the parameter executors used in the calling process are all instantiated parameter executors.
In the above embodiment, the collection of the compile-time classification of the different types of parameters is realized by the template element programming technology, and the more general function calling method of parameter binding delay calling is realized. The method improves maintainability and readability of codes, reduces logic overhead of parameter classification to a compiling period, does not need running overhead, and has wide application prospect in library programming.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a compiling device for realizing the classification parameters of the compiling method of the classification parameters, and a calling device for calling the classification parameters of the classifying parameters. The implementation scheme of the device for solving the problem is similar to the implementation scheme described in the method, so the specific limitation in the embodiment of the compiling device for one or more classification parameters and the invoking device for the classification parameters provided below can be referred to the limitation of the compiling method for the classification parameters in the above description, and is not repeated here.
In one exemplary embodiment, as shown in FIG. 15, a compiling apparatus for classifying parameters is provided, comprising a parameter wrapper obtaining module 1501 and a parameter collector instantiating module 1502, wherein:
A parameter wrapper obtaining module 1501, configured to obtain, at compile time, a parameter wrapper obtained by packaging a parameter to be invoked, where the parameter wrapper includes a parameter type;
The parameter collector instantiation module 1502 is configured to classify parameters to be invoked packaged by the parameter wrapper at compile time through a recursive template function and a parameter type, obtain at least one tuple, and instantiate the at least one tuple to obtain each instantiated parameter collector, where each tuple stores a class of parameters to be invoked.
In one optional embodiment, the device further comprises a parameter packaging module, configured to package the parameter to be invoked, to obtain a parameter wrapper including the reference information of the parameter to be invoked and the parameter type, where the parameter type is only reserved during compiling.
In one optional embodiment, the parameter collector instantiation module 1502 is specifically configured to store parameters to be invoked to a target parameter portion based on a parameter wrapper, obtain a current parameter to be invoked from the target parameter portion, instantiate the tuple portion to obtain a current instantiated parameter collector after the current parameter to be invoked is added to the tuple portion based on a parameter type, generate a next parameter invocation function based on remaining parameters to be invoked in the target parameter portion, obtain the next parameter to be invoked from the target parameter portion as the current parameter to be invoked based on the next parameter invocation function, and continuously execute the step of instantiating the tuple portion to obtain the current instantiated parameter collector after the current parameter to be invoked is added to the tuple portion based on the parameter type until the parameters to be invoked in the target parameter portion are all classified, generate a termination condition, and obtain each instantiated parameter collector.
In one alternative embodiment, the parameter collector instantiation module 1502 is specifically configured to, when the current parameter to be invoked is the first parameter to be invoked, add the current parameter to be invoked to an empty tuple of the tuple portion to obtain a first target tuple based on the parameter type of the current parameter to be invoked, and modify the parameter type of the first target tuple, and when the current parameter to be invoked is not the first parameter to be invoked and the parameter type of each tuple in the instantiated tuple portion is different from the type of the current parameter to be invoked, add the current parameter to be invoked to a new empty tuple of the tuple portion to obtain a second target tuple based on the parameter type of the current parameter to be invoked, and modify the parameter type of the second target tuple, and when the current parameter to be invoked is not the first parameter to be invoked and there is a parameter type of the third target tuple in the instantiated tuple portion that is the same as the type of the current parameter to be invoked, add the current parameter to the third target tuple.
In one optional embodiment, the user program instantiation module is specifically configured to instantiate a user program, where the user program is configured to call each instantiated parameter collector, instantiate a calling function of a corresponding type based on at least one tuple to obtain each instantiated parameter executor, where the calling function in each instantiated parameter executor is configured to call a parameter to be called of the corresponding type, and obtain a compiling result based on the instantiated user program, each instantiated parameter collector, and each instantiated parameter executor.
In one optional embodiment, the user program instantiation module is specifically configured to obtain a current tuple from the tuple portion, call a template function in the parameter executor based on the current tuple, instantiate the template function based on the current tuple, obtain a call function, and obtain an instantiated parameter executor based on the call function, obtain a next tuple as the current tuple, and continue executing the step of calling the template function in the parameter executor through the current tuple until each tuple is processed.
In one optional embodiment, the device further comprises a configuration module, which is used for configuring the calling sequence and the calling condition of each instantiated parameter executor in the user program, and acquiring the configured user program.
In one exemplary embodiment, as shown in FIG. 16, there is provided a calling device of classification parameters, comprising a parameter collector calling module 1601, wherein:
and the parameter collector calling module 1601 is configured to call each instantiated parameter collector to obtain at least one multi-tuple, where each multi-tuple stores a collected class of parameters to be called, and the type of the parameters to be called corresponding to each multi-tuple is different.
In one optional embodiment, the parameter collector invoking module 1601 is specifically configured to obtain a current parameter to be invoked, invoke a current instantiated parameter collector to process the current parameter to be invoked to obtain a current tuple, obtain a next parameter collector as the current instantiated parameter collector, transfer the remaining parameter to be invoked to the current instantiated parameter collector, and continue to execute the step of obtaining the current parameter to be invoked until the termination condition of the instantiated parameter collector is met, and obtain the obtained tuple.
In one alternative embodiment, the parameter collector invoking module 1601 is specifically configured to loop-invoke each instantiated parameter collector by an instantiated user program to obtain at least one tuple, where the instantiated user program is triggered based on the interface invoking instruction after receiving the interface invoking instruction.
In an optional embodiment, the parameter executor calling module is specifically configured to call each instantiated parameter executor sequentially through an instantiated user program, and process the multiple groups of the corresponding parameter types to obtain a calling result.
In one alternative embodiment, the instantiated termination condition of the parameter collector is a parameter collector termination condition function, which is generated after the parameters to be invoked of the target parameter portion are all classified at the time of compiling the parameter collector.
The above-mentioned compiling means of the classification parameter and the calling means of the classification parameter may be implemented in whole or in part by software, hardware or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In an exemplary embodiment, a computer device, which may be a terminal, is provided, and an internal structure thereof may be as shown in fig. 17. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The Communication interface of the computer device is used for conducting wired or wireless Communication with an external terminal, and the wireless Communication can be realized through WIFI, a mobile cellular network, near field Communication (NEAR FIELD Communication) or other technologies. The computer program, when executed by the processor, implements a compiling method of classification parameters and a calling method of classification parameters. The display unit of the computer device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 17 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile memory and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (RESISTIVE RANDOM ACCESS MEMORY, reRAM), magneto-resistive Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computation, an artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) processor, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the present application.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.