[go: up one dir, main page]

CN107038058A - A kind of code process method and device - Google Patents

A kind of code process method and device Download PDF

Info

Publication number
CN107038058A
CN107038058A CN201710068399.0A CN201710068399A CN107038058A CN 107038058 A CN107038058 A CN 107038058A CN 201710068399 A CN201710068399 A CN 201710068399A CN 107038058 A CN107038058 A CN 107038058A
Authority
CN
China
Prior art keywords
code
function
branch condition
branch
specified function
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.)
Granted
Application number
CN201710068399.0A
Other languages
Chinese (zh)
Other versions
CN107038058B (en
Inventor
陈成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201710068399.0A priority Critical patent/CN107038058B/en
Publication of CN107038058A publication Critical patent/CN107038058A/en
Application granted granted Critical
Publication of CN107038058B publication Critical patent/CN107038058B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • G06F8/4434Reducing the memory space required by the program code
    • G06F8/4435Detection or removal of dead or redundant code
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • G06F8/4434Reducing the memory space required by the program code

Landscapes

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

Abstract

The embodiment of the present application discloses a kind of code process method and device.Methods described includes:Obtain pending code;Determine each function call for specified function in the pending code, and each branch condition in the specified function;The parameter according to used in the branch condition and each function call, cutting processing is carried out to the branch code in the specified function corresponding to the branch condition.Using the embodiment of the present application, the partial redundance code in packaging file can be eliminated, so as to reduce the volume of packaging file.

Description

一种代码处理方法及装置Code processing method and device

技术领域technical field

本申请涉及计算机软件技术领域,尤其涉及一种代码处理方法及装置。The present application relates to the technical field of computer software, in particular to a code processing method and device.

背景技术Background technique

随着计算机技术和互联网技术的迅速发展,各类应用程序大量涌现,给人们的生活带来了便利。With the rapid development of computer technology and Internet technology, a large number of various application programs have emerged, bringing convenience to people's lives.

大多数应用程序或者应用程序中某些功能模块需要打包后提供给用户,进而用户下载安装打包文件后可以使用。打包文件中通常包含功能相关的代码和非代码文件,比如,前端控制所使用的JavaScript代码、程序全局配置文件、二进制资源文件等。Most applications or some functional modules in the applications need to be packaged and provided to users, and then users can use the packaged files after downloading and installing them. The packaging file usually contains function-related code and non-code files, such as JavaScript code used by the front-end control, program global configuration files, binary resource files, and so on.

但是,随着应用程序功能越来越强大,打包文件的体积也越来越大,会给用户获取打包文件带来不利影响,而且也会降低打包文件内代码的执行效率。However, as the functions of the application program become more and more powerful, the volume of the packaged file becomes larger and larger, which will have adverse effects on the user's acquisition of the packaged file, and will also reduce the execution efficiency of the code in the packaged file.

发明内容Contents of the invention

本申请实施例提供一种代码处理方法及装置,用以解决现有技术中的如下技术问题:随着应用程序功能越来越强大,打包文件的体积也越来越大,会给用户获取打包文件带来不利影响,而且也会降低打包文件内代码的执行效率。The embodiment of the present application provides a code processing method and device to solve the following technical problems in the prior art: as the functions of the application program become more and more powerful, the volume of the packaged file becomes larger and larger, and the packaged file will be obtained for the user. files, and will also reduce the execution efficiency of the code inside the packaged file.

为解决上述技术问题,本申请实施例是这样实现的:In order to solve the above technical problems, the embodiment of the present application is implemented as follows:

本申请实施例提供的一种代码处理方法,包括:A code processing method provided in an embodiment of the present application includes:

获得待处理代码;get pending code;

确定所述待处理代码中针对指定函数的各函数调用,以及所述指定函数中的各分支条件;determining each function call for a specified function in the code to be processed, and each branch condition in the specified function;

根据所述分支条件和所述各函数调用所使用的参数,对所述指定函数中对应于所述分支条件的分支代码进行裁剪处理。According to the branch condition and the parameters used by the function calls, the branch code corresponding to the branch condition in the specified function is clipped.

本申请实施例提供的一种代码处理装置,包括:A code processing device provided in an embodiment of the present application includes:

获得模块,获得待处理代码;Get the module and get the code to be processed;

确定模块,确定所述待处理代码中针对指定函数的各函数调用,以及所述指定函数中的各分支条件;A determining module, determining each function call for a specified function in the code to be processed, and each branch condition in the specified function;

处理模块,根据所述分支条件和所述各函数调用所使用的参数,对所述指定函数中对应于所述分支条件的分支代码进行裁剪处理。The processing module, according to the branch condition and the parameters used by the function calls, performs tailoring processing on the branch code corresponding to the branch condition in the specified function.

本申请实施例采用的上述至少一个技术方案能够达到以下有益效果:可以消除打包文件中的部分冗余代码,从而可以减小打包文件的体积,进而可以减少现有技术给用户获取打包文件带来的不利影响,而且也有利于提高打包文件内代码的执行效率,因此,可以部分或全部地解决现有技术中的问题。The above-mentioned at least one technical solution adopted in the embodiment of the present application can achieve the following beneficial effects: it can eliminate some redundant codes in the packaged file, thereby reducing the volume of the packaged file, thereby reducing the inconvenience caused by the prior art to the user in obtaining the packaged file. adverse effects, and it is also beneficial to improve the execution efficiency of the code in the packaging file, therefore, it can partially or completely solve the problems in the prior art.

附图说明Description of drawings

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments described in this application. Those skilled in the art can also obtain other drawings based on these drawings without any creative effort.

图1为本申请实施例提供的一种代码处理方法的流程示意图;FIG. 1 is a schematic flowchart of a code processing method provided in an embodiment of the present application;

图2为本申请实施例提供的对应于图1的一种代码处理装置的结构示意图。FIG. 2 is a schematic structural diagram of a code processing device corresponding to FIG. 1 provided by an embodiment of the present application.

具体实施方式detailed description

本申请实施例提供一种代码处理方法及装置。Embodiments of the present application provide a code processing method and device.

为了使本技术领域的人员更好地理解本申请中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to enable those skilled in the art to better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described The embodiments are only some of the embodiments of the present application, but not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.

图1为本申请实施例提供的一种代码处理方法的流程示意图,该流程可以由程序实现,可搭载所述程序的设备包括但不限于以下:个人计算机、大中型计算机、计算机集群、手机、平板电脑、智能可穿戴设备、车机等。Figure 1 is a schematic flow diagram of a code processing method provided by the embodiment of the present application. The flow can be implemented by a program, and the devices that can carry the program include but are not limited to the following: personal computers, large and medium-sized computers, computer clusters, mobile phones, Tablet PCs, smart wearable devices, vehicles, etc.

图1中的流程可以包括以下步骤:The process in Figure 1 may include the following steps:

S101:获得待处理代码。S101: Obtain the code to be processed.

在本申请实施例中,所述代码可以是基于任一种编程语言的。比如,JavaScript、JAVA、C、C++、PHP、Python等编程语言所编写的代码。为了便于描述,以下各实施例主要以JavaScript代码为例进行说明。In this embodiment of the application, the code may be based on any programming language. For example, code written in programming languages such as JavaScript, JAVA, C, C++, PHP, and Python. For ease of description, the following embodiments mainly use JavaScript code as an example for illustration.

在本申请实施例中,待处理代码通常是针对指定的应用场景等待打包或者模块化的代码。In the embodiment of the present application, the code to be processed is usually the code waiting to be packaged or modularized for a specified application scenario.

待处理代码中包含一个或多个函数的函数体,以及一个或多个对于所述函数的函数调用。在不同的应用场景下,函数体可能不变,而对应的函数调用所使用的参数可能不同,比如,参数类型不同、参数值不同等。The code to be processed includes function bodies of one or more functions, and one or more function calls to the functions. In different application scenarios, the function body may remain unchanged, but the parameters used in the corresponding function calls may be different, for example, different parameter types and different parameter values.

S102:确定所述待处理代码中针对指定函数的各函数调用,以及所述指定函数中的各分支条件。S102: Determine each function call for a specified function in the code to be processed, and each branch condition in the specified function.

在本申请实施例中,所述指定函数可以是函数体包含在待处理代码中的任意函数。在实际应用中,对于函数体包含在待处理代码中的各函数,可以将所述各函数中至少部分函数中的每个函数分别作为指定函数,并分别对各指定函数执行图1中的流程。In this embodiment of the present application, the specified function may be any function whose function body is included in the code to be processed. In practical applications, for each function whose function body is included in the code to be processed, each function in at least some of the functions can be used as a designated function, and the flow in Figure 1 is executed for each designated function .

在本申请实施例中,所述各函数调用具体包括所述待处理代码中针对指定函数的全部函数调用。所述各函数调用可以分别使用不同的参数。In the embodiment of the present application, the function calls specifically include all function calls for a specified function in the code to be processed. The various function calls may use different parameters respectively.

例如,假定指定函数为“clone(item)”,某个针对该指定函数的函数调用可以为“clone()”,另一个针对该指定函数的函数调用可以为“clone(‘foo’)”,等等。可以看到,clone()所使用的参数为空(属于非item),clone(‘foo’)所使用的参数为字符串foo。For example, assuming the specified function is "clone(item)", a function call to the specified function could be "clone()", and another function call to the specified function could be "clone('foo')", wait. It can be seen that the parameter used by clone() is empty (belonging to non-item), and the parameter used by clone('foo') is the string foo.

在本申请实施例中,指定函数中包含一个或多个分支条件。所述各分支条件具体包括指定函数中的全部分支条件。一般地,分支条件包含在诸如“if”、“else”等条件语句中。In the embodiment of the present application, the specified function includes one or more branch conditions. The branch conditions specifically include all branch conditions in the specified function. Generally, branching conditions are contained in conditional statements such as "if", "else", etc.

例如,假定指定函数clone(item)如下所示:For example, assume that the function clone(item) is specified as follows:

可以看到,上例的指定函数中共包含两个分支条件。分支1的分支条件为“!item”,分支2的分支条件为“typeof item===‘string’”。It can be seen that the specified function in the above example contains two branch conditions. The branch condition of branch 1 is "!item", and the branch condition of branch 2 is "typeof item==='string'".

需要说明的是,在实际应用中,指定函数的函数体也可以不包含在待处理代码中。但是,在这种情况下,后续对指定函数的裁剪处理有可能会影响:待处理代码之外的针对指定函数的函数调用的结果。It should be noted that, in practical applications, the function body of the specified function may not be included in the code to be processed. However, in this case, the subsequent clipping processing of the specified function may affect: the result of a function call to the specified function outside the code to be processed.

S103:根据所述分支条件和所述各函数调用所使用的参数,对所述指定函数中对应于所述分支条件的分支代码进行裁剪处理。S103: According to the branch condition and the parameters used by the function calls, perform clipping processing on the branch code corresponding to the branch condition in the specified function.

在本申请实施例中,如前所述,待处理代码通常是针对指定的应用场景等待打包或者模块化的代码,在该指定的应用场景下,对待处理代码中的函数进行调用时,未必需要用到该函数中的全部分支。那么,可以认为:在该指定的应用场景下,不会被用到的分支的代码是冗余的,可以将其从待处理代码中裁剪掉,再打包裁剪后的待处理代码,以减小待处理代码的体积。In the embodiment of this application, as mentioned above, the code to be processed is usually the code waiting to be packaged or modularized for the specified application scenario. In the specified application scenario, when calling the function in the code to be processed, it is not necessary All branches in the function are used. Then, it can be considered that: in the specified application scenario, the code of the branch that will not be used is redundant, it can be cut out from the code to be processed, and then the cut code to be processed can be packaged to reduce the The volume of pending code.

在本申请实施例中,根据分支条件和各函数调用所使用的参数,可以确定在待处理代码对应的场景下哪些分支是不需要用到的,进而可以对不会被用到的分支的代码进行裁剪处理。In the embodiment of this application, according to the branch conditions and the parameters used by each function call, it can be determined which branches are not needed in the scene corresponding to the code to be processed, and then the code of the branch that will not be used can be determined Perform cropping.

另外,需要说明的是,本申请对步骤S102中“确定所述待处理代码中针对指定函数的各函数调用”和“确定所述指定函数中的各分支条件”的执行顺序并不做限定,可以同时执行,也可以一先一后地执行。In addition, it should be noted that this application does not limit the execution order of "determining the function calls for the specified function in the code to be processed" and "determining the branch conditions in the specified function" in step S102, It can be executed at the same time or one after the other.

通过图1的方法,可以消除打包文件中的部分冗余代码(包含在上述的待处理代码中),从而可以减小打包文件的体积,进而可以减少现有技术给用户获取打包文件带来的不利影响,而且也有利于提高打包文件内代码的执行效率,因此,可以部分或全部地解决现有技术中的问题。Through the method in Fig. 1, part of the redundant codes (included in the above code to be processed) in the packaged file can be eliminated, thereby reducing the volume of the packaged file, and then reducing the cost of obtaining the packaged file for the user in the prior art adverse effects, and is also beneficial to improve the execution efficiency of the code in the packaging file, therefore, the problems in the prior art can be partially or completely solved.

基于图1的方法,本申请实施例还提供了该方法的一些具体实施方案,以及扩展方案,下面进行说明。Based on the method in FIG. 1 , the embodiment of the present application also provides some specific implementations and extensions of the method, which will be described below.

在本申请实施例中,在获得待处理代码后,可以通过遍历待处理代码实现后续步骤,也可以将待处理代码转换为诸如语法树等更容易分析的数据形式,进而再根据转换后得到的数据实现后续步骤。以下以语法树为例。In this embodiment of the application, after the code to be processed is obtained, the subsequent steps can be implemented by traversing the code to be processed, or the code to be processed can be converted into a data form that is easier to analyze such as a syntax tree, and then according to the obtained Data enables next steps. The syntax tree is used as an example below.

则对于步骤S102,所述确定所述待处理代码中针对指定函数的各函数调用,具体可以包括:生成所述待处理代码的语法树;根据所述待处理代码的语法树,确定所述待处理代码中针对指定函数的各函数调用和所述各函数调用所使用的参数,以及所述指定函数中的各分支条件。Then for step S102, the determining the function calls for the specified function in the code to be processed may specifically include: generating a syntax tree of the code to be processed; determining the code to be processed according to the syntax tree of the code to be processed Each function call for the specified function in the processing code, the parameters used by each function call, and each branch condition in the specified function.

具体如何生成语法树本申请并不做限定,可以利用已有的技术实现。在语法树中,函数与函数调用等代码中的元素都可以被表示树节点,易于分析和操作。How to generate the syntax tree is not limited in this application, and it can be realized by using existing technologies. In the syntax tree, elements in the code such as functions and function calls can be represented as tree nodes, which are easy to analyze and operate.

前面有提到,可能会针对待处理代码中的多个函数执行图1中的流程,因此,可以统一确定待处理代码中的所有函数调用及其所使用的参数(并可以这些数据保存在诸如列表等数据结构中以便于使用),如此,执行后续流程时直接使用这些函数调用及参数即可,有利于提高本申请的方案的执行效率。As mentioned earlier, the process in Figure 1 may be executed for multiple functions in the code to be processed, therefore, all function calls and the parameters used in the code to be processed can be uniformly determined (and these data can be saved in such as List and other data structures for ease of use), in this way, these function calls and parameters can be directly used when executing the subsequent process, which is beneficial to improve the execution efficiency of the solution of the present application.

具体地,所述根据所述待处理代码的语法树,确定所述待处理代码中针对指定函数的各函数调用和所述各函数调用所使用的参数,可以包括:根据所述待处理代码的语法树,确定所述待处理代码中的所有函数调用,以及确定分别确定所述所有函数调用所使用的参数;对确定的所述所有函数调用进行分类,所针对函数相同的函数调用被分在同一类中;在各类中确定针对指定函数的一类函数调用,以及确定该类函数调用所使用的参数。Specifically, the determining, according to the syntax tree of the code to be processed, each function call for a specified function in the code to be processed and the parameters used by each function call may include: according to the code to be processed Syntax tree, determine all function calls in the code to be processed, and determine the parameters used to determine all the function calls respectively; classify all the determined function calls, and the function calls for the same function are divided into Within the same class; among various classes, determine a type of function call for the specified function, and determine the parameters used by this type of function call.

进一步地,所述确定所述指定函数中的各分支条件,具体可以包括:根据所述待处理代码的语法树,确定所述指定函数的语法树;根据所述指定函数的语法树,确定所述指定函数中的各分支条件。Further, the determining each branch condition in the specified function may specifically include: determining the syntax tree of the specified function according to the syntax tree of the code to be processed; determining the syntax tree of the specified function according to the syntax tree of the specified function Describes each branch condition in the specified function.

在本申请实施例中,对于步骤S103,所述根据所述分支条件和所述各函数调用所使用的参数,对所述指定函数中对应于所述分支条件的分支代码进行裁剪处理,具体可以包括:In the embodiment of the present application, for step S103, the branch code corresponding to the branch condition in the specified function is trimmed according to the branch condition and the parameters used by the function calls, specifically, include:

分别对所述各分支条件中的每个分支条件执行:Execute each branch condition in the branch conditions respectively:

分别根据所述各函数调用中的每个函数调用所使用的参数,确定对于该函数调用所使用的参数,是否可满足该分支条件;若对于所述每个函数调用所使用的参数,均不可满足该分支条件,则删除对应于该分支条件的分支代码。According to the parameters used by each function call in the function calls, determine whether the parameters used for the function call can satisfy the branch condition; if the parameters used for each function call can not If the branch condition is satisfied, the branch code corresponding to the branch condition is deleted.

为了便于理解,沿用上例进行说明。For ease of understanding, the above example is used for illustration.

假定对于待处理代码中的上述指定函数clone(item),共有两个针对clone(item)的函数调用:clone()、clone(‘foo’)。可以看到,clone()可以符合clone(item)的分支1的分支条件“!item”,clone(‘foo’)可以符合clone(item)的分支2的分支条件“typeof item===‘string’”,因此,这两个分支的分支代码均不是冗余的,无需裁剪。Assume that for the above specified function clone(item) in the code to be processed, there are two function calls for clone(item): clone() and clone('foo'). It can be seen that clone() can meet the branch condition "!item" of branch 1 of clone(item), and clone('foo') can meet the branch condition "typeof item==='string" of branch 2 of clone(item). '", therefore, the branch codes of these two branches are not redundant and do not need to be pruned.

而假定clone(item)只有一个针对clone(item)的函数调用clone(),clone()所使用的参数并不满足分支2的分支条件“typeof item===‘string’”,因此,分支2的分支代码(也即,对应于分支2的分支条件的分支代码)是冗余的,可以裁剪。裁剪后的clone(item)的函数体如下所示:Assuming that clone(item) has only one function call clone() for clone(item), the parameters used by clone() do not satisfy the branch condition "typeof item==='string'" of branch 2, therefore, branch 2 The branch code of (that is, the branch code corresponding to the branch condition of branch 2) is redundant and can be trimmed. The function body of clone(item) after clipping is as follows:

进一步地,所述分别对所述各分支条件中的每个分支条件执行后,还可以执行:若所述执行后的所述指定函数中只包含一个分支条件,则将表示该分支条件的代码删除。如此,可以进一步地消除代码冗余。Further, after executing each of the branch conditions respectively, it may also execute: if only one branch condition is included in the specified function after the execution, the code representing the branch condition delete. In this way, code redundancy can be further eliminated.

可以这样做的原因在于:若所述执行后的所述指定函数中只包含一个分支条件,则对于所述待处理代码中针对所述指定函数中的任一函数调用,对于该函数调用所使用的参数必定会满足该分支条件,因此,只要保留当满足该分支条件时所需执行的代码即可,而无需保留该分支条件本身。The reason for this is: if only one branch condition is included in the specified function after the execution, then for any function call in the specified function in the code to be processed, the function call used The parameters of must satisfy the branch condition, so it is only necessary to keep the code that needs to be executed when the branch condition is met, and it is not necessary to keep the branch condition itself.

为了便于理解,沿用上例进行说明。For ease of understanding, the above example is used for illustration.

对上例中裁剪后的clone(item)的函数体进一步地裁剪,进一步地裁剪后如下所示:The function body of clone(item) after clipping in the above example is further clipped, and after further clipping, it is as follows:

“function clone(item){ "function clone(item){

return item;return item;

}”}"

