CN110968293A - Method for constructing function pre-dependency and related equipment - Google Patents

Method for constructing function pre-dependency and related equipment Download PDF

Info

Publication number
CN110968293A
CN110968293A CN201811163055.9A CN201811163055A CN110968293A CN 110968293 A CN110968293 A CN 110968293A CN 201811163055 A CN201811163055 A CN 201811163055A CN 110968293 A CN110968293 A CN 110968293A
Authority
CN
China
Prior art keywords
function
parameter
binding
dependency
unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811163055.9A
Other languages
Chinese (zh)
Inventor
兰浩青
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201811163055.9A priority Critical patent/CN110968293A/en
Publication of CN110968293A publication Critical patent/CN110968293A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method and related equipment for constructing a function pre-dependency, wherein the method for constructing the function pre-dependency comprises the following steps: establishing a first function, wherein the first function is a function of universal identification under various terminal environments; and encapsulating a second function by using the first function, wherein the second function calling process needs a dependency context. In the method for constructing the function pre-dependency, the first function which can be universally identified by various terminal environments is constructed to encapsulate the second function, so that the second function can be called under various terminal environments; the problem that the second function cannot be executed due to different pre-dependencies is solved; the method and the device realize that one set of codes are used in multiple terminals, and reduce the workload of development and maintenance of the codes for research and development personnel.

Description

