发明名称 Method for compressing a .net file
摘要 The invention discloses a method for compressing a .net file, characterized by at least one of the following steps of obtaining and compressing reference type in a .net tile; obtaining and compressing definition method in a .net file; obtaining and compressing method body of the definition method in a .net file; obtaining and compressing Namespace in a .net file; obtaining and compressing definition type in a .net file. By compressing the .net file, the invention efficiently reduces the storage space occupied by the .net file, and makes it stored in a small-sized medium, such as a smart card.
申请公布号 US8805801(B2) 申请公布日期 2014.08.12
申请号 US201013129296 申请日期 2010.12.29
申请人 Feitian Technologies Co., Ltd. 发明人 Lu Zhou;Yu Huazhang
分类号 G06F17/30;G06F9/445 主分类号 G06F17/30
代理机构 Fay Sharpe LLP 代理人 Fay Sharpe LLP
主权项 1. A method for compressing a non-compressed file compiled by a .net platform, wherein the method comprises the steps of: obtaining and compressing a reference type in the non-compressed file compiled by the .net platform; obtaining and compressing a definition method in the non-compressed file compiled by the .net platform; obtaining and compressing a method body of the definition method in the non-compressed file compiled by the .net platform; obtaining and compressing a Namespace in the non-compressed file compiled by the .net platform; and obtaining and compressing a definition type in the non-compressed file compiled by the .net platform, wherein the obtaining and compressing the reference type in the non-compressed file compiled by the .net platform comprises the steps of: obtaining and compressing a name of the reference type used in the non-compressed file compiled by the .net platform to obtain a compressed name of the reference type, counting methods and fields in the reference type, combining the compressed name with the method and field counts in the reference type according to a predetermined format, to obtain a compression result of the reference type, wherein the obtaining and compressing the method body of the definition method comprises the steps of: obtaining a header of the definition method from the non-compressed file compiled by the .net platform; compressing the method body of the definition method and obtaining a compression result of the method body; the method further comprises a step of determining whether method headers of all definition methods in the non-compressed file compiled by the .net platform have been read and all corresponding method bodies have been compressed, if not, keeping reading the header of the next definition method; if yes, ending the compression, wherein the compressing the method body of the definition method comprises the steps of: obtaining local variables of the definition method according to the header of the definition method, and an offset of the local variables, referring to the offset of the local variables in a compressed structure corresponding to the non-compressed file compiled by the .net platform, according to a type of the local variables; reading an ILcode of the definition method according to the header of the definition method, compressing the ILcode and computing a length of the compressed ILcode; combining the length of the compressed ILcode, offset of the local variables and compressed ILcode according to a predefine form to obtain a compression result of the method body; the wherein compressing the ILcode comprises the steps of: reading an instruction from the ILcode and determining whether there is a parameter with the instruction, if not, recording the instruction directly; if yes, further determining a type of the parameter, if the parameter is a jump offset, obtaining a jumped ILcode according to the jump offset, computing the jump offset according to the jumped ILcode, recording the instruction and computed jump offset; if the parameter is an offset of the local variables in the method body, recording the instruction and parameter; if the parameter is a token, obtaining an offset of the token in the compressed structure, recording the instruction and obtained offset; the wherein compressing the ILcode further comprises the steps of: determining whether all the instructions and parameters in the ILcode have been read and compressed, if yes, computing the length of the compressed ILcode; if not, reading and compressing the following instruction; wherein the obtaining and compressing the definition type in the non-compressed file compiled by the .net platform comprises the steps of: obtaining information included in the definition type of the non-compressed file compiled by the .net platform; obtaining a prescribed information and count according to the information included in the definition type; compressing the prescribed information; taking the compressed prescribed information and count as a compression result of the definition type and storing it, wherein the information included in the definition type comprises a token, a name offset and a method offset of the definition type; accordingly the prescribed information comprises a token and a name of the definition type; the count comprises method reloading information and method count of the definition type; the definition type token is divided into three types, class token, access token and description token; accordingly, the compressing the prescribed information comprises the steps of: performing an OR operation on the class token, access token and description token and taking a result of the OR operation as a compression result of the definition type token; performing a hash operation on the definition type name and taking prescribed bytes of a result of the hash operation as a compression result of the definition type name.
地址 Beijing CN