因为,在该例中待处理代码针对clone(item)的函数调用只有clone(),因此在执行函数调用时,无需再进行分支条件判断,直接执行“return item”即可。Because, in this example, the only function call of the code to be processed for clone(item) is clone(), so when the function call is executed, there is no need to judge the branch condition, and it is sufficient to directly execute "return item".

基于类似的思路,所述分别对所述各分支条件中的每个分支条件执行后,还可以执行:对于所述执行后的所述指定函数中最后一个分支条件以外的其他分支条件,若对应于所述其他分支条件的分支代码均会跳出所述指定函数,则将表示所述最后一个分支条件的代码删除。如此,也可以进一步地消除代码冗余。Based on a similar idea, after each branch condition in the branch conditions is executed, it can also be executed: for branch conditions other than the last branch condition in the specified function after the execution, if the corresponding If the branch codes of the other branch conditions all jump out of the specified function, the code representing the last branch condition is deleted. In this way, code redundancy can also be further eliminated.

可以这样做的原因在于:对于所述待处理代码中针对所述指定函数中的任一函数调用,若对于该函数调用所使用的参数,均不满足所述最后一个分支条件之前的各分支条件(若满足,则会跳出所述指定函数,不会再执行指定函数内的后续代码),则必定会满足所述最后一个分支条件,因此,只要保留当满足所述最后一个分支条件时所需执行的代码即可,而无需保留所述最后一个分支条件本身。The reason for this is: for any function call in the specified function in the code to be processed, if the parameters used in the function call do not satisfy the branch conditions before the last branch condition (if it is satisfied, the specified function will be jumped out, and the subsequent code in the specified function will not be executed), then the last branch condition must be satisfied, therefore, as long as the last branch condition is met, the required Execute the code without preserving the last branch condition itself.

