首页 | 本学科首页   官方微博 | 高级检索  
     检索      

一种在静态类型面向对象语言中构造VFCG的方法
引用本文:李必信,王云峰,李宣东,郑国梁.一种在静态类型面向对象语言中构造VFCG的方法[J].南京大学学报(自然科学版),2000,36(2):163-170.
作者姓名:李必信  王云峰  李宣东  郑国梁
作者单位:[1]南京大学计算机软件新技术国家重点实验室南京大学计算机科 [2]南京大学计算机软件新技术国家重点实验室南京大学
基金项目:江苏省应用基础基金!(No :BJ970 36 )资助项目
摘    要:阐述了在静态类型面向对象语言中构造虚函数调用图(VFCG)的方法:先构造可见方法类层次图(VM-CHG),再计算继承集、改写集,确定改写边界,最后利用VM-CHG和改写边界构造VFCG。同时说明了VFCG在静态类型面向对象语言中解决虚函数调用方面的重要作用。

关 键 词:继承集  改写集  VFCG  静态类型面向对象语言

AN APPROACH FOR CONSTRUCTING VFCG IN STATICALLY-TYPED OBJECT-ORIENTED LANGUAGE
LI Bi-xin,WANG Yun-feng,LI Xuan-dong,ZHENG Guo-liang.AN APPROACH FOR CONSTRUCTING VFCG IN STATICALLY-TYPED OBJECT-ORIENTED LANGUAGE[J].Journal of Nanjing University: Nat Sci Ed,2000,36(2):163-170.
Authors:LI Bi-xin  WANG Yun-feng  LI Xuan-dong  ZHENG Guo-liang
Abstract:A major advantage of object oriented languages is abstraction. The most important language feature that supports abstraction is the dynamic dispatch of methods based on the run time type of an object. In dynamically typed language like Smalltalk and SELF, all dispatches are considered dynamic, and eliminating these dynamic dispatches that has been essential to obtain high performance. In statically typed language, such as C , virtual function call is a both important and complicated problem, and programmers must explicitly request dynamic dispatch by declaring a method to be virtual. Virtual functions make code easier for programmers to reuse. But virtual function call makes it harder to analyze or understand C programs. We think there are at least 3 reasons: first, C programs suffer less of an initial performance penalty, at the cost of reduced flexibility and increased programmer effort in the presence of virtual function call. Second, if every potential target of a virtual function call is included in the call graph, the user will face with a vastly larger space of object types and functions that must be comprehended to understand the meaning of the program as a whole. Third, because of the existence of inheritance relationship (especially multiple inheritance relationship), all classes in a program form a complicated class hierarchy structure. We represent such structure with class hierarchy graph (CHG). Methods defined in some class can be either visible or invisible in its corresponding class node in CHG. We use visible method class hierarchy graph (VM CHG) to represent such CHG. Some child classes inherit their parent class' method; others override their parent class' method. We use inherit set to represent the set of classes that inherit their parent class' method, and override set to represent the set of classes that override their parent class' method. If some class has many base (or parent) classes and these base classes have only one super base class, it is hard to determine the inherited method by the derived class belongs to which base class or which version of super base class. In this paper, we present an approach for constructing VFCG in statically typed object oriented language so as to understand virtual function call easily. First,VM CHG is constructed to represent class hierarchy relationship between objects where method defined or inherited is visible. Then, inherit set (which represents the union of the set of classes that inherit a particular class' method m and the particular class that defines the method m) and override set(representing the set of classes that override a particular class' method)are computed, and override frontier is also determined by having computed inherit set and override set. Finally, VFCG is constructed with VM CHG and override frontier. On the other hand, we present all algorithms for constructing VM CHG, computing inherit set and override set, determining override frontier, and creating VFCG. Meantime, we discuss the importance of VFCG in resolving static object oriented virtual function call.
Keywords:VM  CHG  inherit set  override set  override frontier  VFCG
本文献已被 维普 万方数据 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号