Lecture 20 Types Offsets Revisited - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Lecture 20 Types Offsets Revisited

Description:

Review Semantics actions for function invocation. Review Semantics actions for arglist ... BYRNES, GARRETT, GREGORY, KODUR, SAXENA, TEMLYAKOV, VARGHESE, TALATAM. 4 ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 18
Provided by: mantonm5
Learn more at: http://www.cse.sc.edu
Category:

less

Transcript and Presenter's Notes

Title: Lecture 20 Types Offsets Revisited


1
Lecture 20 Types / Offsets Revisited
CSCE 531 Compiler Construction
  • Topics
  • Procedural Abstraction
  • Activation records
  • Readings 8.2

March 29, 2006
2
Overview
  • Last Time
  • Review Semantics actions for function invocation
  • Review Semantics actions for arglist
  • Attribute placeList list of identifiers
  • Handling Function Definitions
  • Todays Lecture
  • Final reductions of statement lists in
    programs/functions/procedures
  • Passing Parameters
  • Array.c
  • Nested Scope
  • Nested.c
  • References Section 8.2
  • Homework

3
Test 2 - TIME CHANGE !!!!!
  • Test 2 - TIME CHANGE !!!!!
  • Wednesday April 5 700PM
  • First Robotics Volunteers Friday March 31,
    500-700PM
  • Graduate Assistants - I need to see after class!
  • AARONS,
  • AL-ABRI,
  • BYRNES,
  • GARRETT,
  • GREGORY,
  • KODUR,
  • SAXENA,
  • TEMLYAKOV,
  • VARGHESE,
  • TALATAM

4
Some Email Questions
  • How do we handle running out of pace in quad
    arrays? Again with corrections
  • When an if-then statement is last statement in
    program (or function) how do we backpatch?

5
Question on size of code arrays
  • What happens when you run out of space?
  • Nextquad gt arraySize

void gen(int op) static int opcodeNULL
static int arraySize 0 static int nextquad
0 if (nextquad gt arraySize)
arraySize ARRAY_INCREMENT opcode (int
) realloc(opcode, arraySize)
opcodenextquad op
Need to be a globals Why?
6
Final reductions of statement lists
7
Precedence of Operators
  • Dear Dr. Matthews
  • About the operator precedence, if I have
  • a b c,
  • What will be the order?
  • Is that first evaluate bc then a
  • (bc) or first a b then (ab) c?
  • Best

8
C type booleans Not for Project 4!!!
  • The grammar for handling the logical operator
    not
  • Is B ? NOT B
  • Not B ? '!' E , which would be fine in C
  • /CODE FOR THE ('not' B)
    EXPRESSION/

9
Parameter Passing
  • Call by value
  • Call by reference
  • Copy-restore
  • Call by name
  • Logically the procedure is treated as a macro
    with the arguments substituted for the formal
    parameters
  • Actually code passed for evaluating the argument
    is passed to the functions

10
(No Transcript)
11
Declarations within Functions/Procedures
  • Figure 8.11 differences in approaches
  • P ? offset 0 D // place code instead
    of marker
  • D ? D D
  • D ? ID T enter(id.place, T.type,
    offset)
  • offset offset T.width

12
Types within the Declarations
  • T ? integer T.type INTEGER T.width 4
  • double T.type double T.width 8
  • array num of T1
  • T.type array(num.val, T1.type)
  • T.width num.val T1.width
  • T1 T.type pointer(T1.type)
  • T.width 4

13
Representing Type Information
  • Type tree
  • Nodes
  • Leaves Base types int, float
  • Interior Nodes Type Constructors
  • Array (size, dimensions, type)
  • or maybe array of array for 2 dimensions
  • Pointer ( targetType)
  • FuncReturning
  • Record ( componentTypeList )

14
Type Example
15
Type Encoding
  • Base types
  • boolean 0000
  • char 0001
  • int 0010
  • double 0011
  • Type constructor encodings -
  • pointer 01
  • array 10
  • freturns 11
  • Why encode at all?

16
Handling Records
17
Structural and Name Equivalence of Types
  • Two identifiers are name equivalent if the types
    have the same name.
  • Two identifiers are structurally equivalent if
    the types have the same structure (type tree).
Write a Comment
User Comments (0)
About PowerShow.com