Ch. 6 - 8 Ch. 6 - 81 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
Chapter 9 Subprograms Specification: name, signature, actions Signature: number and types of input arguments, number and types of output results –Book.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Implementing Subprograms
(1) ICS 313: Programming Language Theory Chapter 10: Implementing Subprograms.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
ISBN Chapter 10 Implementing Subprograms.
1 Storage Registers vs. memory Access to registers is much faster than access to memory Goal: store as much data as possible in registers Limitations/considerations:
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
1 Chapter 7: Runtime Environments. int * larger (int a, int b) { if (a > b) return &a; //wrong else return &b; //wrong } int * larger (int *a, int *b)
ISBN Chapter 10 Implementing Subprograms.
ISBN Chapter 10 Implementing Subprograms.
G. Levine Chapter 6 Chapter 6 Encapsulation –Why do we want encapsulation? Programmer friendliness- programmer need not know about these details –Easier.
Run time vs. Compile time
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
Chapter 9: Subprogram Control
1 CSCI 360 Survey Of Programming Languages 9 – Implementing Subprograms Spring, 2008 Doug L Hoffman, PhD.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Chapter 10 Implementing Subprograms. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Semantics of Call and Return The subprogram call and return.
ISBN Chapter 9 Subprograms and Functions –Design Issues –Local Referencing Environments –Parameter-Passing Methods –Parameters that are Subprogram.
© 2003 G. Drew Kessler and William M. Pottenger1 Subroutines (Part 1) CSE 262, Spring 2003.
ISBN Chapter 10 Implementing Subprograms.
Names and Scope. Scope Suppose that a name is used many times for different entities in text of the program, or in the course of execution. When the name.
Chapter 9 Subprograms Fundamentals of Subprograms
Chapter 10 Implementing Subprograms. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 10 Topics The General Semantics of Calls and Returns.
Copyright © 2005 Elsevier Chapter 8 :: Subroutines and Control Abstraction Programming Language Pragmatics Michael L. Scott.
1 CS Programming Languages Class 15 October 17, 2000.
Basic Semantics Associating meaning with language entities.
1 Ada Programming Language Chapter 7 Modularity And Data Abstraction In the Name of God.
1 Control Abstraction (Section ) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
Programming Languages and Paradigms Imperative Programming.
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
1 Subprograms In Text: Chapter 8. 2 Chapter 8: Subprograms Outline Definitions Referencing environments Parameter passing modes and mechanisms Independent.
ISBN Chapter 10 Implementing Subprograms.
Implementing Subprograms What actions must take place when subprograms are called and when they terminate? –calling a subprogram has several associated.
Run-Time Storage Organization Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
A.Alzubair Hassan Abdullah Dept. Computer Sciences Kassala University A.Alzubair Hassan Abdullah Dept. Computer Sciences Kassala University NESTED SUBPROGRAMS.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
1 CS Programming Languages Class 22 November 14, 2000.
Chapter 10 Implementing Subprograms. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 10 Topics The General Semantics of Calls and Returns.
10-1 Chapter 10: Implementing Subprograms The General Semantics of Calls and Returns Implementing “Simple” Subprograms Implementing Subprograms with Stack-Dynamic.
ISBN Chapter 10 Implementing Subprograms.
Implementing Subprograms
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan.
© G. Drew Kessler and William M. Pottenger1 Subroutines, Part 2 CSE 262, Spring 2003.
PZ09A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ09A - Activation records Programming Language Design.
Subprograms - implementation. Calling a subprogram  transferring control to a subprogram: save conditions in calling program pass parameters allocate.
Chapter Ten: Implementing Subprograms Lesson 10. Implementing?  Previous lesson: parameter passing  In, out, inout  By value  By reference  Passing.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
ISBN Chapter 10 Implementing Subprograms.
ISBN Chapter 10 Implementing Subprograms.
Implementing Subprograms
CSE3302 Programming Languages (notes continued)
Chapter 10 : Implementing Subprograms
Implementing Subprograms Chapter 10
Implementing Subprograms
Implementing Subprograms
Chapter 10: Implementing Subprograms Sangho Ha
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Implementing Subprograms
Subprograms In Text: Chapter 9.
Final Review In Text: Chapters 1-3, 5-16.
Languages and Compilers (SProg og Oversættere)
Presentation transcript:

Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan

Ch Ch jcmt CSE 3302 Programming Languages Block Structured Languages: Activation records Fixed program part Variable activation-record part –Instruction part –Environment part Local context Nonlocal context

Ch Ch jcmt CSE 3302 Programming Languages Nonlocal context Static link IP-EP locus of control Two coordinate access –Static distance –Offset Two step access

Ch Ch jcmt CSE 3302 Programming Languages Procedure Activation Needs static and dynamic links Three steps –Save caller state –Create callee activation record –Enter callee in context of new record Procedure Deactivation Two steps –Delete callee activation record –Restore the state of the caller

Ch Ch jcmt CSE 3302 Programming Languages Procedural Parameters Two element record –IP gives entry address of actual procedure –EP gives pointer to environment of definition of procedure Block structured languages generally only allow procedures to be passed in - not to be returned

Ch Ch jcmt CSE 3302 Programming Languages Nonlocal context Static chains as discussed –Implemented as linked lists Display –Random access to context –Array with pointers to activation records –Calls require saving display data Shallow binding –Static activation records on stack

Ch Ch jcmt CSE 3302 Programming Languages Blocks Handled like degenerate procedures Activation records very important in language implementation Two-coordinate addressing is also significant Concepts

Ch Ch jcmt CSE 3302 Programming Languages Ada Overview Rationale –Software complexity and cost –Maintenance and portability –Government backing History – Specifications –CII-Honeywell-Bull : Jean Ichbiah –Mil std and ANSI ‘83, ISO ‘87

Ch Ch jcmt CSE 3302 Programming Languages Ada Highlights Abstract Data Types –Information Hiding (D. L. Parnas) Verification Concurrency Generally uses Pascal as basis

Ch Ch jcmt CSE 3302 Programming Languages Ada Packages support info hiding and implement abstract data types –Specification of public names –Private body of package Control structures include –Exception handling –Concurrent programming

Ch Ch jcmt CSE 3302 Programming Languages Ada Declarations Object (constants and variables) Type Subprogram (procedures, functions and overloaded operators) Package (executable modules) Task (concurrently executable modules)

Ch Ch jcmt CSE 3302 Programming Languages Ada: Data Structures Based on Pascal –Range constraints –Accuracy constraints: digits, delta –Discriminant constraint –Index constraint Name equivalence –Subtype, derived type Overloaded enumerations

Ch Ch jcmt CSE 3302 Programming Languages Ada: Name structures Variables can be initialized at declaration Constants are declared with keyword and are constant within scope Separation of ‘interface’ & ‘implementation’

Ch Ch jcmt CSE 3302 Programming Languages Ada Issues “Global Variables Considered Harmful” Wulf & Shaw –Side effects –Indiscriminate access –Vulnerability –No overlapping definitions Parnas’s principles of information hiding –One must provide the intended user with all the info needed to use the module correctly and nothing more. –One must provide the implementor with all the info needed to complete the module and nothing more.

Ch Ch jcmt CSE 3302 Programming Languages Name structures (cont.) Packages –Interface specification “public” part of package May have “private” section –Body Defines everything in interface specification This is private to the package developer Use With

Ch Ch jcmt CSE 3302 Programming Languages Ada Packages ADT Library of routines Shared data structure Generic packages –ADT templates –Parameters Internal vs. External representations

Ch Ch jcmt CSE 3302 Programming Languages Ada: Control Structures Iterator - loop end loop –Infinite loop - uses ‘exit’ keyword or ‘exit when’ –‘while’ phrase prefix –‘for’ phrase prefix Conditional - if then end if Case Subprograms Goto Exception handling Concurrency control

Ch Ch jcmt CSE 3302 Programming Languages 4th Generation Languages Data abstraction languages Control structure for concurrency Refinement and correction of 3rd gen