# US 2007/0234288 A1 · Type inference system and method

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2007/0234288 A1
- Document ID: US20070234288A1
- Status: Published application
- Kind: A1
- Application number: 11/655,729
- Filed: 2007-01-19
- Published: 2007-10-04
- Earliest claimed: 2006-01-20
- Assignees: Aptana, Inc.
- Inventors: Kevin Lindsey; Paul Colton; Robin Debreuil; Donald Washburn
- Web page: https://patentgrep.com/patent/US20070234288A1

## CPC

- G06F 8/72: Code refactoring
- G06F 8/437: {Type checking}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods of representing and extracting type information from typeless and dynamically-typed programming languages are provided. These systems and methods can be immune to source file edits and the order in which those edits are executed. Deriving type information from these languages allows tools to perform operations, for example, refactoring, intellisense, recognition of semantic errors, etc. These systems and methods can be implemented using processes that, implicitly or explicitly, gather type information for the program, and can also accept user input as well.

## Claims

### Claim 1

A method for extracting type information comprising:
generating nodes associated with symbols;
requesting type information based on a particular symbol; and
returning a value associated with the particular symbol.

### Claim 2 (depends on 1)

The method of claim 1, wherein the generating step is performed by a parser.

### Claim 3 (depends on 1)

The method of claim 1, wherein the nodes comprise Abstract Syntax Tree (AST) nodes.

### Claim 4 (depends on 3)

The method of claim 3, wherein the generating step is performed in a runtime environment.

### Claim 5 (depends on 1)

The method of claim 1, wherein the generating step occurs while a code is being modified.

### Claim 6 (depends on 1)

The method of claim 1, wherein the generating step include parsing and associating symbols.

### Claim 7 (depends on 1)

The method of claim 1, wherein the requesting step is performed by an outside process.

### Claim 8 (depends on 7)

The method of claim 7, wherein the outside process is an Integrated Development Environment (IDE).

### Claim 9 (depends on 1)

The method of claim 1, wherein the requesting step is performed during editing of code.

### Claim 10 (depends on 1)

The method of claim 1, wherein the requesting step includes querying a runtime environment using a key.

### Claim 11 (depends on 10)

The method of claim 10, wherein the key comprises position information and symbol information.

### Claim 12 (depends on 1)

The method of claim 1, further comprising using a symbol to retrieve information about an underlying object being queried.

### Claim 13 (depends on 1)

The method of claim 1, wherein the symbols have different type information at different positions in a source code.

### Claim 14 (depends on 1)

The method of claim 1, wherein the returning step occurs once the particular symbol is located in an environment.

### Claim 15 (depends on 1)

The method of claim 1, wherein the value is an abstract syntax tree.

### Claim 16 (depends on 1)

The method of claim 1, wherein the returning step includes evaluating the value based on a current state of an environment and returning a type at that moment in time for a given file and file offset.

### Claim 17 (depends on 1)

The method of claim 1, wherein the generating step further includes creating a node in an abstract syntax tree for each occurrence of a symbol.

### Claim 18 (depends on 1)

The method of claim 1, further including storing information for each occurrence of a symbol and inferring a type for each occurrence of the symbol.

### Claim 19

A method for populating a type environment, comprising:
processing inputs obtained from one or more sources into type information;
populating a type environment with the type information; and
performing one or more queries on the type information.

### Claim 20 (depends on 19)

The method of claim 19, further comprising combining the type environment with runtime environment information.

### Claim 21 (depends on 19)

The method of claim 19, wherein the inputs comprise structured data that can be converted into type information.

### Claim 22 (depends on 19)

The method of claim 19, further comprising storing the type information as metadata.

### Claim 23 (depends on 19)

The method of claim 19, further comprising using a hash table to implement the type environment.

### Claim 24 (depends on 23)

The method of claim 23, wherein the hash table includes information pertaining to a reference count that indicates the number of times a variable is referenced.

### Claim 25 (depends on 23)

The method of claim 23, wherein the hash table includes information pertaining to the one or more values that a referenced variable may take at a given point in a source.

### Claim 26 (depends on 19)

The method of claim 19, wherein the inputs comprise one or more source files.

### Claim 27 (depends on 26)

The method of claim 26, wherein the processing step further comprises analyzing source code in the one or more of the source files and extracting information for symbols defined in the one or more source files.

