xref: /csrg-svn/usr.bin/pascal/pdx/test/fproc.p (revision 62156)
148079Sbostic(*
2*62156Sbostic * Copyright (c) 1980, 1993
3*62156Sbostic *	The Regents of the University of California.  All rights reserved.
448079Sbostic *
548079Sbostic * %sccs.include.redist.c%
648079Sbostic *
7*62156Sbostic *	@(#)fproc.p	8.1 (Berkeley) 06/06/93
848079Sbostic *)
948079Sbostic
1048079Sbosticprogram fproc(output);
1148079Sbostic    var
1248079Sbostic    i :integer;
1348079Sbostic
1448079Sbostic    procedure print(function frtn :integer);
1548079Sbostic	begin
1648079Sbostic	    write(frtn:3,'   formal routine =');
1748079Sbostic	end;
1848079Sbostic
1948079Sbostic    procedure lvl1(function form: integer);
2048079Sbostic	label	1;
2148079Sbostic	var
2248079Sbostic	loc :integer;
2348079Sbostic
2448079Sbostic	function eval :integer;
2548079Sbostic	    begin
2648079Sbostic		if loc = 8 then begin
2748079Sbostic			writeln(' non-local jump');
2848079Sbostic			goto 1;
2948079Sbostic		end;
3048079Sbostic		eval := loc;
3148079Sbostic	    end;
3248079Sbostic
3348079Sbostic    begin
3448079Sbostic	loc := i;
3548079Sbostic	i := i - 1;
3648079Sbostic	if (loc = 4) or (loc = 8) then
3748079Sbostic		lvl1(eval)
3848079Sbostic	else if loc > 0 then
3948079Sbostic		lvl1(form);
4048079Sbostic1:	write('Stack frame:',loc:3,'   formal print =');
4148079Sbostic	print(form);
4248079Sbostic	writeln(form:3);
4348079Sbostic    end;
4448079Sbostic
4548079Sbostic    function geval :integer;
4648079Sbostic	begin
4748079Sbostic	    geval := i;
4848079Sbostic	end;
4948079Sbostic
5048079Sbostic    begin
5148079Sbostic	writeln('This should print levels 0-3, with formal values of 4.');
5248079Sbostic	writeln('Level 4 should jump to level 8.');
5348079Sbostic	writeln('Finally levels 8-10 should print with formal values of -1.');
5448079Sbostic	i := 10;
5548079Sbostic	lvl1(geval);
5648079Sbostic    end.
57