Executing a Program

11/9/98


Click here to start


Table of Contents

Executing a Program

Executing a Function

Parts of a Function Definition

Function Calls

Executing a Function Call

Executing a Function

1a. Evaluate Arguments

1b. Make Boxes for Parameters

1c. Copy argument values to corresponding parameters

2b. (skip 2a, return type void) Make boxes for local variables

3. Execute the statements in the body of the function

3. Execute the statements in the body of the function

3. Execute the statements in the body of the function

4. Cleanup - eliminate boxes for local variables, parameters

5. Go back to where the call was made

Functions with Return Types

A Function Returning a Value

1. Setup the parameters

2. Setup other variables

3. Execute the statements in the body of the function

3. Execute the statements in the body of the function

3. Execute the statements in the body of the function

4. Cleanup, eliminate boxes for local variables, parameters

5. Go back to where call was made, return value is in box ReturnOf...

5. Once value is used you can eliminate ReturnOf… box

Reference Parameters

A Function with Reference Parameters

1. Setup the parameters

Reference Parameters

3. (Nothing happens in Step 2) Execute the body of the function

3. Execute the body of the function

3. Execute the body of the function

4. Cleanup, eliminate boxes for local variables, parameters

5. Go back to where call was made

Author: Rich Maclin

Email: rmaclin@d.umn.edu

Home Page: http://www.d.umn.edu/~rmaclin/

Download presentation source