上面对本申请实施例提供的一种代码处理方法进行了说明,基于同样的发明思路,本申请实施例还提供了对应的装置,如图2所示。The above describes a code processing method provided by the embodiment of the present application. Based on the same inventive idea, the embodiment of the present application also provides a corresponding device, as shown in FIG. 2 .

图2为本申请实施例提供的对应于图1的一种代码处理装置的结构示意图,该装置可以位于图1中流程的执行主体上,包括:Fig. 2 is a schematic structural diagram of a code processing device corresponding to Fig. 1 provided by the embodiment of the present application. The device can be located on the execution body of the process in Fig. 1, including:

获得模块201,获得待处理代码;Obtaining module 201, obtaining the code to be processed;

确定模块202,确定所述待处理代码中针对指定函数的各函数调用,以及所述指定函数中的各分支条件;Determining module 202, determining each function call for a specified function in the code to be processed, and each branch condition in the specified function;

处理模块203,根据所述分支条件和所述各函数调用所使用的参数,对所述指定函数中对应于所述分支条件的分支代码进行裁剪处理。The processing module 203, according to the branch condition and the parameters used by the function calls, performs tailoring processing on the branch code corresponding to the branch condition in the specified function.

可选地,所述确定模块202确定所述待处理代码中针对指定函数的各函数调用,以及所述指定函数中的各分支条件,具体包括:Optionally, the determination module 202 determines each function call for a specified function in the code to be processed, and each branch condition in the specified function, specifically including:

