Patent ID: 7516449
Filing Date: 2009-04-07
Classification: G06F,Y10S

Abstract:
1. A computer-implemented method of converting, at run-time, a class of an object in an object-oriented programming environment, said method comprising: defining a plurality of classes in said object-oriented programming environment; receiving C++ source code by a computing system and subsequent to said defining said plurality of classes; generating intermediate code from said source code during compile time, wherein said generating said intermediate code is performed by said computing system and subsequent to said receiving said source code; identifying, by said computing system and subsequent to said generating said intermediate code, a type conversion statement within said intermediate code, wherein said type conversion statement indicates that said object is to be converted from a source class to a destination class, wherein said source class and said destination class are included in said plurality of classes, wherein said destination class is not an extension of another class of said plurality of classes, wherein said source class defines one or more source class members, and wherein said destination class defines one or more destination class members; determining, by said computing system and subsequent to said identifying said type conversion statement, that said destination class is polymorphic to said source class; determining, by said computing system and subsequent to said identifying said type conversion statement, that a first amount of memory space required for said destination class is less than or equal to a second amount of memory space required for said source class, wherein said determining that said first amount of memory space is less than or equal to said second amount of memory space includes determining that said one or more destination class members does not include a non-static member in addition to said one or more source class members, and wherein said non-static member is associated with an instance of said destination class but is not associated with said destination class as a whole; retrieving, by said computing system and subsequent to said identifying said type conversion statement, a class hierarchy from a symbol table, wherein said class hierarchy includes said source class, said destination class and a common parent class, wherein said common parent class includes a member or a function inherited by said source class and said destination class; traversing up at compile time, by said computing system and subsequent to said retrieving said class hierarchy, said class hierarchy from said source class to said common parent class via a first set of one or more pairs of classes included in said class hierarchy, wherein a pair of said first set of one or more pairs includes an intermediate upward source class and an intermediate upward destination class, and wherein said traversing up at compile time includes generating a first set of machine-executable code; traversing down at compile time, by said computing system and subsequent to said traversing up at compile time, said class hierarchy from said common parent class to said destination class via a second set of one or more pairs of classes included in said class hierarchy, wherein a pair of said second set of one or more pairs includes an intermediate downward source class and an intermediate downward destination class, and wherein said traversing down at compile time includes generating a second set of machine-executable code; retrieving, by said computing system, a source class layout of said source class, wherein said source class layout is a first data structure that specifies a plurality of properties of said source class including said one or more source class members and a pointer to a first table (first v-table) of one or more virtual functions that determine one or more behaviors of said source class; retrieving, by said computing system, a destination class layout of said destination class, wherein said destination class layout is a second data structure that specifies a plurality of properties of said destination class including said one or more destination class members and a pointer to a second table (second v-table) of one or more virtual functions that determine one or more behaviors of said destination class; retrieving, by said computing system, an object layout of said object, wherein said object layout is a third data structure that specifies a plurality of properties of said object including one or more data members and a pointer to a table (v-table referenced by said object) of one or more virtual functions that are bound to said object at runtime and that determine one or more behaviors of said object at runtime, wherein said pointer to said v-table referenced by said object is initially said pointer to said first v-table; receiving a pointer to said object by said computing system at runtime, wherein said pointer is included in a plurality of pointers referencing said object at runtime; updating said pointer to said v-table referenced by said object from said pointer to said first v-table to said pointer to said second v-table by said computing system at runtime, wherein said updating said pointer includes: wherein said updating said pointer is performed without changing an address of said object layout and without changing said source class layout, said destination class layout or any other class layout of said plurality of classes, and wherein said plurality of pointers referencing said object remain valid after said updating said pointer.