ILE C/C++ Programmer's Guide


Source for Sample EVAL Commands for Displaying C++ Constructs



The sample EVAL command for displaying C++ constructs presented in Figure 77 is based on the source shown in the following figure:

Figure 82. Source for Sample EVAL Commands for Displaying C++ Constructs


   // Program demonstrates the EVAL debug command
     class A {
       public:
          union {
            int a;
            int ua;
          };
       int ac;
       int amb;
       int not_amb;
       };
 
     class B {
       public:
          int b;
     };
 
     class C {
       public:
          int ac;
          static int c;
          int amb;
          int not_amb;
     };
 
     int C::c = 45;
     template <class T> class E : public A, public virtual B {
       public:
          T e;
    };
 
    class D : public C, public virtual B {
       public:
          int d;
    };
 
    class outter {
       public:
          static int static_i;
          class F : public E<int>, public D {
             public:
                int f;
                int not_amb;
                void funct();
           } inobj;
     };
 
 
     int outter :: static_i = 45;
 
     int VAR = 2;
 
     void outter::F::funct()
     {
         int local;
         a=1;              //EVAL VAR  : Is VAR in global scope
         b=2;
         c=3;
         d=4;
         e=5;
         f=6;
 
         local = 828;
         int VAR;
 
         VAR=1;
         static_i=10;
         A::ac=12;
         C::ac=13;
         not_amb=32;
 
         not_amb=13;
         // Stop here and show:
         // EVAL VAR          : is VAR in local scope
         // EVAL ::VAR        : is VAR in global scope
         // EVAL %LOCALVARS   : see all local vars
         // EVAL *this        : fields of derived class
         // EVAL this->f      : show member f
         // EVAL f            : in derived class
         // EVAL a            : in base class
         // EVAL b            : in Virtual Base class
         // EVAL c            : static member
         // EVAL static_i     : static var made visible
                                                : by middle-end
         // EVAL au           : anonymous union members
         // EVAL a=49         :
         // EVAL au
         // EVAL ac           : show ambigous var
         // EVAL A::ac        : disambig with scope op
         // EVAL B::ac        : Scope op
         // EVAL E<int>::ac   : Scope op
         // EVAL this         : notice pointer values
         // EVAL (E<int>*)this      : change
         // EVAL (class D *)this    : class is optional
         // EVAL *(E<int> *)this    : show fields
         // EVAL *(D *) this       : show fields
     }
 
     int main()
     {
        outter obj;
        int outter::F::*mptr = &outter::F::b;
        int i;
        int& r = i;
        obj.inobj.funct();
        i = 777;
 
        obj.static_i = 2;
        // Stop here
        // EVAL obj.inobj.*mptr  : member ptr
        // EVAL obj.inobj.b
        // EVAL i
        // EVAL r
        // EVAL r=1
        // EVAL i
        // EVAL (A &) (obj.inobj)  : reference cast
        // EVAL
     }


[ Top of Page | Previous Page | Next Page | Table of Contents ]