所述确定模块202生成所述待处理代码的语法树,根据所述待处理代码的语法树,确定所述待处理代码中针对指定函数的各函数调用和所述各函数调用所使用的参数,以及所述指定函数中的各分支条件。The determining module 202 generates a syntax tree of the code to be processed, and determines each function call for a specified function in the code to be processed and the parameters used by each function call according to the syntax tree of the code to be processed, and each branch condition in the specified function.

可选地,所述确定模块202根据所述待处理代码的语法树,确定所述待处理代码中针对指定函数的各函数调用和所述各函数调用所使用的参数,具体包括:Optionally, the determining module 202 determines each function call for a specified function in the code to be processed and the parameters used by each function call according to the syntax tree of the code to be processed, specifically including:

所述确定模块202根据所述待处理代码的语法树,确定所述待处理代码中的所有函数调用,以及确定分别确定所述所有函数调用所使用的参数,对确定的所述所有函数调用进行分类,所针对函数相同的函数调用被分在同一类中,在各类中确定针对指定函数的一类函数调用,以及确定该类函数调用所使用的参数。The determination module 202 determines all function calls in the code to be processed according to the syntax tree of the code to be processed, and determines the parameters used to determine all the function calls respectively, and executes on all the determined function calls Classification, the function calls for the same function are classified into the same class, and a type of function call for the specified function is determined in each category, and parameters used for this type of function call are determined.

