CN116010147A - Method, system, electronic device and storage medium for generating exception handling table - Google Patents

Method, system, electronic device and storage medium for generating exception handling table Download PDF

Info

Publication number
CN116010147A
CN116010147A CN202211693341.2A CN202211693341A CN116010147A CN 116010147 A CN116010147 A CN 116010147A CN 202211693341 A CN202211693341 A CN 202211693341A CN 116010147 A CN116010147 A CN 116010147A
Authority
CN
China
Prior art keywords
execution
exception handling
code
statement
exception
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211693341.2A
Other languages
Chinese (zh)
Inventor
李士成
莫文盼
蔡路
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Eastcompeace Technology Co Ltd
Original Assignee
Eastcompeace 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 Eastcompeace Technology Co Ltd filed Critical Eastcompeace Technology Co Ltd
Priority to CN202211693341.2A priority Critical patent/CN116010147A/en
Publication of CN116010147A publication Critical patent/CN116010147A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The application provides a generation method, a system, electronic equipment and a storage medium of an exception handling table, wherein the method comprises the following steps: acquiring a statement block to be analyzed, wherein the statement block to be analyzed comprises an execution statement and an exception handling statement; based on the stack structure, respectively carrying out corresponding push marking on the execution statement and the exception handling statement to obtain a marked statement block containing marking information; according to the stack sequence of the stack structure, compiling and analyzing the mark statement blocks in sequence to obtain an intermediate code containing mark information, wherein the intermediate code comprises an execution code and an exception handling code; and screening and removing the exception handling instructions from the execution codes through the marking information and the stack sequence to generate an exception handling table, wherein the exception handling instructions comprise exception handling codes. The embodiment of the application aims to reduce the entries of the exception handling table and realize the running of an exception handling mechanism on the equipment with limited resources.

Description

