cs160-lec13 - CMPSC 160 Translation of Programming...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPSC 160 Translation of Programming Languages Lectures 13: Procedure Abstraction, Symbol Tables
Background image of page 1

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

View Full DocumentRight Arrow Icon
The Procedure Abstraction What is a Procedure: An abstraction (illusion) provided by programming languages What does the idea of procedure provide? Control abstraction: transfer of control between caller and callee Namespace (scope): caller and callee have different namespaces External interface: passing arguments between caller and callee Why have procedures? establishes a separation of concerns (an important software engineering principle) enables modular design enables separate compilation
Background image of page 2
Why do should I care about procedures? This is a compilers class, not a programming languages class, right? A programming language has the notion of procedures The architecture (or whatever is going to run our output code) does not have any notion of a procedure, of control abstraction, or even of separate name spaces It is up to the compiler to take the input program (that has procedures) and translate it into output code that runs exactly the same (even if the underlying machine has no notion of a procedure) In essence, the compiler has to implement procedures. So, we better know what it is that we have to implement
Background image of page 3

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

View Full DocumentRight Arrow Icon
The Procedure Abstraction There are 3 major things that procedures provide Control abstraction Well defined entries and exits Mechanism to return control to caller Mapping a set of parameters (arguments) from caller’s name space to callee’s name space Name space (scope) Declare locally visible names Local names may hide identical, non-local names Local names cannot be seen outside External Interface Access is by procedure name and parameters Protection for both caller and callee
Background image of page 4
The Procedure Abstraction Procedures are the key to building large systems: Requires system-wide cooperation Broad agreement on memory layout, calling sequences Involves architecture, operating system, and compiler Establishes the need for a private context Create private storage for each procedure invocation Encapsulate information about control flow and data abstractions Provides shared access to system-wide facilities Storage management
Background image of page 5

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

View Full DocumentRight Arrow Icon
The Procedure Abstraction Procedures allow us to use separate compilation Separate compilation allows us to build non-trivial programs Keeps compile times reasonable Lets multiple programmers collaborate Without separate compilation, we would not be able to build large systems The procedure linkage convention Ensures that each procedure inherits a valid run-time environment and that it restores one for its caller Highly machine dependent Establishes division of responsibility and separation of concerns
Background image of page 6
The Procedure Abstraction Underlying hardware supports little of this abstraction Procedures create named variables – Hardware understands a linear array of memory locations (one big array)
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/19/2012 for the course ENGR 361 taught by Professor Drexel during the Spring '12 term at Bloomsburg.

Page1 / 27

cs160-lec13 - CMPSC 160 Translation of Programming...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online