可选地,所述确定模块202确定所述指定函数中的各分支条件,具体包括:Optionally, the determination module 202 determines each branch condition in the specified function, specifically including:

所述确定模块202根据所述待处理代码的语法树,确定所述指定函数的语法树,根据所述指定函数的语法树,确定所述指定函数中的各分支条件。The determination module 202 determines the syntax tree of the specified function according to the syntax tree of the code to be processed, and determines each branch condition in the specified function according to the syntax tree of the specified function.

可选地,所述处理模块203根据所述分支条件和所述各函数调用所使用的参数,对所述指定函数中对应于所述分支条件的分支代码进行裁剪处理,具体包括:Optionally, the processing module 203 performs tailoring processing on the branch code corresponding to the branch condition in the specified function according to the branch condition and the parameters used by the function calls, specifically including:

所述处理模块203分别对所述各分支条件中的每个分支条件执行:The processing module 203 respectively executes on each of the branch conditions:

分别根据所述各函数调用中的每个函数调用所使用的参数,确定对于该函数调用所使用的参数,是否可满足该分支条件;Determine whether the branch condition can be satisfied for the parameters used in the function call according to the parameters used in each of the function calls;

若对于所述每个函数调用所使用的参数,均不可满足该分支条件,则删除对应于该分支条件的分支代码。If the branch condition cannot be satisfied for the parameters used by each function call, delete the branch code corresponding to the branch condition.

