1/24
文档分类:资格/认证考试

Implementing Subprograms.ppt


下载后只包含 1 个 PPT 格式的文档,里面的视频和音频不保证可以播放,查看文件列表

特别说明:文档预览什么样,下载就是什么样。

0/100
您的浏览器不支持进度条
下载所得到的文件列表
Implementing Subprograms.ppt
文档介绍:
ImplementingSubprogramsInText:essingnonlocals(staticscoping)essingnonlocalswithdynamicscopingChapter9:ImplementingSubprogramsImplementingSubprogramsThesubprogramcallandreturnoperationsofalanguagearetogethercalleditssubprogramlinkageFirst,let’slookatimplementingFORTRAN77subprogramsChapter9:ImplementingSubprogramsImplementingFORTRAN77SubprogsCallSemantics:SavetheexecutionstatusofthecallerCarryouttheparameter-passingprocessPassthereturnaddressTransfercontroltothecalleeReturnSemantics:Ifpass-by-value-resultisused,movecurrentvaluesofparameterstotheircorrespondingactualsIfitisafunction,movereturnvaluetoaplacethecallercangetitRestoretheexecutionstatusofthecallerTransfercontrolbacktothecallerRequiredStorage:Statusinformationofthecaller,parameters,returnaddress,andfunctionalvalue(ifitisafunction)Chapter9:ImplementingSubprogramsFORTRANActivationInfocanallocateallmemorystaticallymain... f(...)...procf(...)... g(...)...procg()... g(...)--!!!monMainfg}}Chapter9:ImplementingSubprogramsActivationRecordsTheformat,orlayout,ofthenoncodepartofanexecutingsubprogramiscalledanactivationrecord(AR)Anactivationrecordinstance(ARI)isaconcreteexampleofanactivationrecord(thecollectionofdataforaparticularsubprogramactivation)FORTRAN77subprogramscanhavenomorethanoneactivationrecordinstanceatanygiventimeThecodeofalloftheprogramunitsofaFORTRAN77programmayresidetogetherinmemory,withthedataforallunitsstoredtogetherelsewhereThealternativeistostorealllocalsubprogramdatawiththesubprogramcodeChapter9:ImplementingSubprogramsImplementingSubprogramsinALGOL-plicatedthanFORTRAN77:ParametersareoftenpassedbytwomethodsLocalvariablesareoftendynamicallyallocatedRecursionmustbesupportedStaticscopingmustbesupportedChapter9:ImplementingSubprogramsActivationRecordStructureAtypicalactivationrecordforanALGOL-likelanguage:LocalvariablesParametersDynamiclinkStaticlinkstacktopReturnaddressChapter9:ImplementingSubprogramsActivationRecordDetailsTheactivationrecordformatisstatic,butitssizemaybedynamicThestaticlinkpoint 内容来自淘豆网www.taodocs.com转载请标明出处.