IP Library Granted Patent US 10,013,245
Granted Patent B2
US 10,013,245 · App. 15/083,167 · Granted Jul 3, 2018

Systems and methods for converting typed code

Inventor: Julien Marcel Verlaguet (Palo Alto, CA)
Assignee: Facebook, Inc.
G06F8/51G06F8/40G06F8/437G06F8/443G06F9/38G06F9/3846G06F8/41G06F9/45508
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,013,245
App. No.
15/083,167
Granted
Jul 3, 2018
Kind
B2
Abstract

Techniques provided implement automatic data type annotation in dynamically-typed source code. A codebase, which may comprise a plurality of source code files, is scanned at a global level. The resulting scanned data may describe characteristics of the codebase, including variable and function usage. Based on inferences drawn from the scanning, data types are determined for different variables, expressions, or functions to facilitate conversion from dynamically-typed source code to statically-typed source code. For example, if a function is called once with a parameter value of data type A (e.g., class A), and another time with a parameter value of data type B (e.g., class B), a conversion tool may annotate the parameter variable in the declaration of the function with a data type D (e.g., class d) when data type D is identified as a common ancestor (e.g., superclass) to both data type A and data type B.

Claims (37)

1. A computer-implemented method comprising:

scanning, by a computer system, a codebase to determine a first set of characteristics associated with a first dynamically-typed variable or function in the codebase;

determining, by the computer system, a first set of potential data types for the first dynamically-typed variable or function based on the first set of characteristics;

determining, by the computer system, a first candidate data type that is a superclass of data types associated with the first set of characteristics, and wherein each of the data types associated with the first set of characteristics is a subclass of the first candidate data type;

converting, by the computer system, the first dynamically-typed variable or function in the codebase to a first statically-typed variable or function in the codebase based on the first candidate data type; and

checking, by the computer system, the codebase for one or more errors in response to the converting the first dynamically-typed variable or function to the first statically-typed variable or function.

2. The computer-implemented method of claim 1 , wherein scanning the codebase generates at least one of a fact or a constraint regarding source code included in the codebase.

3. The computer-implemented method of claim 1 , wherein the superclass of the data types associated with the first set of characteristics corresponds to a common ancestor to each of the data types associated with the first set of characteristics.

4. The computer-implemented method of claim 1 , wherein converting the first dynamically-typed variable or function in the codebase to the first statically-typed variable or function in the codebase further comprises converting a source code from a first programming language that permits dynamic data typing to a second programming language that requires static data typing.

5. The computer-implemented method of claim 1 , wherein converting the first dynamically-typed variable or function in the codebase to the first statically-typed variable or function in the codebase further comprises modifying the first dynamically-typed variable or function to be statically typed thereby producing the first statically-typed variable or function.

6. The computer-implemented method of claim 5 , wherein modifying the first dynamically-typed variable or function further comprises invoking static typing with respect to the first dynamically-typed variable or function.

7. The computer-implemented method of claim 5 , wherein modifying the first dynamically-typed variable or function further comprises annotating the first dynamically-typed variable or function with one or more reserved keywords for a programming language associated with the first dynamically-typed variable or function.

8. A computer system comprising:

at least one processor; and

a memory storing instructions configured to instruct the at least one processor to perform:

scanning a codebase to determine a first set of characteristics associated with a first dynamically-typed variable or function in the codebase;

determining a first set of potential data types for the first dynamically-typed variable or function based on the first set of characteristics;

determining a first candidate data type that is a superclass of data types associated with the first set of characteristics, and wherein each of the data types associated with the first set of characteristics is a subclass of the first candidate data type;

converting the first dynamically-typed variable or function in the codebase to a first statically-typed variable or function in the codebase based on the first candidate data type; and

checking the codebase for one or more errors in response to the converting the first dynamically-typed variable or function to the first statically-typed variable or function.

9. The computer system of claim 8 , wherein scanning the codebase generates at least one of a fact or a constraint regarding source code included in the codebase.

10. The computer system of claim 8 , wherein the superclass of the data types associated with the first set of characteristics corresponds to a common ancestor to each of the data types associated with the first set of characteristics.

11. The computer system of claim 8 , wherein converting the first dynamically-typed variable or function in the codebase to the first statically-typed variable or function in the codebase further comprises converting a source code from a first programming language that permits dynamic data typing to a second programming language that requires static data typing.

12. The computer system of claim 8 , wherein converting the first dynamically-typed variable or function in the codebase to the first statically-typed variable or function in the codebase further comprises modifying the first dynamically-typed variable or function to be statically typed thereby producing the first statically-typed variable or function.

13. The computer system of claim 12 , wherein modifying the first dynamically-typed variable or function further comprises invoking static typing with respect to the first dynamically-typed variable or function.

14. The computer system of claim 12 , wherein modifying the first dynamically-typed variable or function further comprises annotating the first dynamically-typed variable or function with one or more reserved keywords for a programming language associated with the first dynamically-typed variable or function.

15. A non-transitory computer-storage medium storing computer-executable instructions that, when executed, cause a computer system to perform a computer-implemented method comprising:

scanning, by a computer system, a codebase to determine a first set of characteristics associated with a first dynamically-typed variable or function in the codebase;

determining, by the computer system, a first set of potential data types for the first dynamically-typed variable or function based on the first set of characteristics;

determining, by the computer system, a first candidate data type that is a superclass of data types associated with the first set of characteristics, and wherein each of the data types associated with the first set of characteristics is a subclass of the first candidate data type;

converting, by the computer system, the first dynamically-typed variable or function in the codebase to a first statically-typed variable or function in the codebase based on the first candidate data type; and

checking, by the computer system, the codebase for one or more errors in response to the converting the first dynamically-typed variable or function to the first statically-typed variable or function.

16. The non-transitory computer-storage medium of claim 15 , wherein scanning the codebase generates at least one of a fact or a constraint regarding source code included in the codebase.

17. The non-transitory computer-storage medium of claim 15 , wherein the superclass of the data types associated with the first set of characteristics corresponds to a common ancestor to each of the data types associated with the first set of characteristics.

18. The non-transitory computer-storage medium of claim 15 , wherein converting the first dynamically-typed variable or function in the codebase to the first statically-typed variable or function in the codebase further comprises converting a source code from a first programming language that permits dynamic data typing to a second programming language that requires static data typing.

19. The non-transitory computer-storage medium of claim 15 , wherein converting the first dynamically-typed variable or function in the codebase to the first statically-typed variable or function in the codebase further comprises modifying the first dynamically-typed variable or function to be statically typed thereby producing the first statically-typed variable or function.

20. The non-transitory computer-storage medium of claim 19 , wherein modifying the first dynamically-typed variable or function further comprises invoking static typing with respect to the first dynamically-typed variable or function.

Assignments (2)
CHANGE OF NAME Recorded Dec 1, 2021
From: FACEBOOK, INC.
To: META PLATFORMS, INC.
Reel/Frame 058645/0271 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 8, 2016
From: VERLAGUET, JULIEN MARCEL
To: FACEBOOK, INC.
Reel/Frame 038237/0866 →
Continuity (2)
Continuation 14010266 · Aug 26, 2013
Related Publication 20160210129A1 · Jul 21, 2016
Cited By (2)
US 12,498,984 US 12,554,550