可选地,所述处理模块203分别对所述各分支条件中的每个分支条件执行后,若所述执行后的所述指定函数中只包含一个分支条件,则将表示该分支条件的代码删除。Optionally, after the processing module 203 respectively executes each of the branch conditions, if the executed specified function contains only one branch condition, the code representing the branch condition delete.

可选地,所述处理模块203分别对所述各分支条件中的每个分支条件执行后,对于所述执行后的所述指定函数中最后一个分支条件以外的其他分支条件,若对应于所述其他分支条件的分支代码均会跳出所述指定函数,则将表示所述最后一个分支条件的代码删除。Optionally, after the processing module 203 respectively executes each of the branch conditions, for branch conditions other than the last branch condition in the specified function after execution, if the corresponding If the branch codes of the other branch conditions mentioned above all jump out of the specified function, the code representing the last branch condition is deleted.

可选地,所述代码为JavaScript代码。Optionally, the code is JavaScript code.

本申请实施例提供的装置与方法是一一对应的,因此,装置也具有与其对应的方法类似的有益技术效果,由于上面已经对方法的有益技术效果进行了详细说明,因此,这里不再赘述对应装置的有益技术效果。The device and the method provided in the embodiment of the present application are in one-to-one correspondence, therefore, the device also has beneficial technical effects similar to the corresponding method, since the beneficial technical effect of the method has been described in detail above, so it will not be repeated here The beneficial technical effect of the corresponding device.