Method, system, electronic device and storage medium for generating exception handling table
Technical Field
The present invention relates to the field of compiler technologies, and in particular, to a method, a system, an electronic device, and a storage medium for generating an exception handling table.
Background
Currently conventional high-level languages, such as c++, java, python, ruby, scala, and Swift, require support for exception handling (Exception Handling) mechanisms. The exception handling mechanism is a program operation fault recovery mechanism and can better handle the situation that the program cannot normally operate. Statement blocks with the function of capturing and processing the exception are usually set in the traditional high-level language, and a compiler in the related art forms a large number of exception table entries for processing the exception after the exception capturing and processing, but cannot store a large number of exception table entries on the resource-limited device, so that the exception processing is difficult on the resource-limited device. Therefore, how to generate an exception handling table on a device with limited resources becomes a technical problem to be solved.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The main purpose of the embodiment of the application is to provide a method, a system, electronic equipment and a storage medium for generating an exception handling table, aiming at reducing the entries of the exception handling table and realizing the operation of an exception handling mechanism on equipment with limited resources.
In order to achieve the above object, a first aspect of an embodiment of the present application provides a method for generating an exception handling table, where the method includes:
acquiring a statement block to be analyzed, wherein the statement block to be analyzed comprises an execution statement and an exception handling statement;
based on a stack structure, respectively carrying out corresponding push marks on the execution statement and the exception handling statement to obtain a marked statement block containing marking information;
according to the stack sequence of the stack structure, compiling and analyzing the marked statement blocks in sequence to obtain intermediate codes containing the marked information, wherein the intermediate codes comprise execution codes and exception handling codes;
and screening out an exception handling instruction from the execution codes through the marking information and the stack sequence to generate an exception handling table, wherein the exception handling instruction comprises the exception handling codes.
In some embodiments, according to the stack order of the stack structure, the compiling and parsing are sequentially performed on the tag statement blocks to obtain an intermediate code containing the tag information, including:
sequentially analyzing the marked statement blocks according to the stack sequence of the stack structure to obtain an intermediate execution code and an exception handling code;
Copying the exception processing code to a position in the intermediate execution code before the return instruction under the condition that the return instruction exists in the execution statement, so as to obtain an execution code;
inserting a jump instruction for jumping to the exception handling code from the intermediate execution code to obtain an execution code when no return instruction exists in the execution statement;
and comprehensively sequencing the execution codes and the exception handling codes according to the stack structure to obtain intermediate codes containing the marking information.
In some embodiments, the filtering out the exception handling instruction from the execution code by the tag information and the stack order to generate an exception handling table includes:
determining a first range of the execution code and a second range of the exception handling code through the marking information and the stack order;
when the execution code includes the exception handling code, the second range is eliminated from the first range, and a plurality of exception intervals are generated;
and merging the plurality of abnormal sections to generate an abnormal processing table.
In some embodiments, the tag information includes an execution tag for tagging the execution statement and an exception handling tag for tagging the exception handling statement;
The determining, by the tag information and the stack order, a first range of the execution code and a second range of the exception handling code includes:
determining an execution start position and an execution end position by using the execution mark and the stack sequence, and determining a first range of the execution code according to the execution start position and the execution end position;
determining an abnormal starting position and an abnormal ending position by using the abnormal processing mark and the stack sequence, and determining a second range of the abnormal processing code according to the abnormal starting position and the abnormal ending position;
wherein the first range includes the execution start position and the execution end position, and the second range includes the abnormality start position and the abnormality end position.
In some embodiments, the execution code includes exception capture code, the exception capture code including a plurality of exception types;
the determining, by using the execution flag and the stack order, an execution start position and an execution end position, and determining, according to the execution start position and the execution end position, a first range of the execution code includes:
Determining an abnormality capturing mark corresponding to the abnormality capturing code from the execution code according to the abnormality type and the stack sequence;
determining a plurality of execution start positions and a plurality of execution end positions by using the execution marks, the abnormality capturing marks and the stack sequence, wherein each execution start position corresponds to each execution end position one by one;
and determining a plurality of first ranges according to the execution starting positions and the execution ending positions, wherein the first ranges comprise the execution marks and the abnormality capturing marks.
In some embodiments, the anomaly interval includes the anomaly capture tag;
the merging the plurality of abnormal intervals to generate an abnormal processing table comprises the following steps:
and merging the abnormal sections which have the same abnormal capturing mark and are continuous in section to generate an abnormal processing table.
In some embodiments, the executing code includes, when the exception handling code, culling the second range from the first range, generating a plurality of exception intervals;
and when the abnormality start position and the abnormality end position are both between the execution start position and the execution end position, determining a first abnormality section by using the execution start position and the abnormality start position, and determining a second abnormality section by using the abnormality end position and the execution end position.
To achieve the above object, a second aspect of the embodiments of the present application proposes a system for generating an exception handling table, the system including:
the sentence acquisition module is used for acquiring a sentence block to be analyzed, wherein the sentence block to be analyzed comprises an execution sentence and an exception handling sentence;
the statement marking module is used for respectively carrying out corresponding push marking on the execution statement and the exception handling statement based on a stack structure to obtain a marked statement block containing marking information;
the compiling and analyzing module is used for sequentially compiling and analyzing the mark statement blocks according to the stack sequence of the stack structure to obtain intermediate codes containing the mark information, wherein the intermediate codes comprise execution codes and exception handling codes;
and the exception table generation module is used for screening out exception processing instructions from the execution codes through the marking information and the stack sequence to generate an exception processing table, wherein the exception processing instructions comprise the exception processing codes.
To achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, where the electronic device includes a memory and a processor, where the memory stores a computer program, and the processor implements the method for generating the exception handling table according to the first aspect when executing the computer program.
In order to achieve the above object, a fourth aspect of the embodiments of the present application proposes a storage medium, which is a computer-readable storage medium storing a computer program that when executed by a processor implements the method for generating an exception handling table according to the first aspect.
The application provides a generation method, a system, electronic equipment and a storage medium of an exception handling table, wherein the method comprises the following steps: acquiring a statement block to be analyzed, wherein the statement block to be analyzed comprises an execution statement and an exception handling statement; based on the stack structure, respectively carrying out corresponding push marking on the execution statement and the exception handling statement to obtain a marked statement block containing marking information; according to the stack sequence of the stack structure, compiling and analyzing the mark statement blocks in sequence to obtain an intermediate code containing mark information, wherein the intermediate code comprises an execution code and an exception handling code; and screening and removing the exception handling instructions from the execution codes through the marking information and the stack sequence to generate an exception handling table, wherein the exception handling instructions comprise exception handling codes. According to the technical scheme, the statement blocks to be analyzed are split and marked through the stack structure to form the marked statement blocks, and the marked statement blocks are compiled sequentially according to the stacking sequence. However, the exception handling statement is not exception information, so that the position and the range of the exception handling code are determined through the compiled execution code and the corresponding marking information and stack sequence of the exception handling code, the exception handling instruction containing the exception handling code is removed from the execution code, a large number of continuous exception capturing ranges in the execution code are split into a plurality of exception capturing sections, small-granularity exception handling table information is realized, and meanwhile, exception handling table entries are reduced, so that optimization of a traditional exception handling table is realized, and an exception handling mechanism can be operated on equipment with limited resources.
Drawings
FIG. 1 is a flow chart of steps of a method for generating an exception handling table provided by one embodiment of the present application;
FIG. 2 is a flowchart of specific steps of step S130 according to one embodiment of the present application;
FIG. 3 is a flowchart showing the specific steps of step S140 according to another embodiment of the present application;
FIG. 4 is a flowchart showing the specific steps of step S310 according to another embodiment of the present application;
FIG. 5 is a flowchart showing the specific steps of step S410 according to another embodiment of the present application;
FIG. 6 is a flowchart showing the specific steps of step S330 according to another embodiment of the present application;
FIG. 7 is a specific step flow chart of step S320 provided in another embodiment of the present application;
FIG. 8 is a schematic block diagram of a system for generating an exception handling table according to an embodiment of the present application;
fig. 9 is a schematic hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
It should be noted that although functional block diagrams are depicted as block diagrams, and logical sequences are shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the block diagrams in the system. The terms first, second and the like in the description and in the claims and in the above-described figures, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the present application.
The method for generating the exception handling table provided by the embodiment of the application can be applied to a terminal, a server side or software running in the terminal or the server side. In some embodiments, the terminal may be a smart phone, tablet, notebook, desktop, etc.; the server side can be configured as an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), basic cloud computing services such as big data and artificial intelligent platforms and the like; the software may be an application or the like that realizes the generation method of the exception handling table, but is not limited to the above form.
The subject application is operational with numerous general purpose or special purpose computer system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
Embodiments of the present application are described below with reference to the accompanying drawings.
In a first aspect, fig. 1 is an optional flowchart of a method for generating an exception handling table according to an embodiment of the present application, where the method for generating an exception handling table in fig. 1 may include, but is not limited to, steps S110 to S140
Step S110, acquiring a statement block to be analyzed, wherein the statement block to be analyzed comprises an execution statement and an exception handling statement;
step S120, based on the stack structure, respectively carrying out corresponding push marks on the execution statement and the exception handling statement to obtain a marked statement block containing marking information;
step S130, compiling and analyzing the mark statement blocks in sequence according to the stack sequence of the stack structure to obtain an intermediate code containing mark information;
and step S140, screening out the exception handling instructions from the execution codes through the marking information and the stack sequence to generate an exception handling table.
It can be understood that the statement block to be parsed can be obtained through the observer mode acquisition, namely, the statement in the abstract syntax tree is acquired by using the design mode of the observer. The statement block to be analyzed may be a try-catch-find statement block, and the execution statement may be a try statement, in which a code may be executed by using the try statement, after an abnormality occurs in the code block, execution of a subsequent code may be stopped, and then a jump to a catch statement may be made, and if no abnormality occurs, the catch statement may not be executed, but the find statement may be executed. And one or more exception capturing sentences, namely a catch sentence, can be included in the try sentence, and the exception type can be determined from the exception capturing sentences. And the exception handling statement may be a finall statement that is executed after the end of execution of the try statement or catch statement block.
The statement blocks to be analyzed usually appear in a multi-layer nested format, namely, multi-layer try statements are nested and used, and can be processed through a stack structure by the principle that an outer layer try statement is first stacked and an inner layer try statement is then stacked. Therefore, the executing statement and the exception handling statement in the statement block to be analyzed are respectively subjected to stacking marking according to the stacking sequence by utilizing the stack structure, so that a marked statement block containing marking information is obtained, wherein the marked statement block contains the executing statement and the exception handling statement, namely, the executing statement and the exception handling statement both have marking information, the marking information is characterized by the stacking sequence of each statement in the stack structure, and meanwhile, the marking information can distinguish the executing statement and the exception handling statement.
Because the mark sentence blocks are positioned in the stack structure, the mark sentence blocks can be compiled and analyzed by the stack sequence of the stack structure by sequentially utilizing the custom intermediate codes, so that the execution codes are generated by compiling and analyzing the execution sentences, and the exception handling codes are generated by compiling and analyzing the exception handling sentences, so that the intermediate codes containing the mark information are obtained. The contents of the exception handling sentences are generated by redundancy after possible branch paths in each section of execution sentences in the traditional high-level language in the compiling process to realize an exception handling mechanism, so that a large number of exception handling table entries taking the exception handling sentences as a start index and an end index are generated, which is equivalent to exception handling codes in the part of the compiled execution codes, but the exception handling sentences and the exception handling codes are not exception information, therefore, the positions of the exception handling codes are determined through the marking information and the stack sequence, and whether the exception handling codes are positioned in the execution codes is judged. If the exception handling code is in the executing code, namely the final statement is in the try statement range or the catch statement range, the exception handling instruction containing the exception handling statement is removed from the executing code, which is equivalent to removing the range of the exception handling instruction from the range of the executing code when calculating the exception capturing range of the statement block to be analyzed, and splitting a redundant continuous exception capturing section of the executing code into a plurality of simple and accurate cells, thereby constructing a fine-granularity exception handling table by utilizing the cells, reducing the items of the exception handling table, realizing the optimization of the traditional exception handling table, and enabling an exception handling mechanism to be operated on equipment with limited resources.
In addition, the exception handling instruction includes, besides the exception handling statement that should not capture the exception, some special instructions that traverse in the execution code for each exception capture interval, such as a jump instruction and a return instruction, which may be considered as impossible to throw the exception, so that the special instructions may be removed from the execution code, which is equivalent to deleting the corresponding redundant entries from the conventional exception handling table, reducing the entries of the exception handling table, and facilitating operation on the resource-constrained device.
Referring to fig. 2, in some embodiments, step S130 of fig. 1 may include, but is not limited to, steps S210 to S240:
step S210, sequentially analyzing the marked statement blocks according to the stack sequence of the stack structure to obtain an intermediate execution code and an exception handling code;
step S220, copying the exception handling code to the position before the return instruction in the middle execution code to obtain the execution code when the return instruction exists in the execution statement;
step S230, inserting a jump instruction for jumping to an exception handling code from the intermediate execution code to obtain an execution code when no return instruction exists in the execution statement;
Step S240, according to the stack structure, the executing code and the exception handling code are comprehensively ordered to obtain an intermediate code containing the marking information.
It can be understood that, through the stack sequence of each statement in the stack structure of the flag statement block, each statement in the flag statement block is sequentially parsed, that is, the execution statement is parsed to obtain an intermediate execution code, the exception handling statement is parsed to obtain an exception handling code, the execution statement and the exception handling statement both have flag information, and after compiling and parsing, the corresponding generated execution code and exception handling code also have flag information.
When the return instruction exists in the execution statement, the exception handling code is copied to a position before the return instruction in the intermediate execution code, so that an exception handling mechanism is realized, and the execution code is obtained. In the case where there are multiple return instructions in the execution statement, i.e., multiple return instructions in the intermediate execution code, the exception handling code may be copied before each return instruction, or may be copied before one or more of the return instructions. However, the exception handling code is only used for executing the processing and does not throw an exception, so after an exception capture range is generated for the execution code, the exception handling code copied into the execution code can be deleted, and redundant entry entries in the exception handling table are reduced.
In order to ensure that the exception handling statement can still be executed after the exception occurs in the execution statement under the condition that the return instruction does not exist in the execution statement, a jump instruction for jumping to the exception handling code is inserted into the intermediate execution code, and an exception handling mechanism is realized by inserting the jump instruction, so that the number of byte codes in the execution code can be effectively reduced, and the space is saved.
Therefore, after the copied exception handling code is inserted into the intermediate execution code or the jump instruction is inserted, the execution code is obtained, the execution code and the exception handling code are reordered by using the stack structure, and the execution code and the exception handling code are respectively re-marked by using the marking information, wherein the exception handling code in the execution code is included, and the intermediate code containing the marking information is obtained.
Referring to fig. 3, in some embodiments, step S140 of fig. 1 may include, but is not limited to, steps S310 to S330:
step S310, determining a first range of the execution code and a second range of the exception handling code through the marking information and the stack sequence;
step S320, when the execution code includes an exception handling code, eliminating the second range from the first range, and generating a plurality of exception intervals;
Step S330, merging the plurality of abnormal sections to generate an abnormal processing table.
It will be appreciated that since each statement is marked during the stacking of the marked statement block to generate the marking information, the execution code and the exception handling code, particularly the exception handling code copied into the execution code, can be determined by the marking information. Thus, using both the tag information and the stack order, a first range of executed code may be determined, while a second range of exception handling code is determined.
In the case where the execution code includes exception handling code, that is, the first range may cross-overlap with the second range, the second range in the first range is eliminated, the first range is split into a plurality of exception intervals, and the entries of the exception handling table are reduced. And merging the plurality of abnormal sections, merging the abnormal sections with the same section or continuous sections, and further optimizing an abnormal processing table.
For example, the try code in the execution code ranges from [3,15], the catch code ranges from [15,21], the any code ranges from [22,28], and the finaly code ranges from [29,33] in the exception handling code. In addition, the try code includes a copied-inserted finaliy code, and the copied-inserted code range is [8,12]. The first range is [3,28], the second range is [8,12] and [29,33], the second range [8,12] existing in the first range is removed, namely [3,8] and [13,28] are obtained, and therefore, two exception intervals after the second range is removed are utilized to generate an exception handling table, wherein specific table items are as follows: [3,8, 15], [13,15], [3,8, 22], [13,15, 22] and [15,21, 22], the first element of the table being characterized as a start position, the second element being characterized as an end position, the third element being characterized as a process execution position. If the code in the range of [13,15] is an exception handling instruction, namely a jump instruction, a return instruction and an exception type, only [3,8, 15], [3,8, 22] and [15,21, 22] are reserved after the exception handling instruction is removed, so that the table entry of the exception handling table can be reduced.
Referring to fig. 4, in some embodiments, step S310 of fig. 3 may include, but is not limited to, steps S410 to S420:
step S410, determining an execution start position and an execution end position by using the execution marks and the stack sequence, and determining a first range of the execution code according to the execution start position and the execution end position;
step S420, determining an abnormal starting position and an abnormal ending position by using the abnormal processing marks and the stack sequence, and determining a second range of the abnormal processing codes according to the abnormal starting position and the abnormal ending position.
It can be understood that the marking information may include an execution marking for marking the execution statement and an exception handling marking for marking the exception handling statement, so that each statement in the statement block to be parsed is marked according to the statement type in the stacking process, so that the execution statement and the exception handling statement can be determined by the marking information.
By the execution flag and the stack position, the start line and the end line of the execution code, that is, the execution start position and the execution end position, can be determined, so that the code range between the execution start position and the execution end position is regarded as the first range of the execution code, that is, the first range can be determined from the execution start position and the execution end position, and the execution start position and the execution end position are included.
Accordingly, by executing the flag and the stack position, the start line and the end line of the exception handling code, that is, the exception start position and the exception end position, can be determined. The second range, which is determined as the abnormality processing code by the code range between the abnormality start position and the abnormality end position, that is, the second range can be determined from and included in the abnormality start position and the abnormality end position.
Since the exception handling code may be copied into the execution code, there may be a plurality of exception start positions and exception end positions, and each exception start position and each exception end position corresponds one-to-one, a plurality of second ranges can be determined while the second ranges may exist within the first range.
Referring to fig. 5, in some embodiments, step S410 of fig. 4 may include, but is not limited to, steps S510 to S530:
step S510, determining an abnormality capturing mark corresponding to the abnormality capturing code from the execution code according to the abnormality type and the stack sequence;
step S520, determining a plurality of execution start positions and a plurality of execution end positions by using the execution marks, the abnormality capturing marks and the stack order;
In step S530, a plurality of first ranges are determined according to the plurality of execution start positions and the plurality of execution end positions.
It can be understood that the execution code further comprises an exception capturing code, and the exception capturing code is compiled by an exception capturing statement in the execution statement, namely, is obtained by a catch statement. The exception capturing codes can determine the exception types in the current statement range, the exception capturing codes have a plurality of types, different types of exception capturing codes correspond to different exception types, and the exception capturing codes have a plurality of exception types.
Referring to fig. 6, in some embodiments, step S330 of fig. 3 may include, but is not limited to, step S610:
in step S610, the abnormal sections having the same abnormality capturing flag and having continuous sections are merged to generate an abnormality processing table.
It will be appreciated that each abnormal section is represented by a corresponding abnormality capture tag, and that the abnormality capture tag is characterized as a tag of an abnormality type determined by an abnormality capture sentence, by which the abnormality type of the current abnormal section can be determined. Exception types are different, exception handling performed is different, and in the case of the same exception type, exception handling performed is the same. Therefore, the abnormality sections having the same abnormality capturing marks and continuous sections can be merged, and the abnormality processing table can be generated using the merged abnormality section and the abnormality section that cannot be merged. If the abnormality capturing marks of the plurality of abnormality regions are the same and the regions are continuous and can be merged, for example, if the abnormality capturing marks of both [1,3] and [4,10] are the same, then both may be merged to form a new abnormality region [1,10]. By merging the abnormal sections with the same abnormal type and continuous sections, redundant table entry in the abnormal processing table can be effectively reduced, and the abnormal processing mechanism can be operated on the equipment with limited resources.
Referring to fig. 7, in some embodiments, step S320 of fig. 3 may include, but is not limited to, step S710:
in step S710, when the abnormality start position and the abnormality end position are both located between the execution start position and the execution end position, the first abnormality section is determined using the execution start position and the abnormality start position, and the second abnormality section is determined using the abnormality end position and the execution end position.
It will be understood that when the abnormality start position and the abnormality end position are both between the execution start position and the execution end position, the second range may be considered to be within the first range, so that the first abnormality section is determined by the execution start position and the abnormality start position, while the second abnormality section is determined by the abnormality end position and the execution end position, which corresponds to the elimination of the second range determined by the abnormality start position and the abnormality end position.
In a second aspect, referring to fig. 8, fig. 8 is a schematic block diagram of a system for generating an exception handling table according to an embodiment of the present application, and the embodiment of the present application further provides a system 800 for generating an exception handling table, which may implement the method for generating an exception handling table, where the system includes:
The sentence acquisition module 810 is configured to acquire a sentence block to be parsed, where the sentence block to be parsed includes an execution sentence and an exception processing sentence;
the statement marking module 820 is configured to perform corresponding push marking on the execution statement and the exception handling statement based on the stack structure, so as to obtain a marked statement block containing marking information;
the compiling and analyzing module 830 is configured to sequentially compile and analyze the markup sentence blocks according to a stack sequence of the stack structure, so as to obtain an intermediate code containing markup information, where the intermediate code includes an execution code and an exception handling code;
the exception table generating module 840 is configured to screen out an exception handling instruction from the execution codes by the tag information and the stack order, and generate an exception handling table, where the exception handling instruction includes an exception handling code.
The specific embodiment of the system 800 for generating an exception handling table is substantially the same as the specific embodiment of the method for generating an exception handling table described above, and will not be described herein.
In a third aspect, an embodiment of the present application further provides an electronic device, where the electronic device includes a memory and a processor, and the memory stores a computer program, and the processor implements the method for generating the exception handling table when executing the computer program. The electronic equipment can be any intelligent terminal including a tablet personal computer, a vehicle-mounted computer and the like.
Referring to fig. 9, fig. 9 illustrates a hardware structure of an electronic device according to another embodiment, the electronic device includes:
the processor 910 may be implemented by a general-purpose CPU (central processing unit), a microprocessor, an application-specific integrated circuit (ApplicationSpecificIntegratedCircuit, ASIC), or one or more integrated circuits, etc. for executing related programs to implement the technical solutions provided by the embodiments of the present application;
memory 920 may be implemented in the form of read-only memory (ReadOnlyMemory, ROM), static storage, dynamic storage, or random access memory (RandomAccessMemory, RAM). The memory 920 may store an operating system and other application programs, and when the technical solution provided in the embodiments of the present specification is implemented by software or firmware, relevant program codes are stored in the memory 920 and the processor 910 invokes a generation method for executing the exception handling table of the embodiments of the present application, for example, executing the method steps S110 to S140 in fig. 1, the method steps S210 to S240 in fig. 2, the method steps S310 to S330 in fig. 3, the method steps S410 to S420 in fig. 4, the method steps S510 to S520 in fig. 5, the method step S610 in fig. 6, and the method step S710 in fig. 7 described above;
An input/output interface 930 for inputting and outputting information;
the communication interface 940 is configured to implement communication interaction between the device and other devices, and may implement communication in a wired manner (e.g., USB, network cable, etc.), or may implement communication in a wireless manner (e.g., mobile network, WIFI, bluetooth, etc.);
a bus 950 for transferring information between components of the device (e.g., processor 910, memory 920, input/output interface 930, and communication interface 940);
wherein processor 910, memory 920, input/output interface 930, and communication interface 940 implement communication connections among each other within the device via a bus 950.
In a fourth aspect, embodiments of the present application further provide a computer-readable storage medium storing a computer program that when executed by a processor implements the above-described method of generating an exception handling table.
The memory, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The non-transitory software program and instructions required to implement the method of generating an exception handling table in the above-described embodiments are stored in a memory, and when executed by one or more processors, the method of generating an exception handling table in the above-described embodiments is performed, for example, method steps S110 to S140 in fig. 1, method steps S210 to S240 in fig. 2, method steps S310 to S330 in fig. 3, method steps S410 to S420 in fig. 4, method steps S510 to S520 in fig. 5, method step S610 in fig. 6, and method step S710 in fig. 7, described above.
The embodiments described in the embodiments of the present application are for more clearly describing the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application, and as those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
It will be appreciated by those skilled in the art that the technical solutions shown in the figures do not constitute limitations of the embodiments of the present application, and may include more or fewer steps than shown, or may combine certain steps, or different steps.
The system embodiments described above are merely illustrative, in that the units illustrated as separate components may or may not be physically separate, i.e., may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Those of ordinary skill in the art will appreciate that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof.
The terms "first," "second," "third," "fourth," and the like in the description of the present application and in the above-described figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the present application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in this application, "plurality" means two or more. The character "/" generally indicates that the context-dependent object is an "or" relationship.
In the several embodiments provided in this application, it should be understood that the disclosed systems and methods may be implemented in other ways. For example, the system embodiments described above are merely illustrative, e.g., the division of the above elements is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, system or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including multiple instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of the various embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing a program.
Preferred embodiments of the present application are described above with reference to the accompanying drawings, and thus do not limit the scope of the claims of the embodiments of the present application. Any modifications, equivalent substitutions and improvements made by those skilled in the art without departing from the scope and spirit of the embodiments of the present application shall fall within the scope of the claims of the embodiments of the present application.

