CN108345458B - Calling method and system for static compiling language and scripting language - Google Patents

Calling method and system for static compiling language and scripting language Download PDF

Info

Publication number
CN108345458B
CN108345458B CN201810072681.0A CN201810072681A CN108345458B CN 108345458 B CN108345458 B CN 108345458B CN 201810072681 A CN201810072681 A CN 201810072681A CN 108345458 B CN108345458 B CN 108345458B
Authority
CN
China
Prior art keywords
function
processed
language
static
script language
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.)
Active
Application number
CN201810072681.0A
Other languages
Chinese (zh)
Other versions
CN108345458A (en
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.)
Weimeng Chuangke Network Technology China Co Ltd
Original Assignee
Weimeng Chuangke Network Technology China 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 Weimeng Chuangke Network Technology China Co Ltd filed Critical Weimeng Chuangke Network Technology China Co Ltd
Priority to CN201810072681.0A priority Critical patent/CN108345458B/en
Publication of CN108345458A publication Critical patent/CN108345458A/en
Application granted granted Critical
Publication of CN108345458B publication Critical patent/CN108345458B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

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

Abstract

The embodiment of the invention provides a method and a system for calling a static compiling language and a scripting language, wherein the method for calling the static compiling language and the scripting language comprises the following steps: storing a plurality of functions to be processed sent by a host program end; receiving function parameters sent by a script language execution end; sending the function to be processed corresponding to the function parameter to the script language execution end, and sending the function parameter to the host program end; receiving an operation result pressed by a host program end; and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed. According to the invention, the virtual machine is respectively in information interaction with the host program end and the script language execution end, so that seamless interaction between the two languages is realized, accurate calling of information can be realized, the vulnerability triggering rate in the development process is reduced, and the development efficiency is improved.

Description