Method for constructing function pre-dependency and related equipment
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and related device for constructing a function pre-dependency.
Background
Nowadays, the execution of many functions in the code needs some pre-dependencies, namely the contexts of the functions, and the context definition builds an execution environment for the functions in advance before the functions are built, so that the functions have the dependencies on the contexts.
However, the contexts defined in different terminal environments are different, and thus, in one environment, a function depending on the context of the environment is defined and cannot be called in another environment. For example: in a first terminal environment, defining a variable set inside a function A, defining a function B at the same time, and calling an internal variable of the function A when the function B is executed, namely, the execution of the function B depends on the internal variable of the function A; in the second terminal environment, the context on which the function B depends, i.e., the internal variable of a, is not set, or the set context cannot be identified by the function B, so that the function B cannot establish a dependency relationship and cannot be executed.
Disclosure of Invention
In view of the above, the present invention has been made to provide a method and related apparatus for constructing function pre-dependencies that overcome or at least partially address the above-mentioned problems.
In order to achieve the above purpose, the embodiments of the present invention provide the following technical solutions:
the invention provides a method for constructing function pre-dependency, which comprises the following steps:
establishing a first function, wherein the first function is a function of universal identification under various terminal environments;
and encapsulating a second function by using the first function, wherein the second function calling process needs a dependency context.
Optionally, the first function and the second function have the same function body.
Optionally, the encapsulating the second function with the first function includes:
binding the first parameter of the first function with the context which needs to be depended on by the second function calling process;
and binding the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function respectively.
Optionally, the establishing a first function includes: the first function is created by the bind method.
The invention also provides a device for constructing the function pre-dependency, which comprises the following steps:
the device comprises an establishing unit, a judging unit and a judging unit, wherein the establishing unit is used for establishing a first function which is a function of universal identification under various terminal environments;
and the packaging unit is used for packaging the second function by the first function, and the calling process of the second function needs to depend on the context.
Optionally, the first function and the second function have the same function body.
Optionally, the encapsulation unit includes:
the first binding unit is used for binding the first parameter of the first function with the calling process of the second function, which needs to depend on the context;
and the second binding unit is used for binding the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function respectively.
Optionally, the establishing unit includes: a construction unit for creating the first function by a bind method.
The present invention also provides a storage medium storing a program for, when executed, performing: in the embodiment provided by the invention, any method for constructing the function pre-dependency is adopted.
The present invention also provides a processor for executing a program, wherein the program is executed for performing: in the embodiment provided by the invention, any method for constructing the function pre-dependency is adopted.
By means of the technical scheme, in the method for constructing the function pre-dependency, the first function which can be universally identified by various terminal environments is constructed to encapsulate the second function, so that the second function can be called under various terminal environments; the problem that the second function cannot be executed due to different pre-dependencies is solved; the method and the device realize that one set of codes are used in multiple terminals, and reduce the workload of development and maintenance of the codes for research and development personnel.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart illustrating a method for constructing a function pre-dependency disclosed in an embodiment of the present application;
FIG. 2 is a diagram illustrating an apparatus for constructing a function pre-dependency, according to another embodiment of the present disclosure;
fig. 3 shows a block diagram of a packaging unit disclosed in another embodiment of the present application.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The embodiment of the application discloses a method for constructing function pre-dependency, which is shown in fig. 1 and comprises the following steps:
s101, building a binding function for the execution function.
Before the binding function is constructed, the execution function to be bound is determined. The constructed binding function is a function that can be universally recognized in various terminal environments, and the execution function is a function that depends on a context in the execution environment. The various terminals may be, for example, PC terminals, mobile terminals, etc.
In this step, the execution function is the second function, and the binding function is the first function.
Optionally, it should be further noted that, in order to implement encapsulation of the execution function by the binding function, the constructed binding function and the execution function have the same function body.
The binding function and the execution function have the same function body, which means that: the binding function and the execution function are the same in terms of the flow of function execution, the logic of the function, and the function realized by the function.
Optionally, in another embodiment of the present application, an implementation manner of step S101 includes: the first function is created by the bind method.
And establishing a binding function by a bind method in the JavaScript language. The constructed binding function can be universally identified under various terminal environments.
The binding function is a function established by the bind method, the binding object is an execution function, and the function body context of the binding function is bound to the first parameter transmitted by the bind method, namely the first parameter of the binding function.
And S102, packaging the execution function by using the binding function.
The binding function encapsulates the execution function, and the binding function covers the execution function, namely the execution function is a subfunction of the binding function; the binding function can transmit parameters, and the execution function establishes a relation with the corresponding parameters, obtains a dependency relationship and then executes in a new terminal environment.
And (3) packaging: a function with one or more functions is packaged in the form of a function and a class, and the packaged function and class only provide a function interface to the outside. For example: in an environment where an execution function is defined, it is the context of the execution environment that the execution function depends on; packaging the execution function through the binding function, wherein the dependence of the packaged execution function is used as a part of parameters of the binding function; and establishing a relationship between the binding function and the execution environment so as to realize encapsulation.
Optionally, in another embodiment of the present application, an implementation manner of step S102 includes:
and binding the first parameter of the first function to the context which needs to be depended by the second function calling process.
And binding the second parameter to the end parameter of the first function respectively with the first parameter to the end parameter of the second function.
The second to Nth parameters of the binding function are preset parameters and are in one-to-one correspondence with the first to Nth-1 parameters in the execution function respectively. Wherein the execution function comprises only N-1 parameters. I.e. the number of parameters of the body of the bound function is 1 more than the number of parameters of the body of the function executing the function.
In the embodiment of the invention, the execution function binds corresponding parameters through the binding function, wherein the first parameter transmitted by the binding function is the context of the execution function, and the other parameters are preset parameters of the binding function and are in one-to-one correspondence with the parameters in the execution function; therefore, the dependence of the execution function is the first parameter of the binding function, and the execution function can run under different terminal environments because the binding function encapsulates the execution function.
For example: an execution function F is defined in the first terminal environment, the execution function F having three parameters a1, a2, and A3, respectively. The context in which function F is executed is B.
And establishing a binding function C by using a bind method, wherein a binding object of the binding function C is an execution function F, and the binding function C and the execution function F have the same function body. The first parameter of the binding function C binds the context B on which the function F depends, and the remaining parameters bind the three parameters a1, a2, and A3, respectively, of the executing function F. In the binding function, three parameters B2, 1 and 2 are defined, respectively, the binding function assigns a first parameter B2 to a context B, and the second parameter and the third parameter are preset parameters 1 and 2, respectively.
When a parameter 3 is introduced into the binding function C, since the first parameter of the binding function binds the context B on which the F function depends, and the second parameter and the third parameter of the binding function C are preset parameters 1 and 2, respectively, the execution result of the binding function C is: B2123.
in addition, a context in an execution environment is a dependency of an execution function, and when the context is mapped to internal variables of a plurality of functions in the execution environment, there is uncertainty about the execution function in terms of its context. The context of the executing function is bound through the first parameter of the binding function, and the context of the binding function can be uniquely mapped to the internal variable of a certain function.
In the method for constructing the function pre-dependency disclosed by the embodiment of the invention, the second function is encapsulated by constructing the first function which can be universally identified in various terminal environments, so that the second function can be called in various terminal environments; the problem that the second function cannot be executed due to different pre-dependencies is solved; the method and the system realize that a set of codes are used in various terminal environments, and reduce the workload of development and maintenance of the codes for research and development personnel.
Referring to fig. 2, another embodiment of the present invention further provides an apparatus for constructing a function pre-dependency, including:
the establishing unit 201 is configured to establish a first function, where the first function is a function of universal identification in multiple terminal environments.
Optionally, in another embodiment of the present application, the first function and the second function have the same function body.
Optionally, in another embodiment of the present application, the establishing unit 201 includes: a construction unit for creating the first function by a bind method.
And the encapsulating unit 202 is used for encapsulating the first function to the second function, and the calling process of the second function needs to depend on the context.
In this embodiment, for specific execution processes of the establishing unit 201 and the encapsulating unit 202, reference may be made to contents of corresponding method embodiments, which are not described herein again.
Optionally, in another embodiment of the present application, as shown in fig. 3, the encapsulation unit includes:
a first binding unit 301, configured to bind a first parameter of the first function to a context that is required for a calling process of the second function;
a second binding unit 302, configured to bind the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function, respectively.
In this embodiment, for specific execution processes of the establishing unit 201 and the encapsulating unit 202, reference may be made to contents of corresponding method embodiments, which are not described herein again.
The device for building function pre-dependency comprises a processor and a memory, wherein the building unit, the packaging unit, the first binding unit, the second binding unit, the building unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more, and the method for constructing the function pre-dependency is realized by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium, on which a program is stored, which, when executed by a processor, implements the method for constructing a function pre-dependency.
The embodiment of the invention provides a processor, which is used for running a program, wherein the method for constructing the function pre-dependency is executed when the program runs.
The embodiment of the invention provides equipment, and the equipment can be a server, a PC, a PAD, a mobile phone and the like. The device comprises a processor, a memory and a program stored on the memory and capable of running on the processor, and the processor realizes the following steps when executing the program:
establishing a first function, wherein the first function is a function of universal identification under various terminal environments;
and encapsulating a second function by using the first function, wherein the second function calling process needs a dependency context.
Optionally, the first function and the second function have the same function body.
Optionally, the encapsulating the second function with the first function includes:
binding the first parameter of the first function with the context which needs to be depended on by the second function calling process;
and binding the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function respectively.
Optionally, the establishing a first function includes: the first function is created by the bind method.
The invention also provides a computer program product adapted to perform a program for initializing the following method steps when executed on an apparatus for building a function pre-dependency:
establishing a first function, wherein the first function is a function of universal identification under various terminal environments;
and encapsulating a second function by using the first function, wherein the second function calling process needs a dependency context.
Optionally, the first function and the second function have the same function body.
Optionally, the encapsulating the second function with the first function includes:
binding the first parameter of the first function with the context which needs to be depended on by the second function calling process;
and binding the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function respectively.
Optionally, the establishing a first function includes: the first function is created by the bind method.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method of constructing a function pre-dependency, comprising:
establishing a first function, wherein the first function is a function of universal identification under various terminal environments;
and encapsulating a second function by using the first function, wherein the second function calling process needs a dependency context.
2. The method of claim 1, wherein the first function and the second function have the same function body.
3. The method of claim 1, wherein encapsulating the second function with the first function comprises:
binding the first parameter of the first function with the context which needs to be depended on by the second function calling process;
and binding the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function respectively.
4. The method of claim 1, wherein establishing the first function comprises: the first function is created by the bind method.
5. An apparatus for constructing a function pre-dependency, comprising:
the device comprises an establishing unit, a judging unit and a judging unit, wherein the establishing unit is used for establishing a first function which is a function of universal identification under various terminal environments;
and the packaging unit is used for packaging the second function by the first function, and the calling process of the second function needs to depend on the context.
6. The apparatus of claim 5, wherein the first function and the second function have the same function body.
7. The apparatus of claim 5, wherein the encapsulation unit comprises:
the first binding unit is used for binding the first parameter of the first function with the calling process of the second function, which needs to depend on the context;
and the second binding unit is used for binding the second parameter to the last parameter of the first function with the first parameter to the last parameter of the second function respectively.
8. The apparatus of claim 5, wherein the establishing unit comprises: a construction unit for creating the first function by a bind method.
9. A storage medium storing a program which, when executed, implements a method of constructing a function pre-dependency according to any one of claims 1 to 4.
10. A processor configured to execute a program, wherein the program is configured to perform: the method of constructing a function pre-dependency according to any one of claims 1-4.
CN201811163055.9A 2018-09-30 2018-09-30 Method for constructing function pre-dependency and related equipment Pending CN110968293A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811163055.9A CN110968293A (en) 2018-09-30 2018-09-30 Method for constructing function pre-dependency and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811163055.9A CN110968293A (en) 2018-09-30 2018-09-30 Method for constructing function pre-dependency and related equipment