### Claim 28 (depends on 27)

The method of claim 27, wherein the extracted information is the type information.

### Claim 29 (depends on 26)

The method of claim 26, wherein the processing step further comprising extracting information from the one or more source files, sending the extracted information to the type environment and storing the extracted information.

### Claim 30 (depends on 26)

The method of claim 26, further comprising merging the extracted information with information already existing in the type environment.

### Claim 31 (depends on 26)

The method of claim 26, further comprising executing the source files.

### Claim 32 (depends on 26)

The method of claim 26, further comprising parsing the source files.

### Claim 33 (depends on 19)

The method of claim 19, wherein the processing step further comprises:
identifying lexemes in the inputs;
organizing the lexemes into a stream of lexemes;
detecting patterns in the stream of lexemes;
generating data structures representing the detected patterns; and
associating symbols with the data structures.

### Claim 34 (depends on 33)

The method of claim 33, wherein the data structures are abstract syntax trees.

### Claim 35 (depends on 33)

The method of claim 33, wherein generating the data structures is performed by a parser.

### Claim 36 (depends on 33)

The method of claim 33, wherein the associating step includes using a tree walker.

### Claim 37 (depends on 33)

The method of claim 33, wherein further comprising storing the data structures in the type environment as the type environment is being created.

### Claim 38 (depends on 33)

The method of claim 33, wherein the data structure comprises a key capable of querying a hash table, the key including a symbol identifying field, a file index field and an offset field.

### Claim 39

A computer program product comprising a computer useable medium having computer program logic recorded thereon for populating a type environment, comprising:
computer program code logic configured to process inputs obtained from one or more sources into type information;
computer program code logic configured to populate a type environment with the type information; and
computer program code logic configured to perform one or more queries on the type information.

### Claim 40 (depends on 39)

The computer program product of claim 39, further comprising computer program code logic configured to combine the type environment with runtime environment information.

### Claim 41 (depends on 39)

The computer program product of claim 39, wherein the inputs comprise structured data capable of being converted into type information.

### Claim 42 (depends on 39)

The computer program product of claim 39, further comprising computer program code logic configured to store the type information as metadata.

### Claim 43 (depends on 39)

The computer program product of claim 39, further comprising computer program code logic configured to use a hash table to implement the type environment.

### Claim 44 (depends on 43)

The computer program product of claim 43, wherein the hash table includes information pertaining to a reference count that indicates the number of times a variable is referenced.

### Claim 45 (depends on 43)

The computer program product of claim 43, wherein the hash table includes information pertaining to the one or more values that a referenced variable may take at a given point in a source.

### Claim 46 (depends on 39)

The computer program product of claim 39, wherein the inputs comprise one or more source files.

### Claim 47 (depends on 46)

The computer program product of claim 46, wherein the computer program code logic configured to process the inputs further comprises computer program code logic configured to analyze source code in the one or more of the source files and extract information for symbols defined in the one or more source files.

### Claim 48 (depends on 47)

The computer program product of claim 47, wherein the extracted information is the type information.

### Claim 49 (depends on 46)

The computer program product of claim 46, wherein the computer program code logic configured to process the inputs further comprises computer program code logic configured to extract information from the one or more source files, send the extracted information to the type environment and store the extracted information.

### Claim 50 (depends on 46)

The computer program product of claim 46, further comprising computer program code logic configured to merge the extracted information with information already existing in the type environment.

### Claim 51 (depends on 46)

The computer program product of claim 46, further comprising computer program code logic configured to execute the source files.

### Claim 52 (depends on 46)

The computer program product of claim 46, further comprising computer program code logic configured to parse the source files.

### Claim 53 (depends on 39)

The computer program product of claim 39, wherein the computer program code logic configured to process the inputs further comprises computer program code logic configured to:
identify lexemes in the inputs;
organize the lexemes into a stream of lexemes;
detect patterns in the stream of lexemes;
generate data structures representing the detected patterns; and
associate symbols with the data structures.

### Claim 54 (depends on 53)

The computer program product of claim 53, wherein the data structures are abstract syntax trees.

### Claim 55 (depends on 53)

The computer program product of claim 53, wherein the data structure comprises a key capable of querying a hash table, the key including a symbol identifying field, a file index field and an offset field.