Calling method and system for static compiling language and scripting language
Technical Field
The invention relates to the technical field of computer programming languages, in particular to a method and a system for calling a static compiling language and a scripting language.
Background
In the prior art, when a program service written by a static compiling language is modified and changed, the program service needs to be recompiled and restarted, and the software service which is large in change requirement and long in iteration period can be accepted in the mode, but the updating efficiency is obviously too low for the application service of quick iteration, and the debugging cost is high for the static compiling class.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
in the prior art, a static compiling language and a scripting language interact through a virtual stack, but stack interaction operation and service logic are generally mixed and used together, so that a stack becomes uncontrollable and vulnerability bugs are easy to appear, and a scripting language execution end is of a strong type, which can cause coding redundancy.
Disclosure of Invention
The embodiment of the invention provides a method and a system for calling a static compiling language and a scripting language, which can realize seamless interaction between the two languages.
In one aspect, an embodiment of the present invention provides a method for calling a static compiled language and a scripting language, including:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
Optionally, the to-be-processed function includes a to-be-processed static compiled language function and a function pointer;
the storing of the plurality of to-be-processed functions sent by the host program terminal specifically includes:
pressing a function pointer of each function to be processed, which is sent by a host program end, into a virtual stack of the virtual machine;
calling an application program interface of a scripting language corresponding to each function pointer in the virtual machine;
respectively registering corresponding function pointers into a global table of the virtual machine through each application program interface;
and binding each static compiling language function to be processed to the virtual machine.
Optionally, the binding each to-be-processed static compiled language function to the virtual machine specifically includes:
establishing a data use space in the virtual stack;
creating proxy functions corresponding to the static compiling language functions to be processed, and storing the proxy functions in the data use space;
and binding the corresponding to-be-processed static compiled language function to the virtual machine according to each agent function.
Optionally, the sending the to-be-processed function corresponding to the function parameter to the scripting language execution end specifically includes:
searching a corresponding proxy function from the data use space according to the function parameter sent by the script language execution end;
determining a corresponding static compiling language function to be processed based on the searched proxy function;
acquiring a corresponding function pointer from the global table based on the closure supported by the static compiling language and the determined static compiling language function to be processed;
and sending the determined static compiling language function to be processed and the obtained function pointer to the script language execution end.
On the other hand, an embodiment of the present invention provides a system for calling a static compiled language and a scripting language, including:
the host program end is used for sending a plurality of functions to be processed to the virtual machine, operating the corresponding functions to be processed according to the received function parameters to obtain an operation result, and pressing the obtained operation result into the virtual machine;
the script language execution end is used for sending the function parameters to the virtual machine, receiving the to-be-processed function and the operation result which are sent by the virtual machine and correspond to the function parameters, and executing script language compiling according to the operation result and the to-be-processed function;
the virtual machine is used for storing a plurality of to-be-processed functions sent by the host program end, receiving the function parameters sent by the script language execution end, sending the function parameters to the host program end, receiving the operation results pressed by the host program end, and sending the to-be-processed functions corresponding to the function parameters and the operation results to the script language execution end.
Optionally, the to-be-processed function includes a to-be-processed static compiled language function and a function pointer;
the virtual machine comprises a storage unit, a processing unit and a processing unit, wherein the storage unit is used for storing a plurality of functions to be processed sent by the host program end; wherein the content of the first and second substances,
the memory cell includes:
the pushing module is used for pushing the function pointer of each function to be processed sent by the host program end into a virtual stack of the virtual machine;
the calling module is used for calling an application program interface of the scripting language corresponding to each function pointer in the virtual machine;
the registration module is used for respectively registering the corresponding function pointers into the global table of the virtual machine through each application program interface;
and the binding module is used for binding each static compiling language function to be processed to the virtual machine.
Optionally, the binding module includes:
the space establishing submodule is used for establishing a data use space in the virtual stack;
the function creating submodule is used for creating proxy functions corresponding to the static compiling language functions to be processed and storing the proxy functions in the data use space;
and the function binding submodule is used for binding the corresponding to-be-processed static compiled language function to the virtual machine according to each agent function.
Optionally, the virtual machine further includes: the function sending unit is used for sending the function to be processed corresponding to the function parameter to the script language execution end; wherein the content of the first and second substances,
the function transmission unit includes:
the searching module is used for searching a corresponding proxy function from the data using space according to the function parameter sent by the script language execution end;
the determining module is used for determining a corresponding static compiling language function to be processed based on the searched proxy function;
the acquisition module is used for acquiring a corresponding function pointer from the global table based on the closure supported by the static compiling language and the determined static compiling language function to be processed;
and the sending module is used for sending the determined static compiling language function to be processed and the obtained function pointer to the script language execution end.
The invention also provides a calling system of the static compiling language and the scripting language, which comprises the following steps:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
The present invention also provides a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform operations comprising:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
The technical scheme has the following beneficial effects: the invention encapsulates an intermediate layer between the host program end and the script language execution end to adapt the interaction between the two languages, namely, the virtual machine respectively carries out information interaction with the host program end and the script language execution end, and seamless interaction between the two languages is carried out by sending and receiving function parameters, functions to be processed and operation results, thereby realizing accurate calling of information, reducing vulnerability triggering rate in the development process and improving development efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of a method for invoking a static compiled language and a scripting language according to the present invention;
FIG. 2 is a block diagram of the calling system of the static compiled language and the script language according to the present invention.
Description of the symbols:
host program end-1, script language execution end-2 and virtual machine-3.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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 invention.
The invention aims to provide a calling method of a static compiling language and a scripting language, wherein an intermediate layer is packaged between a host program end and a scripting language execution end to adapt to interaction between the two languages, namely, a virtual machine is respectively used for carrying out information interaction with the host program end and the scripting language execution end, and seamless interaction between the two languages is carried out by sending and receiving function parameters, functions to be processed and operation results, so that accurate calling of information can be realized, the vulnerability triggering rate in the development process is reduced, and the development efficiency is improved.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
As shown in fig. 1, the method for calling the static compiled language and the scripting language of the present invention includes:
step 100: and storing a plurality of functions to be processed sent by the host program end.
The host program end is used for running by adopting a static compiling language, and the static compiling language can be C + +, and the like.
Step 200: and receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed, and the function parameters are used for the script language execution end to execute script language compilation.
Step 300: and sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end.
Step 400: and receiving an operation result pressed by the host program end, wherein the operation result is obtained by the host program end operating the corresponding function to be processed according to the function parameter.
Step 500: and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
The function to be processed comprises a static compiling language function to be processed and a function pointer. The function types of the function to be processed are as follows:
staticintLUACFunction(lua_State*L){
}。
in step 100, the storing the plurality of to-be-processed functions sent by the host program specifically includes:
step 101: pressing a function pointer of each function to be processed, which is sent by a host program end, into a virtual stack of the virtual machine;
step 102: calling an application program interface of a scripting language corresponding to each function pointer in the virtual machine;
step 103: respectively registering corresponding function pointers into a global table of the virtual machine through each application program interface;
step 104: and binding each static compiling language function to be processed to the virtual machine.
Further, in step 104, the binding each to-be-processed static compiled language function to the virtual machine specifically includes:
step 1041: establishing a data use space in the virtual stack;
step 1042: creating proxy functions corresponding to the static compiling language functions to be processed, and storing the proxy functions in the data use space;
step 1043: and binding the corresponding to-be-processed static compiled language function to the virtual machine according to each agent function.
In step 300, sending the to-be-processed function corresponding to the function parameter to the scripting language execution end, specifically including:
step 301: searching a corresponding proxy function from the data use space according to the function parameter sent by the script language execution end;
step 302: determining a corresponding static compiling language function to be processed based on the searched proxy function;
step 303: acquiring a corresponding function pointer from the global table based on the closure supported by the static compiling language and the determined static compiling language function to be processed;
step 304: and sending the determined static compiling language function to be processed and the obtained function pointer to the script language execution end.
In the embodiment, the closure supported by the static compilation language and the static compilation language function to be processed can determine corresponding function parameters, namely function pointers.
Quick check with int test (int a, int b)
return a+b;
Testing test function as an example of a to-be-processed static compilation language function, binding the to-be-processed static compilation language function, and firstly establishing a data use userdata space in the virtual stack; creating proxy functions corresponding to the static compiling language functions to be processed, and storing the proxy functions in the data use space; and binding the corresponding to-be-processed static compiled language function to the virtual machine according to each agent function. And storing each proxy function in the virtual stack by using the Lua _ pushcclosure in the virtual stack, and setting the proxy function into a corresponding lookup table, thereby completing the binding of the function.
When the scripting language execution end calls the function, the function parameters are sent, the host program end needs to read the function parameters from the virtual stack and finally transfer the function parameters to the corresponding function to be processed, and the process can provide Application Programming Interfaces (APIs) for scripting languages of different data types. In this embodiment, a C + + meta programming mode is adopted, when a to-be-processed static compiled language function is bound on the virtual machine, a function type of the to-be-processed static compiled language function is determined, and a code for acquiring a function parameter is generated, and the host program acquires the function parameter from the virtual machine through the code for the function parameter, and transfers the acquired function parameter to the to-be-processed function.
And the host program end obtains an operation result and returns the operation result to the virtual machine by operating the corresponding function to be processed according to the function parameters, which is actually an inverse process of obtaining the parameters.
The coding is greatly simplified by using C + + element programming skills in the two processes of acquiring parameters and returning results, and the flexibility in binding by using the method is improved.
Where there is no object-oriented per se in the scripting language execution side, but the concept of tables, and meta-tables, provided in the Lua scripting language, can emulate an object-oriented, such as:
Figure BDA0001558587460000071
the inheritance of the object can be simulated through the Lua meta-table concept, the object is divided into a namespace, a class, a static constant, a static method and a member method on the end face of the host program, the binding of the namespace is actually simulated by adopting the Lua table, and the class is also realized by adopting the Lua table and the Metatable.
The implementation of the static method is basically the same as the method for binding the function in the foregoing, and for the object-oriented static method, it is a common method, and it is only bound to a class, and details are not described here.
In addition, the member method is a method generated after an object is created, the function type is judged through meta programming in the process of pushing the result into a virtual stack in the result returning part, if the result is a class, a meta table of the class is created firstly, then the returned value is pushed into the userdata space, the returned object can be used for calling the member method at the script language execution end, the realization principle is that the userdata does not have the member method, but the member method is searched from the meta table by setting the meta table of the corresponding class when the object is returned, and the member method is the method bound in the class table. Calling the member method at the Lua script language execution end is that the first parameter of the script language execution end returns the self object, the member method parameter is arranged behind the self object, the first parameter is firstly analyzed into the corresponding C + + object, and the subsequent parameter processing and result returning are the same as the static method processing process.
The method for calling the static compilation language and the scripting language is described in detail by taking the interaction between the Lua scripting language and the C + + static compilation language as an example:
and a virtual machine is arranged between the host program end and the Lua script language to analyze and process the script, and the host program end can start one virtual machine. When the Lua script is called to execute the scripting language compilation, the virtual machine can call the C + + to-be-processed function and send the C + + to the scripting language execution end. Before calling, the host program end sends the function to be processed by C + + to the virtual machine, the virtual machine pushes the function pointer of the function to be processed into the virtual stack, and calls the API interface of the Lua script language to register the function pointer into the global table of the virtual stack.
When the scripting language execution end executes the scripting language compilation, firstly, the function parameters are pressed into the virtual stack, the function is called, the host program end obtains the function parameters from the virtual stack, the corresponding function to be processed is operated according to the function parameters, the operation result is pressed into the virtual stack again, and the scripting language execution end obtains the final operation result of the C + + function from the virtual stack, so that one-time mutual calling is completed.
The calling method of the static compilation language and the scripting language can reduce the coding difficulty, improve the development efficiency of the mixed programming of the scripting language and the static compilation language and reduce the faults caused by misoperation of the virtual stack by abstracting the binding process in a meta-programming mode.
The invention also provides a calling system of the static compiling language and the script language, and seamless interaction between the two languages can be realized. As shown in fig. 2, the calling system of the static compiled language and the scripting language of the present invention includes a host program terminal 1, a scripting language execution terminal 2, and a virtual machine 3.
The host program end 1 is configured to send a plurality of to-be-processed functions to a virtual machine, run corresponding to-be-processed functions according to received function parameters to obtain a running result, and push the obtained running result into the virtual machine.
The script language execution end 2 is configured to send a function parameter to a virtual machine, receive a to-be-processed function and an operation result corresponding to the function parameter sent by the virtual machine, and execute script language compilation according to the operation result and the to-be-processed function.
The virtual machine 3 is configured to store a plurality of to-be-processed functions sent by the host program end 1, receive a function parameter sent by the scripting language execution end 2, send the function parameter to the host program end 1, receive an operation result pressed by the host program end 1, and send the to-be-processed function corresponding to the function parameter and the operation result to the scripting language execution end 2.
The function to be processed comprises a static compiling language function to be processed and a function pointer.
Specifically, the virtual machine 3 includes a storage unit, and the storage unit is configured to store a plurality of to-be-processed functions sent by the host program terminal.
The storage unit comprises a pressing module, a calling module, a registering module and a binding module.
The push module is used for pushing the function pointer of each function to be processed sent by the host program end into a virtual stack of the virtual machine; the calling module is used for calling an application program interface of the scripting language corresponding to each function pointer in the virtual machine; the registration module is used for respectively registering corresponding function pointers into a global table of the virtual machine through each application program interface; the binding module is used for binding each static compiling language function to be processed to the virtual machine.
Further, the binding module comprises a space establishing submodule, a function establishing submodule and a function binding submodule.
The space establishing submodule is used for establishing a data use space in the virtual stack; the function creating submodule is used for creating proxy functions corresponding to the static compiling language functions to be processed and storing the proxy functions in the data use space; and the function binding submodule is used for binding the corresponding to-be-processed static compiling language function to the virtual machine according to each agent function.
In addition, the virtual machine 3 further includes a function sending unit, where the function sending unit is configured to send the to-be-processed function corresponding to the function parameter to the scripting language execution end.
The function sending unit comprises a searching module, a determining module, an obtaining module and a sending module.
The searching module is used for searching a corresponding proxy function from the data using space according to the function parameter sent by the script language execution end; the determining module is used for determining a corresponding static compiling language function to be processed based on the searched proxy function; the acquisition module is used for acquiring a corresponding function pointer from the global table based on the closure supported by the static compiling language and the determined static compiling language function to be processed; and the sending module is used for sending the determined static compiling language function to be processed and the obtained function pointer to the script language execution end.
The embodiment of the present invention further provides a system for calling a static compiled language and a scripting language, including:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
An embodiment of the present invention also provides a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform operations of:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
Compared with the prior art, the calling system of the static compiling language and the scripting language, the computer readable storage medium and the calling method of the static compiling language and the scripting language have the same beneficial effects, and are not repeated herein.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. To those skilled in the art; various modifications to these embodiments will be readily apparent, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".
Those of skill in the art will further appreciate that the various illustrative logical blocks, units, and steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate the interchangeability of hardware and software, various illustrative components, elements, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design requirements of the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present embodiments.
The various illustrative logical blocks, or elements, described in connection with the embodiments disclosed herein may be implemented or performed with a general purpose processor, a digital signal processor, an Application Specific Integrated Circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. For example, a storage medium may be coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC, which may be located in a user terminal. In the alternative, the processor and the storage medium may reside in different components in a user terminal.
In one or more exemplary designs, the functions described above in connection with the embodiments of the invention may be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media that facilitate transfer of a computer program from one place to another. Storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, such computer-readable media can include, but is not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to carry or store program code in the form of instructions or data structures and which can be read by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Additionally, any connection is properly termed a computer-readable medium, and, thus, is included if the software is transmitted from a website, server, or other remote source via a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wirelessly, e.g., infrared, radio, and microwave. Such discs (disk) and disks (disc) include compact disks, laser disks, optical disks, DVDs, floppy disks and blu-ray disks where disks usually reproduce data magnetically, while disks usually reproduce data optically with lasers. Combinations of the above may also be included in the computer-readable medium.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A calling method of a static compiling language and a scripting language is characterized by comprising the following steps:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
2. The method for calling a static compiled language and script language according to claim 1, wherein the function to be processed comprises a function to be processed static compiled language and a function pointer;
the storing of the plurality of to-be-processed functions sent by the host program terminal specifically includes:
pressing a function pointer of each function to be processed, which is sent by a host program end, into a virtual stack of the virtual machine;
calling an application program interface of a scripting language corresponding to each function pointer in the virtual machine;
respectively registering corresponding function pointers into a global table of the virtual machine through each application program interface;
and binding each static compiling language function to be processed to the virtual machine.
3. The method for calling a static compiled language and a scripting language according to claim 2, wherein the binding of each to-be-processed static compiled language function to the virtual machine specifically includes:
establishing a data use space in the virtual stack;
creating proxy functions corresponding to the static compiling language functions to be processed, and storing the proxy functions in the data use space;
and binding the corresponding to-be-processed static compiled language function to the virtual machine according to each agent function.
4. The method for calling a static compiled language and a scripting language according to claim 3, wherein the sending the to-be-processed function corresponding to the function parameter to the scripting language execution end specifically comprises:
searching a corresponding proxy function from the data use space according to the function parameter sent by the script language execution end;
determining a corresponding static compiling language function to be processed based on the searched proxy function;
acquiring a corresponding function pointer from the global table based on the closure supported by the static compiling language and the determined static compiling language function to be processed;
and sending the determined static compiling language function to be processed and the obtained function pointer to the script language execution end.
5. A calling system for a static compiled language and a scripting language, comprising:
the host program end is used for sending a plurality of functions to be processed to the virtual machine, operating the corresponding functions to be processed according to the received function parameters to obtain an operation result, and pressing the obtained operation result into the virtual machine;
the script language execution end is used for sending the function parameters to the virtual machine, receiving the to-be-processed function and the operation result which are sent by the virtual machine and correspond to the function parameters, and executing script language compiling according to the operation result and the to-be-processed function;
the virtual machine is used for storing a plurality of to-be-processed functions sent by the host program end, receiving the function parameters sent by the script language execution end, sending the function parameters to the host program end, receiving the operation results pressed by the host program end, and sending the to-be-processed functions corresponding to the function parameters and the operation results to the script language execution end.
6. The system for invoking static compiled language and scripting language of claim 5, wherein the to-be-processed functions include to-be-processed static compiled language functions and function pointers;
the virtual machine comprises a storage unit, a processing unit and a processing unit, wherein the storage unit is used for storing a plurality of functions to be processed sent by the host program end; wherein the content of the first and second substances,
the memory cell includes:
the pushing module is used for pushing the function pointer of each function to be processed sent by the host program end into a virtual stack of the virtual machine;
the calling module is used for calling an application program interface of the scripting language corresponding to each function pointer in the virtual machine;
the registration module is used for respectively registering the corresponding function pointers into the global table of the virtual machine through each application program interface;
and the binding module is used for binding each static compiling language function to be processed to the virtual machine.
7. The system for invoking the static compiled language and script language of claim 6, wherein the binding module comprises:
the space establishing submodule is used for establishing a data use space in the virtual stack;
the function creating submodule is used for creating proxy functions corresponding to the static compiling language functions to be processed and storing the proxy functions in the data use space;
and the function binding submodule is used for binding the corresponding to-be-processed static compiled language function to the virtual machine according to each agent function.
8. The system for invoking static compiled language and scripting language of claim 7, wherein said virtual machine further comprises: the function sending unit is used for sending the function to be processed corresponding to the function parameter to the script language execution end; wherein the content of the first and second substances,
the function transmission unit includes:
the searching module is used for searching a corresponding proxy function from the data using space according to the function parameter sent by the script language execution end;
the determining module is used for determining a corresponding static compiling language function to be processed based on the searched proxy function;
the acquisition module is used for acquiring a corresponding function pointer from the global table based on the closure supported by the static compiling language and the determined static compiling language function to be processed;
and the sending module is used for sending the determined static compiling language function to be processed and the obtained function pointer to the script language execution end.
9. A calling system for a static compiled language and a scripting language, comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
10. A computer-readable storage medium storing one or more programs which, when executed by an electronic device including a plurality of application programs, cause the electronic device to:
storing a plurality of functions to be processed sent by a host program end;
receiving function parameters sent by a script language execution end, wherein the function parameters correspond to a function to be processed and are used for the script language execution end to execute script language compilation;
sending the function to be processed corresponding to the function parameter to the script language execution end to realize the calling of the function, and sending the function parameter to the host program end;
receiving an operation result pressed by a host program end, wherein the operation result is obtained by the host program end operating a corresponding function to be processed according to the function parameter;
and sending the running result to the script language execution end, so that the script language execution end executes the script language compiling according to the running result and the function to be processed.
CN201810072681.0A 2018-01-25 2018-01-25 Calling method and system for static compiling language and scripting language Active CN108345458B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810072681.0A CN108345458B (en) 2018-01-25 2018-01-25 Calling method and system for static compiling language and scripting language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810072681.0A CN108345458B (en) 2018-01-25 2018-01-25 Calling method and system for static compiling language and scripting language