Publications (1)

Publication Number Publication Date
CN110968293A true CN110968293A (en) 2020-04-07

Family

ID=70028262

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811163055.9A Pending CN110968293A (en) 2018-09-30 2018-09-30 Method for constructing function pre-dependency and related equipment

Country Status (1)

Country Link
CN (1) CN110968293A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120079466A1 (en) * 2010-09-23 2012-03-29 Gonion Jeffry E Systems And Methods For Compiler-Based Full-Function Vectorization
CN107992307A (en) * 2017-12-11 2018-05-04 北京奇虎科技有限公司 A kind of function Compilation Method and device
CN107992749A (en) * 2017-12-11 2018-05-04 北京奇虎科技有限公司 A kind of method and device for detecting patch packet conflict
CN108319858A (en) * 2018-01-29 2018-07-24 中国科学院信息工程研究所 For the data dependence graph construction method and device of uneasy total function

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120079466A1 (en) * 2010-09-23 2012-03-29 Gonion Jeffry E Systems And Methods For Compiler-Based Full-Function Vectorization
CN107992307A (en) * 2017-12-11 2018-05-04 北京奇虎科技有限公司 A kind of function Compilation Method and device
CN107992749A (en) * 2017-12-11 2018-05-04 北京奇虎科技有限公司 A kind of method and device for detecting patch packet conflict
CN108319858A (en) * 2018-01-29 2018-07-24 中国科学院信息工程研究所 For the data dependence graph construction method and device of uneasy total function

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘夏江的博客: "深入理解js中的bind", 《HTTPS://BLOG.CSDN.NET/QQ_37653449/ARTICLE/DETAILS/80803216》 *