Claims (10)

1. A method for generating an exception handling table, the method comprising:
acquiring a statement block to be analyzed, wherein the statement block to be analyzed comprises an execution statement and an exception handling statement;
based on a stack structure, respectively carrying out corresponding push marks on the execution statement and the exception handling statement to obtain a marked statement block containing marking information;
according to the stack sequence of the stack structure, compiling and analyzing the marked statement blocks in sequence to obtain intermediate codes containing the marked information, wherein the intermediate codes comprise execution codes and exception handling codes;
and screening out an exception handling instruction from the execution codes through the marking information and the stack sequence to generate an exception handling table, wherein the exception handling instruction comprises the exception handling codes.
2. The generating method according to claim 1, wherein the compiling and parsing the markup sentence blocks sequentially according to the stack order of the stack structure to obtain the intermediate code containing the markup information, includes:
Sequentially analyzing the marked statement blocks according to the stack sequence of the stack structure to obtain an intermediate execution code and an exception handling code;
copying the exception processing code to a position in the intermediate execution code before the return instruction under the condition that the return instruction exists in the execution statement, so as to obtain an execution code;
inserting a jump instruction for jumping to the exception handling code from the intermediate execution code to obtain an execution code when no return instruction exists in the execution statement;
and comprehensively sequencing the execution codes and the exception handling codes according to the stack structure to obtain intermediate codes containing the marking information.
3. The method according to claim 1, wherein the step of generating an exception table by sorting out exception processing instructions from the execution code by the tag information and the stack order includes:
determining a first range of the execution code and a second range of the exception handling code through the marking information and the stack order;
when the execution code includes the exception handling code, the second range is eliminated from the first range, and a plurality of exception intervals are generated;
And merging the plurality of abnormal sections to generate an abnormal processing table.
4. A generation method according to claim 3, wherein the tag information includes an execution tag for tagging the execution statement, and an exception handling tag for tagging the exception handling statement;
the determining, by the tag information and the stack order, a first range of the execution code and a second range of the exception handling code includes:
determining an execution start position and an execution end position by using the execution mark and the stack sequence, and determining a first range of the execution code according to the execution start position and the execution end position;
determining an abnormal starting position and an abnormal ending position by using the abnormal processing mark and the stack sequence, and determining a second range of the abnormal processing code according to the abnormal starting position and the abnormal ending position;
wherein the first range includes the execution start position and the execution end position, and the second range includes the abnormality start position and the abnormality end position.
5. The generation method of claim 4, wherein the execution code comprises an exception capture code, the exception capture code comprising a plurality of exception types;
The determining, by using the execution flag and the stack order, an execution start position and an execution end position, and determining, according to the execution start position and the execution end position, a first range of the execution code includes:
determining an abnormality capturing mark corresponding to the abnormality capturing code from the execution code according to the abnormality type and the stack sequence;
determining a plurality of execution start positions and a plurality of execution end positions by using the execution marks, the abnormality capturing marks and the stack sequence, wherein each execution start position corresponds to each execution end position one by one;
and determining a plurality of first ranges according to the execution starting positions and the execution ending positions, wherein the first ranges comprise the execution marks and the abnormality capturing marks.
6. The generation method according to claim 5, wherein the abnormal section includes the abnormality capturing flag;
the merging the plurality of abnormal intervals to generate an abnormal processing table comprises the following steps:
and merging the abnormal sections which have the same abnormal capturing mark and are continuous in section to generate an abnormal processing table.
7. The generation method according to claim 3, wherein in the case where the execution code includes the exception handling code, the second range is excluded from the first range, and a plurality of exception intervals are generated;
and when the abnormality start position and the abnormality end position are both between the execution start position and the execution end position, determining a first abnormality section by using the execution start position and the abnormality start position, and determining a second abnormality section by using the abnormality end position and the execution end position.
8. A system for generating an exception handling table, the system comprising:
the sentence acquisition module is used for acquiring a sentence block to be analyzed, wherein the sentence block to be analyzed comprises an execution sentence and an exception handling sentence;
the statement marking module is used for respectively carrying out corresponding push marking on the execution statement and the exception handling statement based on a stack structure to obtain a marked statement block containing marking information;
the compiling and analyzing module is used for sequentially compiling and analyzing the mark statement blocks according to the stack sequence of the stack structure to obtain intermediate codes containing the mark information, wherein the intermediate codes comprise execution codes and exception handling codes;
And the exception table generation module is used for screening out exception processing instructions from the execution codes through the marking information and the stack sequence to generate an exception processing table, wherein the exception processing instructions comprise the exception processing codes.
9. An electronic device comprising a memory storing a computer program and a processor implementing the method of generating an exception handling table according to any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method of generating an abnormality processing table according to any one of claims 1 to 7.
CN202211693341.2A 2022-12-28 2022-12-28 Method, system, electronic device and storage medium for generating exception handling table Pending CN116010147A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211693341.2A CN116010147A (en) 2022-12-28 2022-12-28 Method, system, electronic device and storage medium for generating exception handling table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211693341.2A CN116010147A (en) 2022-12-28 2022-12-28 Method, system, electronic device and storage medium for generating exception handling table