Publications (2)

Publication Number Publication Date
CN108345458A CN108345458A (en) 2018-07-31
CN108345458B true CN108345458B (en) 2021-04-09

Family

ID=62961670

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810072681.0A Active CN108345458B (en) 2018-01-25 2018-01-25 Calling method and system for static compiling language and scripting language

Country Status (1)

Country Link
CN (1) CN108345458B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110858140B (en) * 2018-08-21 2024-01-26 苏州迈科网络安全技术股份有限公司 Compiling method of application program using Lua script and third party C module
CN110825383B (en) * 2019-10-14 2023-08-22 北京奇艺世纪科技有限公司 Video interaction method and device and computer readable storage medium
CN115981652B (en) * 2021-10-14 2023-09-29 华为技术有限公司 Language interoperation method, device, storage medium and program product
CN117724989B (en) * 2024-02-18 2024-06-11 粤港澳大湾区数字经济研究院(福田) Regression testing method and device for interface, terminal and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391219A (en) * 2017-07-07 2017-11-24 腾讯科技(深圳)有限公司 Function Compilation Method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9690551B2 (en) * 2015-04-07 2017-06-27 Qualcomm Innovation Center, Inc. Auto-vectorization in just-in-time compilers for dynamically typed programming languages

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391219A (en) * 2017-07-07 2017-11-24 腾讯科技(深圳)有限公司 Function Compilation Method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
VB与Lua交互调用的研究与实现;黄皓;《现代计算机》;20150915;正文第1-7页 *

