Pseudo An algorithm design language Overview - Concise Pythonic - - PowerPoint PPT Presentation

pseudo
SMART_READER_LITE
LIVE PREVIEW

Pseudo An algorithm design language Overview - Concise Pythonic - - PowerPoint PPT Presentation

Pseudo An algorithm design language Overview - Concise Pythonic syntax - Rich list support - Robust type inference - On-demand objects Compiler Architecture Type Inference Modules L1 Inference Scanner Parser L2 Inference Codegen


slide-1
SLIDE 1

Pseudo

An algorithm design language

slide-2
SLIDE 2

Overview

  • Concise Pythonic syntax
  • Rich list support
  • Robust type inference
  • On-demand objects
slide-3
SLIDE 3

Compiler Architecture

Type Inference Modules

L1 Inference L2 Inference

Scanner Parser Codegen

Preprocessor

slide-4
SLIDE 4

Syntax

slide-5
SLIDE 5

Syntax

slide-6
SLIDE 6

Syntax

slide-7
SLIDE 7

Lists

  • Variable-sized collections of data
  • Supports primitive types and objects
  • Backed by LLVM arrays
  • Rich built-in functions
  • get(), set(), length(), insert(), remove(), push(),

pop(), enqueue(), dequeue()

slide-8
SLIDE 8

Lists

slide-9
SLIDE 9

Type Inference (L1)

  • Primitives: num,bool,string
  • Infer the types of variables based on

their usage (Hindley-Milner)

  • Doubles as a semantic checker
slide-10
SLIDE 10

Type Inference (L1)

slide-11
SLIDE 11

Objects

  • Containers of arbitrary data
  • Backed by LLVM structs
  • Flexible and on-demand
slide-12
SLIDE 12

Objects

Users never explicitly define

  • r create objects!
slide-13
SLIDE 13

Object Inference (L2)

  • Novel object inference algorithm
  • We determine at compile-time:
  • Whether each variable is an object, and if so:
  • Its object type (an integer id)
  • The set of fields in the object type
  • The types of those fields
slide-14
SLIDE 14

Object Inference Algorithm

  • 1. Collect fields for each object variable
  • 2. Collect equalities for object variables
  • 3. Unify object variables to obtain object types
  • 4. Annotate SAST with object type ids
  • 5. Pass to codegen the object types
slide-15
SLIDE 15

Object Inference Algorithm

Coercive Object Equality Scheme

  • Two objects are of the same type if they

are used in a manner that would require them to be the same type

  • Examples: assignment, in a list with other
  • bjects, arguments to a function
slide-16
SLIDE 16

Object Inference Algorithm

Coercive Object Equality Scheme

slide-17
SLIDE 17

Object Initialization

  • The first field assignment

determines the scope of an

  • bject
  • Other fields are automatically

initialized to default values

  • init keyword can also be

used to initialize objects in a scope

slide-18
SLIDE 18

Object Printing

  • Our built-in print function also supports
  • bjects!
slide-19
SLIDE 19

Key Accomplishments

  • Lists
  • Types supported: num, bool, string, Object
  • Rich built-in function support
  • Objects
  • Novel object inference algorithm
  • Object field types supported: num, bool, string,

Object (1 level), List

  • High Dimension Type Inference
  • (All primitives) × (Lists) × (Objects)
slide-20
SLIDE 20

Demo

slide-21
SLIDE 21

Pseudo

An algorithm design language