logo资料库

Inside_the_C++_Object_Model.pdf

第1页 / 共228页
第2页 / 共228页
第3页 / 共228页
第4页 / 共228页
第5页 / 共228页
第6页 / 共228页
第7页 / 共228页
第8页 / 共228页
资料共228页,剩余部分请下载后查看
[Trial version] Main Page
[Trial version] Table of content
[Trial version] Copyright
[Trial version] Preface
[Trial version] What Is the C++ Object Model?
[Trial version] Organization of This Book
[Trial version] The Intended Audience
[Trial version] A Note on Program Examples and Program Execution
[Trial version] Acknowledgments
[Trial version] References
[Trial version] Chapter 1. Object Lessons
[Trial version] Layout Costs for Adding Encapsulation
[Trial version] 1.1 The C++ Object Model
[Trial version] 1.2 A Keyword Distinction
[Trial version] 1.3 An Object Distinction
[Trial version] Chapter 2. The Semantics of Constructors
[Trial version] 2.1 Default Constructor Construction
[Trial version] 2.2 Copy Constructor Construction
[Trial version] 2.3 Program Transformation Semantics
[Trial version] 2.4 Member Initialization List
[Trial version] Chapter 3. The Semantics of Data
[Trial version] 3.1 The Binding of a Data Member
[Trial version] 3.2 Data Member Layout
[Trial version] 3.3 Access of a Data Member
[Trial version] 3.4 Inheritance and the Data Member
[Trial version] 3.5 Object Member Efficiency
[Trial version] 3.6 Pointer to Data Members
[Trial version] Chapter 4. The Semantics of Function
[Trial version] 4.1 Varieties of Member Invocation
[Trial version] 4.2 Virtual Member Functions
[Trial version] 4.3 Function Efficiency
[Trial version] 4.4 Pointer-to-Member Functions
[Trial version] 4.5 Inline Functions
[Trial version] Chapter 5. Semantics of Construction, Destruction, and Copy
[Trial version] Presence of a Pure Virtual Destructor
[Trial version] Presence of a Virtual Specification
[Trial version] Presence of const within a Virtual Specification
[Trial version] A Reconsidered Class Declaration
[Trial version] 5.1 Object Construction without Inheritance
[Trial version] 5.2 Object Construction under Inheritance
[Trial version] 5.3 Object Copy Semantics
[Trial version] 5.4 Object Efficiency
[Trial version] 5.5 Semantics of Destruction
[Trial version] Chapter 6. Runtime Semantics
[Trial version] 6.1 Object Construction and Destruction
[Trial version] 6.2 Operators new and delete
[Trial version] 6.3 Temporary Objects
[Trial version] Chapter 7. On the Cusp of the Object Model
[Trial version] 7.1 Templates
[Trial version] 7.2 Exception Handling
[Trial version] 7.3 Runtime Type Identification
[Trial version] 7.4 Efficient, but Inflexible?
###E###
###E###
###E###
###E###
###E###
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html 1 2 3 4 5 6 7 8 9 10-MA-0099989796 Dedication for Beth who suffered with forbearance the widowhood of an author's wife and nonetheless provided wildly unreasonable support for Danny & Anna who suffered with far less forbearance but no less love Ru-Brd Page 6
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html Ru-Brd Preface For nearly a decade within Bell Laboratories, I labored at implementing C++. First it was on cfront, Bjarne Stroustrup's original C++ implementation (from Release 1.1 back in 1986 through Release 3.0, made available in September 1991). Then it was on what became known internally as the Simplifier, the C++ Object Model component of the Foundation project. It was during the Simplifier's design period that I conceived of and began working on this book. What was the Foundation project? Under Bjarne's leadership, a small group of us within Bell Laboratories was exploring solutions to the problems of large-scale programming using C++. The Foundation was an effort to define a new development model for the construction of large systems (again, using C++ only; we weren't providing a multilingual solution). It was an exciting project, both for the work we were doing and for the people doing the work: Bjarne, Andy Koenig, Rob Murray, Martin Carroll, Judy Ward, Steve Buroff, Peter Juhl, and myself. Barbara Moo was supervising the gang of us other than Bjarne and Andy. Barbara used to say that managing a software group was like herding a pride of cats. We thought of the Foundation as a kernel upon which others would layer an actual development environment for users, tailoring it to a UNIX or Smalltalk model as desired. Internally, we called it Grail, as in the quest for, etc. (It seems a Bell Laboratories tradition to mock one's most serious intentions.) Grail provided for a persistent, semantic-based representation of the program using an object-oriented hierarchy Rob Murray developed and named ALF. Within Grail, the traditional compiler was factored into separate executables. The parser built up the ALF representation. Each of the other components (type checking, simplification, and code generation) and any tools, such as a browser, operated on (and possibly augmented) a centrally stored ALF representation of the program. The Simplifier is the part of the compiler between type checking and code generation. (Bjarne came up with the name Simplifier; it is a phase of the original cfront implementation.) What does a Simplifier do between type checking and code generation? It transforms the internal program representation. There are three general flavors of transformations required by any object model component: 1. 2. 3. Implementation-dependent transformations. These are implementation-specific aspects and vary across compilers. Under ALF, they involved the transformations of what we called "tentative" nodes. For example, when the parser sees the expression fct(); it doesn't know if this is (a) an invocation of a function represented or pointed to by fct or (b) the application of an overloaded call operator on a class object fct. By default, the expression is represented as a function call. The Simplifier rewrites and replaces the call subtree when case (b) applies. Language semantics transformations. These include constructor/destructor synthesis and augmentation, memberwise initialization and memberwise copy support, and the insertion within program code of conversion operators, temporaries, and constructor/destructor calls. 4. Code and object model transformations. These include support for virtual functions, virtual base classes and inheritance in general, operators new and delete, arrays of class objects, local static class instances, and the static initialization of global objects with nonconstant expressions. An implementation goal I aimed for in the Simplifier was to provide an Object Page 7
ABC Amber CHM Converter Trial version, http://www.processtext.com/abcchm.html Model hierarchy in which the object implementation was a virtual interface supporting multiple object models. These last two categories of transformations form the basis of this book. Does this mean this book is written for compiler writers? No, absolutely not. It is written by a (former) compiler writer (that's me) for intermediate to advanced C++ programmers (ideally, that's you). The assumption behind this book is that the programmer, by understanding the underlying C++ Object Model, can write programs that are both less error prone and more efficient. Ru-Brd Page 8
分享到:
收藏