发明名称 |
Efficient and expansive conversions between reference and primitive |
摘要 |
A tool, such as a compiler or an interpreter, receives program source code and determines that the code includes an operation for which type conversion is permitted on an operand. The tool determines a source type of the operand, and a target type to which the operand is to be converted. In response to determining that the source type is a reference type and the target type is a primitive type, the tool generates a set of instructions to (a) determine whether, at run time, in accordance with a class definition of the reference type, a value of the target primitive type can be obtained via one or more method invocations on the operand (b) if such a value can be obtained, obtain the value and assign the value to a result of the operation and (c) if such a value cannot be obtained, generate an error indication. |
申请公布号 |
US8863079(B2) |
申请公布日期 |
2014.10.14 |
申请号 |
US201213563587 |
申请日期 |
2012.07.31 |
申请人 |
Oracle International Corporation |
发明人 |
Darcy Joseph D.;Cimadamore Maurizio;Buckley Alexander R. |
分类号 |
G06F9/44;G06F9/45 |
主分类号 |
G06F9/44 |
代理机构 |
Meyertons, Hood, Kivlin, Kowert & Goetzel, P.C. |
代理人 |
Kowert Robert C.;Meyertons, Hood, Kivlin, Kowert & Goetzel, P.C. |
主权项 |
1. A non-transitory computer-readable storage medium storing program instructions executable by a computer to implement a tool configured to:
receive source code for a computer program, written in a programming language that supports primitive types and reference types; determine, for an operation in the source code for which type conversion is permitted on at least one operand, a source type of the operand and a target type to which the operand is to be converted; in response to determining that the source type is a reference type corresponding to a source primitive type and the target type is a primitive type different than the source primitive type, generate a set of instructions to:
determine whether, at run time, in accordance with a class definition of the reference type, a value of the target primitive type can be obtained via one or more method invocations on the operand;in response to determining that a value of the target primitive type can be obtained, obtain the value and assign the value to a result of the operation; andin response to determining that a value of the target primitive type cannot be obtained, generate an error indication. |
地址 |
Redwood City CA US |