Also Published As

Publication number Publication date
CN108345458A (en) 2018-07-31

Similar Documents

Publication Publication Date Title
CN108345458B (en) Calling method and system for static compiling language and scripting language
CN109976761B (en) Software development kit generation method and device and terminal equipment
CN110096338B (en) Intelligent contract execution method, device, equipment and medium
CA2082409C (en) Improved system and method for jacketing cross-domain calls in a multi-code execution and debugging system within a multi-architecture environment
CN108984174B (en) Cross-platform application creation method, device, server and storage medium
US9164754B1 (en) Runtime patching of native-code programs
US9471282B2 (en) System and method for using annotations to automatically generate a framework for a custom javaserver faces (JSF) component
CN107402792B (en) Integration method, device, equipment and storage medium of application software installation package
CN110955409A (en) Method and device for creating resources on cloud platform
CN110659210A (en) Information acquisition method and device, electronic equipment and storage medium
CN111625290B (en) Layout file preloading method and device under Android platform and electronic equipment
CN110727429A (en) Front-end page generation method, device and equipment
US10747514B2 (en) Reduced save and restore instructions for call-clobbered registers
CN115525282A (en) Method for realizing cross-platform desktop application program and related equipment thereof
CN111427782A (en) Operation method, device, equipment and storage medium of android dynamic link library
CN107273745B (en) Dynamic analysis method for malicious code in dynamic link library form
US9069897B2 (en) Capturing telemetry data by dynamic language engine
US11755458B2 (en) Automatic software behavior identification using execution record
CN113986744A (en) Method and device for testing warehouse and table components and storage medium
CN111399932A (en) Method and system for calling D LL, browser processing method and browser
US10671397B2 (en) Reduced save and restore instructions for call-clobbered registers
CN116126427B (en) Implementation method of non-invasive SDK auxiliary integrated plug-in based on tangent plane programming
CN111209056B (en) Method and device for loading function, readable storage medium and electronic equipment
CN115857900A (en) Code automatic generation method and device, electronic equipment and storage medium
CN118035045A (en) System call detection method based on QNX system

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
GR01 Patent grant
GR01 Patent grant