Method, device, system and medium for generating executable file
By setting the attribute variable to dynamic type and building the execution code in the executable file, the problem of excessive executable file size is solved, and the effect of reducing file size without affecting business logic and pages is achieved.
Patent Information
- Application Number
- CN201910495960.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-10
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2039-06-10
AI Technical Summary
In the prior art, the business logic and page complexity of the application lead to a large amount of executable files and occupies a large amount of storage space. How to reduce the size of the executable files without affecting the business logic and pages is an urgent solution. The problem.
By setting the attribute variables of the original code to dynamic types, building the execution code and adding them to the original code, so that the setting and obtaining operations of the attribute variables at runtime are used to add key-value pairs to specific objects using the runtime mechanism to respond to the settings and acquisition operations of the attribute variables. , and determine the legality of the operation in the preset data structure, and reject non-preset operations to generate error information.
It effectively reduces the size of the executable file, reduces the use of system storage space, and ensures that the setting and acquisition of attribute variables are carried out normally.
Smart Images

Figure CN112068814B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computers, and in particular to a method, device, system and medium for generating an executable file. Background Art
[0002] An executable file is a file that can be loaded and executed by an operating system. An executable file is a component of an application, and an application needs to rely on an executable file to run. In different operating system environments, executable programs are presented differently. For example, in Apple's iOS operating system, the executable file format is Mach-O (Mach Object file format).
[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following problems in the prior art: the more complex the business logic and pages of an application are, the larger the data volume of its executable file is, and the larger the storage space it occupies. How to reduce the data volume of the executable file without affecting the business logic and pages is an urgent problem to be solved. Summary of the invention
[0004] In view of this, one aspect of the present disclosure provides a method, device, system and medium for generating an executable file.
[0005] One aspect of the present disclosure provides a method for generating an executable file. The method includes: 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 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, in response to obtaining a setting operation for an attribute value of the attribute variable, a key-value pair of the attribute variable is added to a specific object, the key-value pair includes 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 obtaining a get operation for 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.
[0006] According to an embodiment of the present disclosure, the adding of the key-value pair of the attribute variable to the specific object includes, by calling the parsing instance method in the runtime mechanism, adding the key-value pair of the attribute variable to the specific object. The obtaining of the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable includes, by calling the parsing instance method in the runtime mechanism, according to the key name corresponding to the attribute variable, obtaining the attribute value corresponding to the key name from the specific object.
[0007] According to an embodiment of the present disclosure, the method for generating an executable file also includes: constructing an error detection code and adding the error detection code to the original code, so that when the executable file is running, in response to the obtained setting operation being not a preset operation, the operation of adding the key-value pair of the attribute variable to the specific object is refused to be executed, and an error message is generated; and when the executable file is running, in response to the obtained getting operation being not a preset operation, the operation of obtaining the attribute value corresponding to the key name is refused to be executed, and an error message is generated.
[0008] According to an embodiment of the present disclosure, the method for generating an executable file further includes: constructing a judgment code and adding the judgment code to the original code, so that when the executable file is running, it is judged whether the preset data structure includes the corresponding relationship between the operated attribute variable and the setting operation or the acquisition operation, and the preset data structure includes any one of the following: array, mapping, list. And if the preset data structure includes the corresponding relationship between the operated attribute variable and the setting operation or the acquisition operation, it is determined that the setting operation or the acquisition operation is the preset operation; otherwise, it is determined that the setting operation or the acquisition operation is not the preset operation.
[0009] According to an embodiment of the present disclosure, the execution code and / or the error detection code and / or the judgment code are located in a parent class of the class where the attribute variable is located.
[0010] Another aspect of the present disclosure provides a device for generating an executable file, including: a first construction module, a setting module, a second construction module and a generation module. The first construction module is used to construct the original code. The setting module is used to set the attribute variables of the original code to dynamic types. The second construction module constructs the execution code and adds the execution code to the original code. The generation module is used to generate an executable file based on the original code. Among them, 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 the attribute value of the attribute variable, a key-value pair of the attribute variable is added to a specific object, and the key-value pair includes 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 running, in response to obtaining a get operation for 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.
[0011] According to an embodiment of the present disclosure, the first construction module includes: an adding submodule, which is used to add the key-value pair of the attribute variable to a specific object by calling the parsing instance method in the runtime mechanism; and an obtaining submodule, which is used to obtain 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 parsing instance method in the runtime mechanism.
[0012] According to an embodiment of the present disclosure, the apparatus for generating an executable file further includes: a third construction module for constructing an error detection code and adding the error detection code to the original code, so that when the executable file is running, in response to the obtained setting operation not being a preset operation, the operation of adding the key-value pair of the attribute variable to the specific object is refused to be executed, and an error message is generated. And when the executable file is running, in response to the obtained acquisition operation not being a preset operation, the operation of obtaining the attribute value corresponding to the key name is refused to be executed, and an error message is generated.
[0013] According to an embodiment of the present disclosure, the device for generating an executable file further includes: a fourth construction module, which is used to construct a judgment code and add the judgment code to the original code, so that when the executable file is running, it is determined whether the preset data structure includes the corresponding relationship between the operated attribute variable and the setting operation or the acquisition operation, and the preset data structure includes any one of the following: array, mapping, list. And if the preset data structure includes the corresponding relationship between the operated attribute variable and the setting operation or the acquisition operation, it is determined that the setting operation or the acquisition operation is a preset operation; otherwise, it is determined that the setting operation or the acquisition operation is not a preset operation.
[0014] According to an embodiment of the present disclosure, the execution code and / or the error detection code and / or the judgment code are located in a parent class of the class where the attribute variable is located.
[0015] Another aspect of the present disclosure provides a system for generating an executable file. The system includes one or more processors and a memory for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors execute the method as described above.
[0016] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.
[0017] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and the instructions are used to implement the method described above when executed.
[0018] According to the embodiment of the present disclosure, by setting the attribute variable of the original code as a dynamic type, constructing the original code and adding it to the original code to generate the original code, an executable file is generated according to the original code. Thus, while ensuring that the setting and obtaining operations of the attribute variables are normal, the size of the executable file is reduced, and the occupation of the system storage space is also reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] For a more complete understanding of the present disclosure and its advantages, reference will now be made to the following description taken in conjunction with the accompanying drawings, in which:
[0020] Figure 1 The application scenario of the method and device for generating an executable file according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 2 A flowchart schematically shows a method for generating an executable file according to an embodiment of the present disclosure;
[0022] Figure 3 A flowchart schematically shows a method executed by an execution code according to an embodiment of the present disclosure;
[0023] Figure 4 A flowchart schematically shows a method for generating an executable file according to another embodiment of the present disclosure;
[0024] Figure 5 A flowchart schematically shows an error detection code and a method for determining code execution according to an embodiment of the present disclosure;
[0025] Figure 6 The structure block diagram of the device for generating an executable file according to an embodiment of the present disclosure is schematically shown;
[0026] Figure 7 Schematically shows a structural block diagram of a first building block according to an embodiment of the present disclosure;
[0027] Figure 8 A structural block diagram schematically shows a device for generating an executable file according to another embodiment of the present disclosure; and
[0028] Fig. 9 The block diagram of a computer system suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0029] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0030] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0031] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0032] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0033] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some boxes or combinations thereof in the block diagrams and / or flow charts can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that these instructions can create a device for implementing the functions / operations described in these block diagrams and / or flow charts when executed by the processor. The technology of the present disclosure can be implemented in the form of hardware and / or software (including firmware, microcode, etc.). In addition, the technology of the present disclosure can take the form of a computer program product on a computer-readable storage medium storing instructions, which can be used by an instruction execution system or used in conjunction with an instruction execution system.
[0034] The embodiment of the present disclosure provides a method for generating an executable file and a device capable of applying the method. The method includes constructing an original code, setting the attribute variables of the original code as dynamic types, constructing an execution code and adding the execution code to the original code, and generating an executable file based on the original code. 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 the attribute value of the attribute variable, a key-value pair of the attribute variable is added to a specific object. The key-value pair includes 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 obtaining a get operation for the attribute value of the attribute variable, the attribute value corresponding to the key name is obtained from a specific object according to the key name corresponding to the attribute variable.
[0035] Figure 1 The application scenario of the method and device for generating an executable file according to an embodiment of the present disclosure is schematically shown. It should be noted that: Figure 1 The examples shown are merely scenarios in which the embodiments of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0036] like Figure 1 As shown, the 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 to provide a medium for 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 optical fiber cables, etc.
[0037] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. The terminal devices 101, 102, 103 can run executable files of various applications, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0038] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0039] The server 105 may be a server that provides various services, such as a compiling server (only as an example). The compiling server may construct the 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.
[0040] It should be noted that the method for generating an executable file provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the device for generating an executable file provided in the embodiment of the present disclosure can generally be set in the server 105. The method for generating an executable file provided in the embodiment of the present disclosure can also be executed by a server or a server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the device for generating an executable file provided in the embodiment of the present disclosure can also be set in a server or a server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0041] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0042] Figure 2 The flowchart of the method for generating an executable file according to an embodiment of the present disclosure is schematically shown.
[0043] like Figure 2 As shown, the method includes operations S210 to S230.
[0044] In operation S210, original code is constructed.
[0045] According to an embodiment of the present disclosure, the original code may be, for example, an application code written in the Objective-C language. Objective-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 expands C. The OC language can be used to develop iOS executable files.
[0046] In operation S220, the attribute variable of the original code is set to a dynamic type.
[0047] For non-dynamic type attribute variables, the compiler will automatically add the attribute variable setting method (setter) and acquisition method (getter) in the executable file code during compilation, while the compiler will not automatically add the attribute variable setter and getter after the attribute variable is set to dynamic type, which can reduce the size of the executable file. Based on this principle, in operation S220, the attribute variable in the original code is set to dynamic type.
[0048] In operation S230, an execution code is constructed and added to the original code.
[0049] In operation S240, an executable file is generated according to the original code.
[0050] Figure 3 The flowchart schematically shows a method executed by an execution code according to an embodiment of the present disclosure.
[0051] like Figure 3 As shown, the function of the above execution code is to perform the following operations S310 to S330 when running the executable file:
[0052] In operation S310, the object object is initialized.
[0053] The above object is a type that can store key-value pairs (for example<key,value> ) data structure and can be read and written by external methods.
[0054] According to the embodiments of the present disclosure, the object object may be implemented as various data structures such as a class, a structure, a linked list, an array, etc.
[0055] In operation S320, when the application is going to perform a setting operation on the property value of the property variable, the key-value pair of the property variable is added to a specific object.
[0056] The key-value pair includes a key name corresponding to the attribute variable and an attribute value to be set by the setting operation.
[0057] According to an embodiment of the present disclosure, operation S320 may include, for example, obtaining a key name key corresponding to the attribute variable and a property value value to be set by the setting operation, and then converting the key-value pair composed of the key and value into<key,value> According to an embodiment of the present disclosure, the operation of adding the key-value pair of the attribute variable to a specific object can be implemented by, for example, calling a resolveInstanceMethod method in a runtime mechanism. The resolveInstanceMethod can be called, and the following method can be added in the resolveInstanceMethod through the class_addMethod function:<key,value> Add to the above initialized object, where key is the key name corresponding to the attribute variable and value is the attribute value to be set. If the above method is added successfully, resolveInstanceMethod returns YES.
[0058] In operation S330, when the application is about to perform an acquisition operation on the property value of the property variable, the property value corresponding to the key name is obtained from the specific object according to the key name corresponding to the property variable.
[0059] According to an embodiment of the present disclosure, operation S330 may include, for example, when an application wants to perform an acquisition operation on the attribute value of the attribute variable, first obtaining the key name key of the attribute variable being operated, and then searching for the attribute value value corresponding to the key in the object according to the key, and if the corresponding value is successfully found, returning the value.
[0060] According to an embodiment of the present disclosure, the above operation of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable can be implemented by calling resolveInstanceMethod, for example. resolveInstanceMethod can be called, and the following method is added in resolveInstanceMethod through the class_addMethod function: according to the key of the attribute variable, search for the value corresponding to the key in the object; if the corresponding value is successfully found, return the value. If the above method is added successfully, resolveInstanceMethod returns YES.
[0061] Figure 4 The flowchart schematically shows a method for generating an executable file according to another embodiment of the present disclosure.
[0062] like Figure 4 As shown, the method for generating an executable file, based on the above-mentioned embodiment, further includes operation S410 before operation S240.
[0063] In operation S410, an error detection code and a judgment code are constructed and added to the original code.
[0064] Figure 5 The flowchart schematically shows an error detection code and a method for determining code execution according to an embodiment of the present disclosure.
[0065] like Figure 5 As shown, the above judgment code is used to perform the following operation S510 when running the executable file, and the above error detection code is used to perform the following operation S520 when running the executable file.
[0066] In operation S510, if a setting operation or a obtaining operation is performed on the attribute value of the attribute variable, it is determined whether the setting operation or the obtaining operation is a preset operation.
[0067] According to an embodiment of the present disclosure, operation S510 may include, for example, determining whether a preset data structure includes a corresponding relationship between the setting operation or the obtaining operation and the attribute variable being operated when performing a setting operation or an obtaining operation on the attribute value of the attribute variable. If the preset data structure includes a corresponding relationship between the attribute variable being operated and the setting operation or the obtaining operation, then determining that the setting operation or the obtaining operation is a preset operation; otherwise, the setting operation or the obtaining operation is not a preset operation.
[0068] According to an embodiment of the present disclosure, the above-mentioned preset data structure may be, for example, an array, a list, a map, etc.
[0069] When an executable file written in the Object-C language is running, whenever an attribute value of an attribute variable needs to be set or obtained, the program will first look for a method for setting or obtaining the attribute variable. Based on this principle, in other embodiments, whether the operation is a preset operation can be determined by determining whether the method required to be called for the operation is a preset method. Specifically, when the program cannot find a method for a certain attribute variable, it determines whether the correspondence between the attribute variable ID and the method ID is included in a preset data structure based on the ID of the attribute variable and the ID of the method being found. If the preset data structure contains the correspondence between the two IDs, it is determined that the operation corresponding to the method is a preset operation.
[0070] In operation S520, in response to the setting operation not being a preset operation, operation S320 is rejected and an error message is generated; and / or, in response to the obtaining operation not being a preset operation, operation S330 is rejected and an error message is generated.
[0071] According to an embodiment of the present disclosure, operation S520 may include, for example, if the judgment result obtained in operation S510 is not a preset operation, no longer performing the operation of S320 or S330, and making resolveInstanceMethod return NO to generate error information.
[0072] In summary, according to the embodiments of the present disclosure, on the one hand, the attribute variables of the original code are set to dynamic types, so as to avoid the compiler automatically generating the setting method and obtaining method of the attribute variables during the compilation stage, thereby reducing the size of the compiled executable file, and at least partially solving the problem that the executable file cannot be put on the App Store because the size exceeds the limit. On the other hand, by adding execution code, error detection code and judgment code to the original code, the attribute variables of the executable file can be set and obtained normally when it is running.
[0073] In addition, according to an embodiment of the present disclosure, the above-mentioned execution code, error detection code and judgment code can be located in the parent class of the class where the attribute variable is located, so that the above-mentioned attribute variable can inherit the above-mentioned execution code, error detection code and judgment code in the parent class and perform the above-mentioned operations without having to write corresponding codes in the class where each attribute variable is located, thereby further reducing the size of the executable file.
[0074] Figure 6 The block diagram of the apparatus 600 for generating an executable file according to an embodiment of the present disclosure is schematically shown.
[0075] like Figure 6 As shown, the executable file generation device 600 includes a first construction module 610 , a setting module 620 , a second construction module 630 and a generation module 640 .
[0076] The first construction module 610 may, for example, perform operation S210 to construct the original code.
[0077] The setting module 620 may, for example, perform operation S220 for setting the attribute variable of the original code to a dynamic type.
[0078] The second construction module 630 can, for example, perform operation S230 to construct an execution code and add the execution code to the original code. 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 the attribute value of the attribute variable, a key-value pair of the attribute variable is added to a specific object, the key-value pair including the key name corresponding to the attribute variable and the attribute value to be set by the setting operation. And when the executable file is run, in response to obtaining a get operation for 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.
[0079] The generating module 640 may, for example, perform operation S240 to generate an executable file according to the original code.
[0080] Figure 7 The block diagram of the first building module 610 according to an embodiment of the present disclosure is schematically shown.
[0081] like Figure 7 As shown, the first building module 610 may include an adding submodule 710 and an obtaining submodule 720 .
[0082] The adding submodule 710 is used to add the key-value pair of the attribute variable to a specific object by calling the parsing instance method in the runtime mechanism.
[0083] The acquisition submodule 720 is used to obtain 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 parsing instance method in the runtime mechanism.
[0084] Figure 8 A block diagram of an executable file generating device 800 according to another embodiment of the present disclosure is schematically shown.
[0085] like Figure 8 As shown, the executable file generation device 800 may further include a third construction module 810 and / or a fourth construction module 820 based on the above-mentioned embodiment.
[0086] The third construction module 810 is used to construct an error detection code and add the error detection code to the original code, so that when the executable file is running, in response to the obtained setting operation not being a preset operation, the operation of adding the key-value pair of the attribute variable to the specific object is refused to be executed, and an error message is generated; and when the executable file is running, in response to the obtained getting operation not being a preset operation, the operation of obtaining the attribute value corresponding to the key name is refused to be executed, and an error message is generated.
[0087] The fourth construction module 820 is used to construct a judgment code and add the judgment code to the original code, so that when the executable file is running, it is determined whether the preset data structure includes the correspondence between the operated attribute variables and the setting operation or the acquisition operation, and the preset data structure includes any one of the following: array, mapping, list; and if the preset data structure includes the correspondence between the operated attribute variables and the setting operation or the acquisition operation, it is determined that the setting operation or the acquisition operation is the preset operation; otherwise, it is determined that the setting operation or the acquisition operation is not the preset operation.
[0088] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.
[0089] For example, any multiple of the first building module 610, the setting module 620, the second building module 630, the generation module 640, the adding submodule 710, the obtaining submodule 720, the third building module 810 and the fourth building module 820 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first building module 610, the setting module 620, the second building module 630, the generation module 640, the adding submodule 710, the obtaining submodule 720, and the third building module 810 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the first building module 610, the setting module 620, the second building module 630, the generating module 640, the adding submodule 710, the obtaining submodule 720, and the third building module 810 may be at least partially implemented as a computer program module, which may perform corresponding functions when the computer program module is executed.
[0090] Fig. 9 The block diagram of a computer system suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. Fig. 9The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0091] like Fig. 9 As shown, the computer system 900 according to the embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 908 to the random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.
[0092] In RAM 903, various programs and data required for the operation of system 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other through bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0093] According to an embodiment of the present disclosure, the system 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The system 900 may further include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A 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, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0094] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0095] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0096] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0097] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0098] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0099] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes 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 various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for generating an executable file, comprising: Build the original code; Setting the attribute variable of the original code to a dynamic type; Building an execution code and adding the execution code to the original code; as well as Generate an executable file according to the original code; Among them, an 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 the property value of the property variable, a key-value pair of the property variable is added to a specific object, and the key-value pair includes a key name corresponding to the property variable and the property value to be set by the setting operation; and when the executable file is run, in response to obtaining a get operation for the property value of the property variable, the property value corresponding to the key name is obtained from the specific object according to the key name corresponding to the property variable.
2. The method according to claim 1, wherein: 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 parsing instance method in a runtime mechanism; as well as The method of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable includes 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 a parsing instance method in a runtime mechanism.
3. The method according to claim 1 or 2, further comprising: Building an error detection code and adding the error detection code to the original code, so that when the executable file is running, in response to the obtained setting operation not being a preset operation, the operation of adding the key-value pair of the attribute variable to the specific object is refused to be executed, and an error message is generated; as well as When the executable file is running, in response to the obtained acquisition operation not being a preset operation, the operation of obtaining the attribute value corresponding to the key name is refused to be executed, and an error message is generated.
4. The method according to claim 3, further comprising: Constructing a judgment code and adding the judgment code to the original code, so that when the executable file is running, it is judged whether a preset data structure includes a corresponding relationship between the operated attribute variable and the setting operation or the obtaining operation, and the preset data structure includes any one of the following: an array, a mapping, and a list; as well as If the preset data structure includes a correspondence between the operated attribute variable and the setting operation or the obtaining operation, the setting operation or the obtaining operation is determined to be a preset operation; otherwise, the setting operation or the obtaining operation is determined not to be a preset operation.
5. The method according to claim 4, wherein: The execution code and / or the error detection code and / or the judgment code are located in the parent class of the class where the attribute variable is located.
6. A device for generating an executable file, comprising: The first building block is used to build the original code; A setting module, used for setting the attribute variable of the original code to a dynamic type; A second construction module constructs an execution code and adds the execution code to the original code; as well as A generation module, used to generate an executable file according to the original code; Among them, an 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 the property value of the property variable, a key-value pair of the property variable is added to a specific object, and the key-value pair includes a key name corresponding to the property variable and the property value to be set by the setting operation; and when the executable file is run, in response to obtaining a get operation for the property value of the property variable, the property value corresponding to the key name is obtained from the specific object according to the key name corresponding to the property variable.
7. The device according to claim 6, wherein: The first building block comprises: An adding submodule, used to add the key-value pair of the attribute variable to the specific object by calling a parsing instance method in a runtime mechanism; and The obtaining submodule is used to obtain 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 parsing instance method in the runtime mechanism.
8. The device according to claim 6 or 7, further comprising: A third construction module is used to construct an error detection code and add the error detection code to the original code, so that when the executable file is running, in response to the obtained setting operation not being a preset operation, the operation of adding the key-value pair of the attribute variable to the specific object is refused to be executed, and an error message is generated; as well as When the executable file is running, in response to the obtained acquisition operation not being a preset operation, the operation of obtaining the attribute value corresponding to the key name is refused to be executed, and an error message is generated.
9. The apparatus according to claim 8, further comprising: a fourth construction module, for constructing a judgment code and adding the judgment code to the original code, so that when the executable file is running, it is determined whether a preset data structure includes a corresponding relationship between the operated attribute variable and the setting operation or the obtaining operation, and the preset data structure includes any one of the following: an array, a mapping, and a list; as well as If the preset data structure includes a correspondence between the operated attribute variable and the setting operation or the obtaining operation, the setting operation or the obtaining operation is determined to be a preset operation; otherwise, the setting operation or the obtaining operation is determined not to be a preset operation.
10. The device according to claim 9, wherein: The execution code and / or the error detection code and / or the judgment code are located in the parent class of the class where the attribute variable is located.
11. A system for generating an executable file, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1 to 5.
12. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to implement the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Memory optimization of virtual machine code by partitioning extraneous information
CN102081546A
Concurrent accesses of dynamically typed object data
CN105493042A