A method for searching for a class and a function based on a microprocessor smart card based on .net technology, which is applied during execution of an assembly in the microprocessor smart card based on .net technology, wherein the assembly comprises groups of classes and functions, the method comprises:
- building a first character string according to information of a class currently executed by the microprocessor smart card based on .net technology, or information of a function currently executed by the microprocessor smart card based on .net technology and a class that the function belongs to;
- computing a first index value from the first character string, wherein the first character string is hashed to obtain a hash value of the class currently executed or the function currently executed, and the first index value is obtained with the hash value modulo operation being performed on the total number of classes and functions corresponding to the index values in the index table;
- searching for a first locator value corresponding to the first index value in an index table pre-stored in the microprocessor smart card based on .net technology, wherein index values in the index table are generated in the same way as the first index value is generated, wherein, the index table includes index values and corresponding locator values, a locator value corresponds to entity content of a class or a function in the class library of the microprocessor smart card based on .net technology;
- finding the class or the function in a runtime library of the microprocessor smart card based on .net technology according to the first locator value and invoking the entity of the class or the function;
- the method further comprising:
- if the first index value is not included in the index table, building a second character string according to information of a superclass of a current class and the information of the function, with the class that the function currently executed by the microprocessor smart card based on .net technology belongs to as the current class, and computing a second index value from the second character string;
- determining whether the second index value is included in the index table;
- if the second index value is included in the index table, searching for a second locator value corresponding to the second index value in the index table, and finding the class currently executed by the microprocessor smart card based on .net technology in the runtime library of the microprocessor smart card based on .net technology according to the second locator;
- if the second index value is not included in the index table, performing a process which is the same as the process of obtaining the second index value with the superclass as a current class until a third index value which is included in the index table is found, searching for a third locator value corresponding to the third index value in the index table, and finding the class currently executed by the microprocessor smart card based on .net technology in the runtime library of the microprocessor smart card based on .net technology according to the third locator value;
- wherein the step of building the first character string according to the information of the class currently executed by the microprocessor smart card based on .net technology comprises:
- forming the first character string by a class name and a namespace of the class currently executed by the microprocessor smart card based on .net technology;
- or
- forming the first character string by a class name and a namespace of the class that the function currently executed by the microprocessor smart card based on .net technology belongs to, a function name of the function, and a class name and a namespace of each parameter of the function;
- wherein the index table is stored in the assembly in the microprocessor smart card based on .net technology.