在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable GateArray,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware DescriptionLanguage)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(RubyHardware Description Language)等,目前最普遍使用的是VHDL(Very-High-SpeedIntegrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, the improvement of a technology can be clearly distinguished as an improvement in hardware (for example, improvements in circuit structures such as diodes, transistors, and switches) or improvements in software (improvement in method flow). However, with the development of technology, the improvement of many current method flows can be regarded as the direct improvement of the hardware circuit structure. Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (Programmable Logic Device, PLD) (such as a Field Programmable Gate Array (Field Programmable Gate Array, FPGA)) is such an integrated circuit, and its logic function is determined by programming the device by a user. It is programmed by the designer to "integrate" a digital system on a PLD, instead of asking a chip manufacturer to design and make a dedicated integrated circuit chip. Moreover, nowadays, instead of making integrated circuit chips by hand, this kind of programming is mostly realized by "logic compiler (logic compiler)" software, which is similar to the software compiler used when writing programs. The original code of the computer must also be written in a specific programming language, which is called a hardware description language (Hardware Description Language, HDL), and there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., currently the most commonly used is VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. It should also be clear to those skilled in the art that only a little logical programming of the method flow in the above-mentioned hardware description languages and programming into an integrated circuit can easily obtain a hardware circuit for realizing the logic method flow.

控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable way, for example the controller may take the form of a microprocessor or processor and a computer readable medium storing computer readable program code (such as software or firmware) executable by the (micro)processor , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers, and embedded microcontrollers, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art also know that, in addition to realizing the controller in a purely computer-readable program code mode, it is entirely possible to make the controller use logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded The same function can be realized in the form of a microcontroller or the like. Therefore, such a controller can be regarded as a hardware component, and the devices included in it for realizing various functions can also be regarded as structures within the hardware component. Or even, means for realizing various functions can be regarded as a structure within both a software module realizing a method and a hardware component.

上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementing device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Combinations of any of these devices.

为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above devices, functions are divided into various units and described separately. Of course, when implementing the present application, the functions of each unit can be implemented in one or more pieces of software and/or hardware.

本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, systems, or computer program products. Accordingly, the present invention can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.

在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.

内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read only memory (ROM) or flash RAM. Memory is an example of computer readable media.

计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. Information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridge, tape magnetic disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.

还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes Other elements not expressly listed, or elements inherent in the process, method, commodity, or apparatus are also included. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.

本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems or computer program products. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。This 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 storage devices.

本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, refer to part of the description of the method embodiment.

以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above descriptions are only examples of the present application, and are not intended to limit the present application. For those skilled in the art, various modifications and changes may occur in this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims (16)

1. a kind of code process method, it is characterised in that including:
Obtain pending code;
Determine each function call for specified function in the pending code, and each branch's bar in the specified function Part;
The parameter according to used in the branch condition and each function call, to corresponding to described point in the specified function The branch code of branch condition carries out cutting processing.
2. the method as described in claim 1, it is characterised in that determine to be directed to each letter of specified function in the pending code Number is called, and each branch condition in the specified function, is specifically included:
Generate the syntax tree of the pending code;
According to the syntax tree of the pending code, determine in the pending code for specified function each function call and Each branch condition in parameter, and the specified function used in each function call.
3. method as claimed in claim 2, it is characterised in that the syntax tree according to the pending code, determines institute State in pending code for parameter used in each function call and each function call of specified function, specifically include:
According to the syntax tree of the pending code, all function calls in the pending code are determined, and determine to divide Parameter used in all function calls is not determined;
Pair determine all function calls classify, targeted function identical function call is in same class;
Called in all kinds of middle Certain function summaries for determining to be directed to specified function, and determine parameter used in such function call.
4. method as claimed in claim 2, it is characterised in that each branch condition in the determination specified function, tool Body includes:
According to the syntax tree of the pending code, the syntax tree of the specified function is determined;
According to the syntax tree of the specified function, each branch condition in the specified function is determined.
5. the method as described in claim 1, it is characterised in that described according to the branch condition and each function call institute The parameter used, carries out cutting processing to the branch code in the specified function corresponding to the branch condition, specifically includes:
Each branch condition in each branch condition is performed respectively:
Parameter used in each function call in each function call respectively, it is determined that being made for the function call Parameter, if the branch condition can be met;
If for parameter used in each function call, can not meet the branch condition, then delete and correspond to this point The branch code of branch condition.
6. method as claimed in claim 5, it is characterised in that described respectively to each branch's bar in each branch condition After part is performed, methods described also includes:
If only the code for representing the branch condition is deleted comprising a branch condition in the specified function after the execution Remove.
7. method as claimed in claim 5, it is characterised in that described respectively to each branch's bar in each branch condition After part is performed, methods described also includes:
For other branch conditions beyond last branch condition in the specified function after the execution, if corresponding to The branch code of other branch conditions can jump out the specified function, then will represent last branch condition Code deletion.
8. the method as described in any one of claim 1~7, it is characterised in that the code is JavaScript code.
9. a kind of code processing apparatus, it is characterised in that including:
Module is obtained, pending code is obtained;
Determining module, determines to be directed to each function call of specified function in the pending code, and in the specified function Each branch condition;
Processing module, the parameter according to used in the branch condition and each function call, to right in the specified function The branch code of branch condition described in Ying Yu carries out cutting processing.
10. device as claimed in claim 9, it is characterised in that the determining module determines to be directed in the pending code Each function call of specified function, and each branch condition in the specified function, are specifically included:
The determining module generates the syntax tree of the pending code, according to the syntax tree of the pending code, determines institute State in pending code for parameter used in each function call and each function call of specified function, and the finger Determine each branch condition in function.
11. device as claimed in claim 10, it is characterised in that the determining module is according to the grammer of the pending code Tree, determines for parameter used in each function call and each function call of specified function in the pending code, Specifically include:
The determining module determines that all functions in the pending code are adjusted according to the syntax tree of the pending code With, and determine to determine parameter used in all function calls respectively, pair all function calls determined are carried out Classification, targeted function identical function call is in same class, in all kinds of middle class letters determined for specified function Number is called, and determines parameter used in such function call.
12. device as claimed in claim 10, it is characterised in that the determining module determines each point in the specified function Branch condition, is specifically included:
The determining module determines the syntax tree of the specified function, according to described according to the syntax tree of the pending code The syntax tree of specified function, determines each branch condition in the specified function.
13. device as claimed in claim 9, it is characterised in that the processing module is according to the branch condition and described each Parameter used in function call, is carried out at cutting to the branch code in the specified function corresponding to the branch condition Reason, is specifically included:
The processing module is performed to each branch condition in each branch condition respectively:
Parameter used in each function call in each function call respectively, it is determined that being made for the function call Parameter, if the branch condition can be met;
If for parameter used in each function call, can not meet the branch condition, then delete and correspond to this point The branch code of branch condition.
14. device as claimed in claim 13, it is characterised in that the processing module is respectively in each branch condition After each branch condition is performed, if only comprising a branch condition in the specified function after the execution, will represent should The code deletion of branch condition.
15. device as claimed in claim 13, it is characterised in that the processing module is respectively in each branch condition After each branch condition is performed, for other points beyond last branch condition in the specified function after the execution Branch condition, if can jump out the specified function corresponding to the branch code of other branch conditions, will represent described in most The code deletion of latter branch condition.
16. the device as described in any one of claim 9~15, it is characterised in that the code is JavaScript code.
CN201710068399.0A 2017-02-08 2017-02-08 Code processing method and device Expired - Fee Related CN107038058B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710068399.0A CN107038058B (en) 2017-02-08 2017-02-08 Code processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710068399.0A CN107038058B (en) 2017-02-08 2017-02-08 Code processing method and device

Publications (2)

Publication Number Publication Date
CN107038058A true CN107038058A (en) 2017-08-11
CN107038058B CN107038058B (en) 2021-12-24

Family

ID=59533258

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710068399.0A Expired - Fee Related CN107038058B (en) 2017-02-08 2017-02-08 Code processing method and device

Country Status (1)

Country Link
CN (1) CN107038058B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107665124A (en) * 2017-09-14 2018-02-06 广东神马搜索科技有限公司 Modularization JavaScript file processing method, equipment and server
WO2019080091A1 (en) * 2017-10-27 2019-05-02 华为技术有限公司 Code processing method and device
CN110941431A (en) * 2018-09-21 2020-03-31 北京奇虎科技有限公司 Optimizing method and device for obfuscated code, computing device, and storage medium
CN111552638A (en) * 2020-04-23 2020-08-18 北京奇艺世纪科技有限公司 Code detection method and device
CN112889026A (en) * 2018-10-16 2021-06-01 电子湾有限公司 User interface resource file optimization

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102360305A (en) * 2011-10-09 2012-02-22 中国航天科技集团公司第五研究院第五一三研究所 VxWorks operating system scaling and customizing method for aerospace computer
US8782625B2 (en) * 2010-06-17 2014-07-15 Microsoft Corporation Memory safety of floating-point computations
CN104375875A (en) * 2013-08-15 2015-02-25 国际商业机器公司 Method for compiler optimization of applications and compiler
CN104572424A (en) * 2013-10-09 2015-04-29 阿里巴巴集团控股有限公司 Test method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8782625B2 (en) * 2010-06-17 2014-07-15 Microsoft Corporation Memory safety of floating-point computations
CN102360305A (en) * 2011-10-09 2012-02-22 中国航天科技集团公司第五研究院第五一三研究所 VxWorks operating system scaling and customizing method for aerospace computer
CN104375875A (en) * 2013-08-15 2015-02-25 国际商业机器公司 Method for compiler optimization of applications and compiler
CN104572424A (en) * 2013-10-09 2015-04-29 阿里巴巴集团控股有限公司 Test method and device

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107665124A (en) * 2017-09-14 2018-02-06 广东神马搜索科技有限公司 Modularization JavaScript file processing method, equipment and server
CN107665124B (en) * 2017-09-14 2021-04-20 阿里巴巴(中国)有限公司 Modular JavaScript file processing method, device and server
WO2019080091A1 (en) * 2017-10-27 2019-05-02 华为技术有限公司 Code processing method and device
CN111095197A (en) * 2017-10-27 2020-05-01 华为技术有限公司 Code processing method and device
CN111095197B (en) * 2017-10-27 2021-10-15 华为技术有限公司 Code processing method and device
CN110941431A (en) * 2018-09-21 2020-03-31 北京奇虎科技有限公司 Optimizing method and device for obfuscated code, computing device, and storage medium
CN112889026A (en) * 2018-10-16 2021-06-01 电子湾有限公司 User interface resource file optimization
CN111552638A (en) * 2020-04-23 2020-08-18 北京奇艺世纪科技有限公司 Code detection method and device
CN111552638B (en) * 2020-04-23 2023-08-18 北京奇艺世纪科技有限公司 Code detection method and device

Also Published As

Publication number Publication date
CN107038058B (en) 2021-12-24

Similar Documents

Publication Publication Date Title
CN107577694B (en) Data processing method and device based on block chain
CA3048740C (en) Blockchain-based data processing method and device
CN110245468B (en) Compilation method, device, equipment and system
CN107038058A (en) A kind of code process method and device
JP2020514866A (en) Blockchain-based data processing method and apparatus
CN107506181A (en) Business processing, data processing method, device and electronic equipment
CN109597678B (en) Task processing method and device
CN107045438B (en) Application top view processing method, device and component
US11176161B2 (en) Data processing method, apparatus, and device
CN107479868B (en) Interface loading method, device and device
US12443355B2 (en) Data storage methods, apparatuses, devices, and storage media
CN115391426A (en) Data query method and device, storage medium and electronic equipment
CN108491468A (en) A kind of document processing method, device and server
CN108304313B (en) Device, client and method for data testing
CN107402953A (en) A kind of method for page jump and device
CN107885443B (en) Information processing method and device
KR20170071495A (en) A method and device for determining a category directory, and an automatic classification method and device
CN116304704A (en) A model training method, device, storage medium and electronic equipment
CN116842715A (en) Simulation data structuring processing system
CN114115016A (en) Data processing method, device, equipment and medium
US20240143298A1 (en) Data processing methods and apparatuses, devices, and storage mediums
CN115017915B (en) Model training and task execution method and device
CN109815116A (en) A kind of method for testing software and equipment platform and computer readable storage medium
CN113590490B (en) An automated testing method, device and equipment
CN108133123A (en) A kind of recognition methods of application program and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20200924

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200924

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20211224

CF01 Termination of patent right due to non-payment of annual fee