Unformatted text preview:

Multidimensional Arrays as Parameters z In C C void fun int matrix 10 int main int mat 5 10 fun mat 1 Multidimensional Arrays as Parameters z In Ada type MTYPE is array INTEGER range INTEGER range of FLOAT MAT MTYPE 1 100 1 20 function FOO M in MTYPE return FLOAT is for ROW in M range 1 loop 2 Implementation of Subprograms z Activation record local variables parameters return value dynamic link static link return address 3 CSC 4101 Programming Languages 1 FORTRAN Activation Record z Allocated statically z Needs only local variables parameters return address 4 Static and Dynamic Links z Static Link activation record of enclosing scope needed to access non local variables z Dynamic Link activation record of caller needed to pop the activation record needed for finding exception handler 5 Displays Alternative old implementation for accessing static information z Instead of static link z Maintained outside stack z Contains pointers to activation records of all active nesting levels z Old values are spilled onto stack z No traversal of static links z 6 CSC 4101 Programming Languages 2 Implementation of Functional Languages z Activation record must be on heap if function returns a local function if a function escapes its scope z Optimized implementations on heap if absolutely necessary in registers if possible otherwise on stack z Garbage collection 7 Implementation on RISC Processors Activation record in registers On SPARC 6 parameters in registers z On MIPS 4 parameters in registers z If registers are exhausted spill an old activation record onto stack z On SPARC 8 register windows spilling needed after 8 calls z Inefficient for recursion z z 8 Exception Handling Alternative mechanism for returning from function z In C z int main try foo 42 catch int x int foo int i throw int throw 17 CSC 4101 Programming Languages 9 3 Exception Handling in Java class Ex extends Exception void Main String args try foo 42 catch Ex e finally int foo int i throws Ex if somethingTerribleHappens throw new Ex 10 Exception Handling Handler searched for along call chain Jumps out across multiple functions z May require destructor calls in intermediate scopes z Conceptually z z Return address is continuation param Exception is error continuation Continuation is function to compute the rest of the program CSC 4101 Programming Languages 11 4


View Full Document

LSU CSC 4101 - Multidimensional Arrays

Loading Unlocking...
Login

Join to view Multidimensional Arrays and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Multidimensional Arrays and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?