09 Type-based Analysis

# 09 Type-based Analysis - Section Outline Type and...

This preview shows pages 1–9. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Section Outline Type- and Constraint-Based Analysis Constraint-based Analysis Type-based Analysis ◮ Type Systems ◮ Type Inference ◮ Steensgaard’s Flow-Insensitive Pointer Analysis Relation to Datafow Analysis Ben Hardekopf () CS 290C Program Analysis Fall 2011 1 / 71 Section Outline Type- and Constraint-Based Analysis Constraint-based Analysis Type-based Analysis ◮ Type Systems ◮ Type Inference ◮ Steensgaard’s Flow-Insensitive Pointer Analysis Relation to Datafow Analysis Ben Hardekopf () CS 290C Program Analysis Fall 2011 2 / 71 What Is A Type? Definition (Type) A type is a set of related values, or equivalently, a logical predicate. Types approximate values. An expression of type τ must have a value that belongs to the set of values described by τ . Ben Hardekopf () CS 290C Program Analysis Fall 2011 3 / 71 What Is A Type? Definition (Type) A type is a set of related values, or equivalently, a logical predicate. Types approximate values. An expression of type τ must have a value that belongs to the set of values described by τ . Example The statement “ exp : int ” states that expression exp evaluates to an integer. It is equivalent to the predicate int ( exp ) = true . Ben Hardekopf () CS 290C Program Analysis Fall 2011 3 / 71 What Is A Type? Definition (Type) A type is a set of related values, or equivalently, a logical predicate. Types approximate values. An expression of type τ must have a value that belongs to the set of values described by τ . Example The statement “ exp : int ” states that expression exp evaluates to an integer. It is equivalent to the predicate int ( exp ) = true . Example (Common Types) Type Description Example int integers 42 bool boolean values true int [ ] array of integers [1, 1, 2, 3] int → bool functions from int to bool fun ( x : int ) { return x ≤ } Ben Hardekopf () CS 290C Program Analysis Fall 2011 3 / 71 What Are Types Good For? Types prevent certain kinds of semantically nonsensical computations, i.e., computations that are not defined in the semantics of a language. Example (Ill-typed Program) def foo = fun (x) { y := x+1 ; return y } z := 1 + foo Ben Hardekopf () CS 290C Program Analysis Fall 2011 4 / 71 What Are Types Good For? Types prevent certain kinds of semantically nonsensical computations, i.e., computations that are not defined in the semantics of a language. Example (Ill-typed Program) def foo = fun (x) { y := x+1 ; return y } z := 1 + foo But not all kinds of errors. A program can still compute something of the right type , but the wrong value . Example (Well-typed, but Incorrect Program) def AbsVal = fun (x) { if (x < 0) then { y := x } else { y := 0-x } ; return y } z := AbsVal(10) Ben Hardekopf () CS 290C Program Analysis Fall 2011 4 / 71 Terminology There is a lot of confusion surrounding typing and its terminology. People often use the terms incorrectly or inconsistently, which can make the debates about typing very frustrating. Here we’ll lay out a number ofdebates about typing very frustrating....
View Full Document

## This note was uploaded on 12/27/2011 for the course CMPSC 290a taught by Professor Vandam during the Fall '09 term at UCSB.

### Page1 / 129

09 Type-based Analysis - Section Outline Type and...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online