Contextual typing
First Claim
Patent Images
1. A method comprising:
- receiving a parse tree representing program source code by a processor of a software development computer, the program source code comprising at least one enclosing expression, the enclosing expression enclosing at least one enclosed expression;
assigning a type associated with the enclosing expression to the at least one enclosed expression by;
evaluating the at least one enclosing expression of the parse tree for applicability of contextual typing by;
comparing the at least one enclosing expression of the parse tree with a set of templates;
selecting a template from the set of templates, the selected template matching the at least one enclosing expression, the selected template associated with a process for assigning a type to the at least one enclosed expression; and
assigning a type to the at least one enclosed expression by performing the process for assigning type to the at least one enclosed expression associated with the selected template in a top down direction; and
providing type information for the at least one enclosed expression whose type is inferred from the type of an expression that encloses the enclosed expression on a display device.
2 Assignments
0 Petitions
Accused Products
Abstract
Type inference is used to provide the benefits of static type checking without explicitly declaring type in the source code. Type inference that proceeds in a bottom up direction is augmented by contextual typing that proceeds in a top down direction. Contextual typing types enclosed expressions by associating the type of a directly enclosing expression with the enclosed expression. Object literals, function literals and array literals enclosed in assignment and call expressions, can be contextually typed.
-
Citations
20 Claims
-
1. A method comprising:
-
receiving a parse tree representing program source code by a processor of a software development computer, the program source code comprising at least one enclosing expression, the enclosing expression enclosing at least one enclosed expression; assigning a type associated with the enclosing expression to the at least one enclosed expression by; evaluating the at least one enclosing expression of the parse tree for applicability of contextual typing by; comparing the at least one enclosing expression of the parse tree with a set of templates; selecting a template from the set of templates, the selected template matching the at least one enclosing expression, the selected template associated with a process for assigning a type to the at least one enclosed expression; and assigning a type to the at least one enclosed expression by performing the process for assigning type to the at least one enclosed expression associated with the selected template in a top down direction; and providing type information for the at least one enclosed expression whose type is inferred from the type of an expression that encloses the enclosed expression on a display device. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A system comprising:
-
at least one processor; a memory connected to the at least one processor; and a module that when loaded into the at least one processor causes the at least one processor to; perform contextual typing by; receiving program source code comprising an enclosing expression, the enclosing expression enclosing at least one enclosed expression; and assigning a data type of the enclosing expression to the at least one enclosed expression in a top down direction; and display the data type of the enclosed expression. - View Dependent Claims (8, 9, 10, 11, 12, 13)
-
-
14. A device, comprising:
-
at least one processor and a memory;
the at least one processor configured to;perform contextual typing by; receiving a parse tree representing a syntax structure of a program source code, the program source code comprising at least one enclosing expression, the at least one enclosing expression enclosing at least one enclosed expression; and assigning a type of the enclosing expression to the at least one enclosed expression of the parse tree in a top down direction of the parse tree. - View Dependent Claims (15, 16, 17, 18, 19, 20)
-
Specification