| 引用本文: | 武成岗,张兆庆,乔如良,冯晓兵,高琳,石学林,蒋弘山,崔慧敏.代码翻译中PERFORM和GOTO语句复合结构的变换.软件学报,2004,15(4):475-486 |
| |
|
| 本文已被:浏览 5468次 下载 6603次 |
 码上扫一扫! |
|
|
| 代码翻译中PERFORM和GOTO语句复合结构的变换 |
|
武成岗1, 张兆庆1, 乔如良1, 冯晓兵1, 高琳1, 石学林1, 蒋弘山2, 崔慧敏2
|
|
1.中国科学院,计算技术研究所,北京,100080;2.清华大学,计算机科学与技术系,北京,100084
|
|
| 摘要: |
| 传统语言COBOL从诞生至今已有近50年历史,现存约有1 000亿行代码是用COBOL编写的.维护这些遗产代码的一个有效方法是将其翻译成现代语言,例如Java.其中将COBOL语言中GOTO和PERFORM语句及其复合控制结构消除是翻译过程中的一个关键步骤.提出一种利用switch,while语句来消除GOTO和PERFORM复合控制结构的方法,实现了程序的等价变换.该方法不改变程序的控制结构,保持其可读性,并将代码膨胀率控制到2倍左右.该方法已在所开发的"C2J翻译系统"中进行应用,通过了400万行实际商用程序的测试,结果证明,该方法是正确、有效的. |
| 关键词: 遗产代码 COBOL JAVA 翻译 PERFORM GOTO 控制流 |
| DOI: |
| 分类号: |
| 基金项目:Supported by the National Natural Science Foundation of China under Grant No.60103006 (国家自然科学基金) |
|
| Converting the Compound Control Structure of PERFORM and GOTO Statements in Code Translation |
|
WU Cheng-Gang,ZHANG Zhao-Qing,QIAO Ru-Liang,FENG Xiao-Bing,GAO Lin,SHI Xue-Lin,JIANG Hong-Shan,CUI Hui-Min
|
| Abstract: |
| COBOL, a traditional language, has been presented for more than 50 years. There are at least 100 billion lines of legacy codes written in COBOL up to now. An effective way to maintain these legacy codes is to translate them into modern languages, such as Java. While translating, it is a key-step to eliminate ‘OTO’and‘ERFORM’and their compound control structures in COBOL programs. A method which uses ‘witch’and ‘hile’statements is proposed in this paper instead of ‘OTO’and ‘ERFORM’and their compound control structures. It preserves the readability because the target Java program has the similar control structures. The code size of the target program expands only 2 times in average. This method is applied in the ‘C2J translation system’ It is proved sound and effective since 4 million lines of real COBOL program have been translated and its target program has passed the test. |
| Key words: legacy code COBOL JAVA translation PERFORM GOTO control-flow |