[go: up one dir, main page]

CN112068814B - Method, device, system and medium for generating executable file - Google Patents

Method, device, system and medium for generating executable file Download PDF

Info

Publication number
CN112068814B
CN112068814B CN201910495960.2A CN201910495960A CN112068814B CN 112068814 B CN112068814 B CN 112068814B CN 201910495960 A CN201910495960 A CN 201910495960A CN 112068814 B CN112068814 B CN 112068814B
Authority
CN
China
Prior art keywords
code
attribute
obtaining
executable file
attribute variable
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
CN201910495960.2A
Other languages
Chinese (zh)
Other versions
CN112068814A (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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910495960.2A priority Critical patent/CN112068814B/en
Publication of CN112068814A publication Critical patent/CN112068814A/en
Application granted granted Critical
Publication of CN112068814B publication Critical patent/CN112068814B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

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 present disclosure provides a method of generating an executable file, including constructing an original code, setting an attribute variable of the original code as a dynamic type, constructing an execution code and adding the execution code to the original code, and generating the executable file according to the original code, wherein the execution code is constructed and added to the original code such that, when the executable file is run, a key value pair of the attribute variable is added to a specific object in response to a setting operation for obtaining the attribute value of the attribute variable, the key value pair including a key name corresponding to the attribute variable and an attribute value to be set by the setting operation, and, when the executable file is run, in response to an obtaining operation for obtaining the attribute value of the attribute variable, an attribute value corresponding to the key name is obtained from the specific object according to the key name corresponding to the attribute variable. The disclosure also provides a device, a system and a medium for generating the executable file.

Description

Executable file generation method, device, system and medium
Technical Field
The disclosure relates to the field of computers, and in particular relates to a method, a device, a system and a medium for generating an executable file.
Background
An executable file (executable file) refers to a file that may be loaded and executed by an operating system. The executable file is an integral part of the application program, which needs to run on the executable file. The manner in which executable programs are presented varies under different operating system environments. For example, in apple's iOS operating system, the executable file format is Mach-O (Mach Object file format).
In the process of implementing the disclosed concept, the inventor finds that at least the following problems exist in the prior art, namely, the more complex the business logic and pages of an application program are, the larger the data volume of executable files is often, and the larger the occupied storage space is. How to reduce the data size of executable files without affecting business logic and pages is a problem that needs to be addressed.
Disclosure of Invention
In view of this, an aspect of the present disclosure provides a method, an apparatus, a system, and a medium for generating an executable file.
One aspect of the present disclosure provides a method of generating an executable file. The method includes the steps of constructing an original code, setting an attribute variable of the original code as a dynamic type, constructing an execution code, adding the execution code to the original code, and generating an executable file according to the original code, wherein the execution code is constructed and added to the original code, so that when the executable file is run, a key value pair of the attribute variable is added to a specific object in response to a setting operation for obtaining the attribute value of the attribute variable, the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation, and when the executable file runs, in response to an obtaining operation for obtaining the attribute value of the attribute variable, the attribute value corresponding to the key name is obtained from the specific object according to the key name corresponding to the attribute variable.
According to an embodiment of the disclosure, the adding the key-value pairs of the attribute variables to the specific object includes adding the key-value pairs of the attribute variables to the specific object by calling a parse-instance method in the runtime mechanism. The step of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable comprises the step of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable by calling an analysis instance method in a runtime mechanism.
According to the embodiment of the disclosure, the method for generating the executable file further comprises the steps of constructing an error detection code and adding the error detection code into the original code, so that when the executable file runs, the operation of adding the key value pair of the attribute variable into a specific object is refused to be executed in response to the obtained setting operation not being a preset operation, and error information is generated, and when the executable file runs, the operation of obtaining the attribute value corresponding to the key name is refused to be executed in response to the obtained obtaining operation not being the preset operation, and the error information is generated.
According to the embodiment of the disclosure, the method for generating the executable file further comprises the steps of constructing a judging code and adding the judging code into an original code, so that whether a preset data structure comprises the corresponding relation of the operated attribute variable and the setting operation or the obtaining operation or not is judged when the executable file runs, wherein the preset data structure comprises any one of an array, a mapping and a list. And if the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining the setting operation or the obtaining operation as the preset operation, otherwise, determining that the setting operation or the obtaining operation is not the preset operation.
According to the embodiment of the disclosure, the execution code and/or the error detection code and/or the judgment code are located in a parent class of the class in which the attribute variable is located.
Another aspect of the disclosure provides a generating device of an executable file, which includes a first construction module, a setting module, a second construction module and a generating module. And the first construction module is used for constructing the original code. And the setting module is used for setting the attribute variable of the original code to be a dynamic type. And a second construction module for constructing the execution code and adding the execution code to the original code. And the generation module is used for generating the executable file according to the original codes. Wherein the execution code is constructed and added to the original code, so that when the executable file is run, in response to obtaining a setting operation for an attribute value of an attribute variable, a key value pair of the attribute variable is added to a specific object, the key value pair including a key name corresponding to the attribute variable and an attribute value to be set by the setting operation. And when the executable file runs, in response to the acquisition operation of the attribute value of the attribute variable, acquiring the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable.
According to the embodiment of the disclosure, the first building module comprises an adding sub-module and an obtaining sub-module, wherein the adding sub-module is used for adding the key value pair of the attribute variable into a specific object by calling the analysis instance method in the runtime mechanism, and the obtaining sub-module is used for obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable by calling the analysis instance method in the runtime mechanism.
According to the embodiment of the disclosure, the generation device of the executable file further comprises a third construction module, wherein the third construction module is used for constructing an error detection code and adding the error detection code into an original code, so that when the executable file runs, the operation of adding the key value pair of the attribute variable into a specific object is refused to be executed in response to the obtained setting operation not being a preset operation, and error information is generated. And when the executable file runs, refusing to execute the operation of obtaining the attribute value corresponding to the key name and generating error information in response to the obtained obtaining operation not being the preset operation.
According to the embodiment of the disclosure, the generating device of the executable file further comprises a fourth construction module, wherein the fourth construction module is used for constructing a judging code and adding the judging code into an original code, so that when the executable file runs, whether a preset data structure comprises the corresponding relation of the operated attribute variable and the setting operation or the obtaining operation or not is judged, and the preset data structure comprises any one of an array, a mapping and a list. And if the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining the setting operation or the obtaining operation as the preset operation, otherwise, determining that the setting operation or the obtaining operation is not the preset operation.
According to the embodiment of the disclosure, the execution code and/or the error detection code and/or the judgment code are located in a parent class of the class in which the attribute variable is located.
Another aspect of the present disclosure provides a system for generating an executable file. The system includes one or more processors and memory for storing one or more programs. Wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method as described above.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions that, when executed, are configured to implement a method as described above.
Another aspect of the present disclosure provides a computer program comprising computer executable instructions which when executed are for implementing a method as described above.
According to an embodiment of the present disclosure, an original code is constructed by setting an attribute variable of the original code to a dynamic type and added to the original code to generate the original code, and an executable file is generated according to the original code. Therefore, under the condition that the setting operation and the acquisition operation of the attribute variables are normal, the size of the executable file is reduced, and meanwhile, the occupation of the storage space of the system is also reduced.
Drawings
For a more complete understanding of the present disclosure and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, in which:
Fig. 1 schematically illustrates an application scenario of a method and an apparatus for generating an executable file according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a method of executable file generation according to an embodiment of the disclosure;
FIG. 3 schematically illustrates a flow chart of a method performed by executing code according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a flow chart of a method of executable file generation according to another embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow chart of a method of error detection code and determination code execution in accordance with an embodiment of the present disclosure;
FIG. 6 schematically illustrates a block diagram of a generation apparatus of an executable file according to an embodiment of the present disclosure;
FIG. 7 schematically illustrates a block diagram of a first build module according to an embodiment of the disclosure;
FIG. 8 schematically shows a block diagram of an executable file generating apparatus according to another embodiment of the present disclosure, and
Fig. 9 schematically illustrates a block diagram of a computer system suitable for implementing the above-described method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a convention should be interpreted in accordance with the meaning of one of skill in the art having generally understood the convention (e.g., "a system having at least one of A, B and C" would include, but not be limited to, systems having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a formulation similar to at least one of "A, B or C, etc." is used, in general such a formulation should be interpreted in accordance with the ordinary understanding of one skilled in the art (e.g. "a system with at least one of A, B or C" would include but not be limited to systems with a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Some of the block diagrams and/or flowchart illustrations are shown in the figures. It will be understood that some blocks of the block diagrams and/or flowchart illustrations, or combinations of blocks in the block diagrams and/or flowchart illustrations, 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, or other programmable data processing apparatus, such that the instructions, when executed by the processor, create means for implementing the functions/acts specified in the block diagrams and/or flowchart. The techniques of this disclosure may be implemented in hardware and/or software (including firmware, microcode, etc.). Additionally, the techniques of this disclosure may take the form of a computer program product on a computer-readable storage medium having instructions stored thereon, the computer program product being for use by or in connection with an instruction execution system.
The embodiment of the disclosure provides a method for generating an executable file and a device capable of applying the method. The method comprises the steps of constructing an original code, setting attribute variables of the original code as dynamic types, constructing an execution code, adding the execution code to the original code, and generating an executable file according to the original code. Wherein the execution code is constructed and added to the original code such that, when the executable file is run, the key value pair of the attribute variable is added to the specific object in response to a setting operation to obtain the attribute value of the attribute variable. The key value pair comprises a key name corresponding to an attribute variable and an attribute value to be set by a setting operation, and when the executable file runs, the attribute value corresponding to the key name is obtained from a specific object according to the key name corresponding to the attribute variable in response to obtaining the attribute value of the attribute variable.
Fig. 1 schematically illustrates an application scenario of a method and an apparatus for generating an executable file according to an embodiment of the present disclosure. It should be noted that fig. 1 is merely an example of a scenario in which embodiments of the present disclosure may be applied to assist those skilled in the art in understanding the technical content of the present disclosure, but does not mean that embodiments of the present disclosure may not be used in other devices, systems, environments, or scenarios.
As shown in fig. 1, a system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Executable files of various applications may be run on the terminal devices 101, 102, 103, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 105 may be a server that provides various services, such as a compilation server (for example only). The compiling server may construct a code of the executable file of the application program, compile the code to generate the executable file, and then transmit the executable file to the terminal device.
It should be noted that, the method for generating an executable file provided in the embodiments of the present disclosure may be generally executed by the server 105. Accordingly, the generating device of the executable file provided in the embodiments of the present disclosure may be generally disposed in the server 105. The method for generating an executable file provided by the embodiments of the present disclosure may also be performed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the generation apparatus of the executable file provided by the embodiments of the present disclosure may also be provided in a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 schematically illustrates a flowchart of a method of generating an executable file according to an embodiment of the present disclosure.
As shown in FIG. 2, the method includes operations S210-S230.
In operation S210, an original code is constructed.
According to embodiments of the present disclosure, the original code may be, for example, application code written based on the Object-C language. Object-C is usually written as Objective-C or Obj-C or OC, which is a language derived from the C language, inherits the characteristics of the C language, and is an Object-oriented programming language that extends C. The OC language may be used to develop iOS executable files.
In operation S220, the attribute variable of the original code is set to a dynamic type.
For attribute variables of a non-dynamic type, the compiler automatically adds a setting method (setter) and an acquisition method (getter) of the attribute variables in the code of the executable file when compiling, and after setting the attribute variables to the dynamic (dynamic) type, the compiler does not automatically add setter and getter of the attribute variables, namely the size of the executable file can be reduced. Based on this principle, in operation S220, the attribute variable in the original code is set to the dynamic type.
In operation S230, an execution code is constructed and added to the original code.
In operation S240, an executable file is generated according to the original code.
Fig. 3 schematically illustrates a flow chart of a method performed by executing code according to an embodiment of the disclosure.
As shown in FIG. 3, the above-mentioned executable code is used to execute the following operations S310-S330 when running the executable file:
in operation S310, an object is initialized.
The object is a data structure that can store key-value pairs (e.g., < key, value >) and can be read and written by external methods.
According to embodiments of the present disclosure, object objects may be implemented as various data structures such as classes (structures), structs (structures), linked lists, arrays, and the like, for example.
When the application program is to perform a setting operation on the attribute values of the attribute variables, key value pairs of the attribute variables are added to a specific object in operation S320.
The key value pair comprises a key name corresponding to the attribute variable and an attribute value to be set by the setting operation.
According to an embodiment of the present disclosure, operation S320 may include, for example, obtaining a key name key corresponding to an attribute variable and setting an attribute value to be set by an operation, and then adding a key value pair < key, value > formed by the key and the value to the initialized object. The above-described addition of key-value pairs of the attribute variables to a particular object may be accomplished, for example, by invoking a resolved instance method (resolveInstanceMethod) in a runtime (runtime) mechanism, according to an embodiment of the present disclosure. resolveInstanceMethod may be invoked, at resolveInstanceMethod, to add a key-value pair < key, value > to the initialized object, where key is the key name corresponding to the attribute variable and value is the attribute value to be set by the set operation, through a class_ addMethod function. If the above method addition is successful, resolveInstanceMethod is returned to YES.
When the application program is to perform an acquisition operation on the attribute value of the attribute variable, the attribute value corresponding to the key name is obtained from the specific object according to the key name corresponding to the attribute variable in operation S330.
According to an embodiment of the present disclosure, operation S330 may include, for example, when an application program is to perform an obtaining operation on an attribute value of the attribute variable, first obtaining a key name key of the operated attribute variable, then searching for an attribute value corresponding to the key in an object according to the key, and if the corresponding value is found successfully, returning the value.
According to an embodiment of the present disclosure, the above operation of obtaining, from the specific object, the attribute value corresponding to the key name according to the key name corresponding to the attribute variable may be implemented by calling resolveInstanceMethod, for example. resolveInstanceMethod can be called, resolveInstanceMethod, a method is added through a class_ addMethod function, wherein a value corresponding to the key is searched in an object according to the key of the attribute variable, and if the corresponding value is successfully found, the value is returned. If the above method addition is successful, resolveInstanceMethod is returned to YES.
Fig. 4 schematically illustrates a flow chart of a method of generating an executable file according to another embodiment of the present disclosure.
As shown in fig. 4, the method for generating an executable file further includes operation S410 before operation S240 on the basis of the foregoing embodiments.
In operation S410, an error detection code and a judgment code are constructed and added to the original code.
FIG. 5 schematically illustrates a flow chart of a method of error detection code and determination code execution according to an embodiment of the present disclosure.
As shown in fig. 5, the above-mentioned judgment code is used to perform the following operation S510 when the executable file is run, and the above-mentioned error detection code is used to perform the following operation S520 when the executable file is run.
In operation S510, if a setting operation or an acquiring operation is performed on the attribute value of the attribute variable, it is determined whether the setting operation or the acquiring operation is a preset operation.
According to an embodiment of the present disclosure, operation S510 may include, for example, determining whether a preset data structure includes a correspondence between a setting operation or an acquiring operation and an operated attribute variable when the setting operation or the acquiring operation is performed on the attribute value of the attribute variable. If the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, the setting operation or the obtaining operation is determined to be the preset operation, otherwise, the setting operation or the obtaining operation is not the preset operation.
According to an embodiment of the present disclosure, the preset data structure may be, for example, an array, a list, a map (map), or the like.
When an executable file written based on the Object-C language runs, each time a setting operation or an acquisition operation is to be performed on an attribute value of an attribute variable, a program first searches for a setting or acquisition method of the attribute variable. Based on this principle, in other embodiments, whether an operation is a preset operation may be determined by determining whether a method that the operation needs to call is a preset method. Specifically, when the program cannot find a method of a certain attribute variable, whether the correspondence between the ID of the attribute variable and the ID of the method is contained in a preset data structure may be determined according to the ID of the attribute variable and the ID of the found method. If the preset data structure contains the corresponding relation of the two IDs, determining the operation corresponding to the method as a preset operation.
In operation S520, in response to the setting operation not being a preset operation, execution of operation S320 is refused and error information is generated, and/or in response to the acquiring operation not being a preset operation, execution of operation S330 is refused and error information is generated.
According to an embodiment of the present disclosure, operation S520 may include, for example, in case the determination result obtained in operation S510 is not a preset operation, not performing the operations of S320 or S330 any more, and causing resolveInstanceMethod to return NO to generate an error message.
In summary, according to an embodiment of the present disclosure, on the one hand, an attribute variable of an original code is set to be a dynamic type, so that a setting method and an obtaining method for automatically generating the attribute variable by a compiler in a compiling stage are avoided, thereby reducing a size of a compiled executable file, and at least partially solving a problem that the executable file cannot be put on shelf in an application store because the size of the executable file exceeds a limit. On the other hand, by adding the execution code, the error detection code and the judgment code into the original code, the setting operation and the acquisition operation of the executable file runtime attribute variable can be normally performed.
In addition, according to the embodiment of the present disclosure, the execution code, the error detection code, and the determination code may be located in a parent class of the class in which the attribute variable is located, so that the attribute variable may inherit the execution code, the error detection code, and the determination code in the parent class and perform the above operation without writing a corresponding code in the class in which each attribute variable is located, thereby further reducing the size of the executable file.
Fig. 6 schematically illustrates a block diagram of an executable file generation apparatus 600 according to an embodiment of the disclosure.
As shown in fig. 6, the executable file generating apparatus 600 includes a first building module 610, a setting module 620, a second building module 630, and a generating module 640.
The first construction module 610 may perform operation S210 for constructing an original code, for example.
The setting module 620 may perform operation S220 for setting the attribute variable of the original code to a dynamic type, for example.
The second construction module 630 may, for example, perform operation S230 for constructing an execution code and adding the execution code to the original code. Wherein the execution code is constructed and added to the original code, so that when the executable file is run, in response to obtaining a setting operation for an attribute value of an attribute variable, a key value pair of the attribute variable is added to a specific object, the key value pair including a key name corresponding to the attribute variable and an attribute value to be set by the setting operation. And when the executable file runs, in response to the acquisition operation of the attribute value of the attribute variable, acquiring the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable.
The generation module 640 may perform, for example, operation S240 for generating an executable file according to the original code.
Fig. 7 schematically illustrates a block diagram of a first build module 610, according to an embodiment of the disclosure.
As shown in fig. 7, the first build module 610 may include an add sub-module 710 and an get sub-module 720.
An add sub-module 710 for adding key-value pairs of attribute variables to a particular object by invoking a parse instance method in the runtime mechanism.
The obtaining sub-module 720 is configured to obtain, from the specific object, an attribute value corresponding to the key name according to the key name corresponding to the attribute variable by calling the parsing instance method in the runtime mechanism.
Fig. 8 schematically illustrates a block diagram of an executable file generation apparatus 800 according to another embodiment of the present disclosure.
As shown in fig. 8, the executable file generating apparatus 800 may further include a third building module 810 and/or a fourth building module 820 based on the foregoing embodiments.
And a third construction module 810 for constructing and adding an error detection code to the original code such that, when the executable file is running, an operation of adding a key value pair of the attribute variable to a specific object is refused to be performed in response to the obtained setting operation not being a preset operation and error information is generated, and when the executable file is running, an operation of obtaining an attribute value corresponding to the key name is refused to be performed in response to the obtained obtaining operation not being a preset operation and error information is generated.
A fourth construction module 820, configured to construct a judging code and add the judging code to the original code, so as to judge, when the executable file runs, whether a preset data structure includes a correspondence between an operated attribute variable and a setting operation or an obtaining operation, where the preset data structure includes any one of an array, a mapping, and a list, and if the preset data structure includes the correspondence between the operated attribute variable and the setting operation or the obtaining operation, then determine that the setting operation or the obtaining operation is the preset operation, and if not, determine that the setting operation or the obtaining operation is the preset operation.
Any number of modules, sub-modules, units, sub-units, or at least some of the functionality of any number of the sub-units according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented as split into multiple modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-substrate, a system-on-package, an Application Specific Integrated Circuit (ASIC), or in any other reasonable manner of hardware or firmware that integrates or encapsulates the circuit, or in any one of or a suitable combination of three of software, hardware, and firmware. Or one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be at least partially implemented as computer program modules, which, when executed, may perform the corresponding functions.
For example, any of the first building block 610, the setup block 620, the second building block 630, the generation block 640, the addition sub-block 710, the acquisition sub-block 720, the third building block 810, and the fourth building block 820 may be combined in one block to be implemented, or any one of the blocks may be split into a plurality of blocks. Or at least some of the functionality of one or more of the modules may be combined with, and implemented in, at least some of the functionality of other modules. According to embodiments of the present disclosure, at least one of the first building block 610, the setting block 620, the second building block 630, the generating block 640, the adding sub-block 710, the obtaining sub-block 720, the third building block 810 may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-substrate, a system-on-package, an Application Specific Integrated Circuit (ASIC), or as hardware or firmware in any other reasonable manner of integrating or packaging the circuits, or as any one of or a suitable combination of any of the three implementations of software, hardware, and firmware. Or at least one of the first building module 610, the setting module 620, the second building module 630, the generating module 640, the adding sub-module 710, the obtaining sub-module 720, the third building module 810 may be at least partially implemented as a computer program module, which may perform the corresponding functions when being run.
Fig. 9 schematically illustrates a block diagram of a computer system suitable for implementing the above-described method according to an embodiment of the present disclosure. The computer system illustrated in fig. 9 is merely an example, and should not be construed as limiting the functionality and scope of use of the embodiments of the present disclosure.
As shown in fig. 9, a computer system 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 902 or a program loaded from a storage portion 908 into a Random Access Memory (RAM) 903. The processor 901 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. Processor 901 may also include on-board memory for caching purposes. Processor 901 may include a single processing unit or multiple processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the system 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other by a bus 904. The processor 901 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the program may be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the disclosure, the system 900 may also include an input/output (I/O) interface 905, the input/output (I/O) interface 905 also being connected to the bus 904. The system 900 may also include one or more of an input portion 906 including a keyboard, mouse, etc., an output portion 907 including a display such as a Cathode Ray Tube (CRT), liquid Crystal Display (LCD), etc., and speakers, etc., a storage portion 908 including a hard disk, etc., and a communication portion 909 including a network interface card such as a LAN card, modem, etc., connected to the I/O interface 905. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as needed. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on the drive 910 so that a computer program read out therefrom is installed into the storage section 908 as needed.
According to embodiments of the present disclosure, the method flow according to embodiments of the present disclosure may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from the network via the communication portion 909 and/or installed from the removable medium 911. The above-described functions defined in the system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 901. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
The present disclosure also provides a computer-readable storage medium that may be included in the apparatus/device/system described in the above embodiments, or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 902 and/or RAM 903 and/or one or more memories other than ROM 902 and RAM 903 described above.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be provided in a variety of combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
The embodiments of the present disclosure are described above. These examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be made by those skilled in the art without departing from the scope of the disclosure, and such alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (12)

1. A method of generating an executable file, comprising:
Constructing an original code;
setting the attribute variable of the original code to be a dynamic type;
building an execution code and adding the execution code to the original code, and
Generating an executable file according to the original code;
The method comprises the steps of constructing an execution code and adding the execution code into the original code, wherein when the executable file is operated, a key value pair of the attribute variable is added into a specific object in response to a setting operation for obtaining the attribute value of the attribute variable, the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation, and when the executable file is operated, in response to an obtaining operation for obtaining the attribute value of the attribute variable, the attribute value corresponding to the key name is obtained from the specific object according to the key name corresponding to the attribute variable.
2. The method according to claim 1, wherein:
The adding the key value pair of the attribute variable to the specific object includes adding the key value pair of the attribute variable to the specific object by calling a resolved instance method in a runtime mechanism, and
The step of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable comprises the step of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable by calling an analysis instance method in a runtime mechanism.
3. The method of claim 1 or 2, further comprising:
Constructing an error detection code and adding the error detection code to the original code such that, when an executable file is running, in response to the obtained set operation not being a preset operation, refusing to perform an operation of adding a key value pair of the attribute variable to a specific object and generating error information, and
And when the executable file runs, refusing to execute the operation of obtaining the attribute value corresponding to the key name and generating error information in response to the obtained obtaining operation not being a preset operation.
4. A method according to claim 3, further comprising:
Constructing a judging code and adding the judging code into the original code, so as to judge whether the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation is included in a preset data structure when the executable file runs, wherein the preset data structure comprises any one of an array, a mapping, a list and
If the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining that the setting operation or the obtaining operation is the preset operation, otherwise, determining that the setting operation or the obtaining operation is not the preset operation.
5. The method of claim 4, wherein the execution code and/or error detection code and/or judgment code is located in a parent class of the class in which the attribute variable is located.
6. An executable file generation device, comprising:
The first construction module is used for constructing an original code;
The setting module is used for setting the attribute variable of the original code to be a dynamic type;
A second construction module for constructing an execution code and adding the execution code to the original code, and
The generation module is used for generating an executable file according to the original codes;
The method comprises the steps of constructing an execution code and adding the execution code into the original code, wherein when the executable file is operated, a key value pair of the attribute variable is added into a specific object in response to a setting operation for obtaining the attribute value of the attribute variable, the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation, and when the executable file is operated, in response to an obtaining operation for obtaining the attribute value of the attribute variable, the attribute value corresponding to the key name is obtained from the specific object according to the key name corresponding to the attribute variable.
7. The apparatus of claim 6, wherein the first build module comprises:
An adding sub-module for adding the key value pair of the attribute variable to the specific object by calling a resolved instance method in a runtime mechanism, and
And the obtaining submodule is used for obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable by calling the analysis instance method in the runtime mechanism.
8. The apparatus of claim 6 or 7, further comprising:
A third construction module for constructing an error detection code and adding the error detection code to the original code such that, when the executable file is running, the execution of the operation of adding the key value pair of the attribute variable to a specific object and the generation of error information are refused in response to the obtained set operation being not a preset operation, and
And when the executable file runs, refusing to execute the operation of obtaining the attribute value corresponding to the key name and generating error information in response to the obtained obtaining operation not being a preset operation.
9. The apparatus of claim 8, further comprising:
A fourth construction module for constructing a judgment code and adding the judgment code to the original code, so as to judge whether the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation is included in a preset data structure when the executable file runs, wherein the preset data structure comprises any one of an array, a mapping, a list and
If the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining that the setting operation or the obtaining operation is the preset operation, otherwise, determining that the setting operation or the obtaining operation is not the preset operation.
10. The apparatus of claim 9, wherein the execution code and/or error detection code and/or judgment code is located in a parent class of a class in which the attribute variable is located.
11. A system for generating an executable file, comprising:
One or more processors;
Storage means for storing one or more programs,
Wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1 to 5.
12. A computer readable storage medium having stored thereon executable instructions which when executed by a processor cause the processor to implement the method of any one of claims 1 to 5.
CN201910495960.2A 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file Active CN112068814B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910495960.2A CN112068814B (en) 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910495960.2A CN112068814B (en) 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file

Publications (2)

Publication Number Publication Date
CN112068814A CN112068814A (en) 2020-12-11
CN112068814B true CN112068814B (en) 2025-01-14

Family

ID=73657963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910495960.2A Active CN112068814B (en) 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file

Country Status (1)

Country Link
CN (1) CN112068814B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114428823B (en) * 2022-01-28 2022-11-01 北京国电通网络技术有限公司 Data linkage method, device, device and medium based on multidimensional variable expression

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081546A (en) * 2009-11-30 2011-06-01 国际商业机器公司 Memory optimization of virtual machine code by partitioning extraneous information
CN105493042A (en) * 2013-08-30 2016-04-13 苹果公司 Concurrent accesses of dynamically typed object data

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9117071B2 (en) * 2009-06-03 2015-08-25 Apple Inc. Methods and apparatuses for secure compilation
US9104434B2 (en) * 2013-12-20 2015-08-11 Microsoft Technology Licensing, Llc Property accesses in dynamically typed programming languages
US9424003B1 (en) * 2014-10-24 2016-08-23 Emc Corporation Schema-less system output object parser and code generator
CN107784231B (en) * 2016-08-24 2021-06-08 顶象科技有限公司 Instruction execution and dynamic compiling method and device and electronic equipment
CN108089852B (en) * 2017-12-15 2020-08-04 网易(杭州)网络有限公司 Method, medium, apparatus and computing device for establishing attribute access

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081546A (en) * 2009-11-30 2011-06-01 国际商业机器公司 Memory optimization of virtual machine code by partitioning extraneous information
CN105493042A (en) * 2013-08-30 2016-04-13 苹果公司 Concurrent accesses of dynamically typed object data

Also Published As

Publication number Publication date
CN112068814A (en) 2020-12-11

Similar Documents

Publication Publication Date Title
CN111221521B (en) Log code generation method, device, computer system and readable storage medium
CN109325195B (en) Rendering method and system for browser, computer device and computer storage medium
US10042746B2 (en) Callpath finder
CN113778848A (en) Test code generation method, device, computer system and medium
CN110895471B (en) Installation package generation method, device, medium and electronic device
CN106547527B (en) JavaScript file construction method and device
US9268854B2 (en) Analytics based on pipes programming model
US20210224055A1 (en) Data interface processing method, device, server and medium
CN113419740B (en) Program data stream analysis method and device, electronic equipment and readable storage medium
CN112965916B (en) Page testing method, page testing device, electronic equipment and readable storage medium
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN115599386A (en) Code generation method, device, equipment and storage medium
CN113761871A (en) Rich text rendering method and device, electronic equipment and storage medium
CN115982491A (en) Page updating method and device, electronic equipment and computer readable storage medium
CN113986402A (en) Function calling method and device, electronic equipment and storage medium
CN116560661A (en) Code optimization method, device, equipment and storage medium
CN111694639A (en) Method and device for updating address of process container and electronic equipment
CN112068814B (en) Method, device, system and medium for generating executable file
CN114254232B (en) Cloud product page generation method, device, computer equipment and storage medium
CN113805878B (en) Plug-in engineering method, device, computer system and medium
CN106502707B (en) Code generation method and device
US12001458B2 (en) Multi-cloud object store access
CN114115908B (en) Instruction set generation, program analysis method, device, equipment and storage medium
CN112506781B (en) Test monitoring method, device, electronic equipment, storage medium and program product
CN115809193A (en) Front-end reverse abnormal data robustness detection method, device and storage medium

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