Publications (1)

Publication Number Publication Date
CN116010147A true CN116010147A (en) 2023-04-25

Family

ID=86022438

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211693341.2A Pending CN116010147A (en) 2022-12-28 2022-12-28 Method, system, electronic device and storage medium for generating exception handling table

Country Status (1)

Country Link
CN (1) CN116010147A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116821000A (en) * 2023-08-30 2023-09-29 天津租赁资产交易中心股份有限公司 Method for processing abnormal operation of user feedback application

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116821000A (en) * 2023-08-30 2023-09-29 天津租赁资产交易中心股份有限公司 Method for processing abnormal operation of user feedback application
CN116821000B (en) * 2023-08-30 2023-12-12 天津租赁资产交易中心股份有限公司 Method for processing abnormal operation of user feedback application

Similar Documents

Publication Publication Date Title
CN110968325B (en) Applet conversion method and device
CN105205080B (en) Redundant file method for cleaning, device and system
CN103078945B (en) To the method and system that browser crash data processes
CN103714116A (en) Webpage information extracting method and webpage information extracting equipment
CN104331438A (en) Method and device for selectively extracting content of novel webpage
CN116010147A (en) Method, system, electronic device and storage medium for generating exception handling table
CN116523457A (en) Workflow processing method, device, equipment and storage medium based on business process
CN108536489B (en) Method, apparatus, and computer-readable storage medium for matching resource environments
CN106897287B (en) Webpage release time extraction method and device for webpage release time extraction
KR101092019B1 (en) Web browsing system using the mobile web browser and method thereof and mobile terminal in the used the same
CN111158777A (en) Component calling method and device and computer readable storage medium
CN114579203B (en) Script file checking method and device, electronic equipment and storage medium
CN110543641A (en) chinese and foreign language information comparison method and device
CN115455006A (en) Data processing method, data processing device, electronic device, and storage medium
CN112230989B (en) Webpage channel navigation bar extraction method, system, electronic equipment and storage medium
CN115202731A (en) Code detection method and code detection device, computer equipment and storage medium
CN114625658A (en) APP stability test method, device, equipment and computer readable storage medium
CN113326407A (en) Data processing method and device
CN112667874A (en) Webpage data extraction method and device, electronic equipment and storage medium
CN112800078A (en) Lightweight text labeling method, system, equipment and storage medium based on javascript
CN110704781A (en) Web page parser
CN116755745A (en) Plug-in updating method, device and equipment of code editor and storage medium
CN111625749B (en) Method, device, equipment and medium for extracting website detail page information of participant company
CN117608719A (en) Page element searching method and device, electronic equipment and medium
CN112287097B (en) Method and device for analyzing markup language text, storage medium and electronic equipment

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