IBM AS/400 manual The Call Stack, Program/Procedure Call Overview, The call stack

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 153
Image 153
The Call Stack

Program/Procedure Call Overview

ples of using procedure pointers, see the section on the procedure type ILEin RPG for AS/400 Reference.

You use the CALLP or

both

the

CALLB

and

PARM

operations

to

make a

pro

call. You can also call a prototyped procedure

with

an expression

i

returns a value. If

you

use

the

CALLB

and

PARM

operations,

then

the

cannot perform type checking on the parameters,

which

may

result

in

r

errors.

 

 

 

 

 

 

 

 

 

 

 

The Call Stack

The call stack

is

a list

of

call

stack

entries,

in

a last-incall-first-out

(L

stack

entry

is

a call to a program

or

procedure.

There is one call s

When

an

ILE

program is

called,

the

program entry

procedure

is

first

call stack. The system then automatically performs

a procedure

call,

ciated

user's

procedure

(the

main

procedure)

is

added.

When

a

pr

only the user's procedure (a main procedure or subprocedure) is ad overhead of a program entry procedure.

Figure 58 shows a call stack

for

an application

consisting

of

an

OPM

pro

which calls

an

ILE

program.

The RPG

main

procedure

of

the

ILE

progra

RPG

subprocedure, which in

turn calls a C procedure. Note

that

in

t

this

book,

the

most

recent

entry

is

at

the

bottom

of

the

stack.

 

The call stack OPM

Program A

stack ILE

Manual backgroundRPG ModuleManual background

Program

Entry Proc.

Main

Procedure

Sub-

Procedure

Manual background C Module

Procedure

CALL STACK

Manual background OPM

Manual background ILEManual backgroundManual background

PEP

Manual background ILEManual backgroundManual background

Procedure

Manual background ILEManual backgroundManual background

Procedure

Manual background ILEManual backgroundManual background

Procedure

Program Call

Procedure Call (by system)

Procedure Call

Procedure Call

Figure

58. Program and Procedure Calls on the Call Stack

 

 

Note:

In a

program call, the calls to the program entry procedure an

 

entry

procedure (UEP) occur together, since the call to the U

 

matic.

Therefore, from now on, the two steps of

a program

call

 

bined

in later diagrams involving the call stack in

this and

rema

chapters.

Chapter 10. Calling Programs and Procedures129

Page 153
Image 153
IBM AS/400 manual The Call Stack, Program/Procedure Call Overview, The call stack