Similar Documents

Publication Publication Date Title
CN110768912B (en) API gateway current limiting method and device
CN110020353B (en) Method and device for constructing webpage form
CN110968357A (en) Method and device for packaging maven item, storage medium and processor
CN104423961A (en) Method and system for generating testing script
CN106648567B (en) Data acquisition method and device
CN110968858A (en) User authority control method and system
US10303144B2 (en) Object creation in process control systems
CN110837446A (en) Equipment management method and device applied to embedded system, medium and embedded equipment
CN112230930A (en) Method and device for constructing and packaging hybrid technology stack and machine-readable storage medium
CN109597695B (en) Data processing method, device and equipment
CN110968293A (en) Method for constructing function pre-dependency and related equipment
CN111459573A (en) Method and device for starting intelligent contract execution environment
CN109542401B (en) Web development method and device, storage medium and processor
CN107291439B (en) Target incremental data construction method and device
CN111158940B (en) Method and device for docking and dynamically loading different devices in field of Internet of things
CN110633564B (en) File generation method and device
CN112738181A (en) Method, device and server for cluster external IP access
CN110968879A (en) Data processing method and device based on block chain
CN106844056B (en) Hadoop big data platform multi-tenant job management method and system
CN111045812A (en) Block chain intelligent contract reverse calling method, equipment and medium
CN112925527B (en) Calling method, calling device, storage medium and electronic equipment
CN110286909B (en) Statistical method and device for resource use data of Simulink model
CN113448588B (en) Data security processing method and device, electronic equipment and storage medium
CN110968709B (en) Data transmission method and related system
CN110969461A (en) Method and device for processing public number information, storage medium and processor

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200407