Annotation of parser3/src/include/pa_vobject.h, revision 1.16

1.1       paf         1: /*
1.16    ! paf         2:   $Id: pa_vobject.h,v 1.15 2001/03/09 04:47:27 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef PA_VOBJECT_H
                      6: #define PA_VOBJECT_H
                      7: 
1.7       paf         8: #include "pa_valiased.h"
1.1       paf         9: #include "pa_vjunction.h"
1.15      paf        10: #include "pa_vclass.h"
1.4       paf        11: 
1.7       paf        12: class Temp_class_alias;
                     13: 
                     14: class VObject : public VAliased {
                     15:        friend Temp_class_alias;
1.1       paf        16: public: // Value
                     17:        
                     18:        // all: for error reporting after fail(), etc
1.8       paf        19:        const char *type() const { return "object"; }
1.11      paf        20: 
1.4       paf        21:        // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref
1.10      paf        22:        Value *get_element(const String& name) {
1.4       paf        23:                // $CLASS=my class
                     24:                if(name==CLASS_NAME)
1.11      paf        25:                        return fclass_alias;
1.6       paf        26:                // $BASE=my parent
                     27:                if(name==BASE_NAME)
1.11      paf        28:                        return fclass_alias->base();
1.7       paf        29:                // $method=junction(self+class+method)
1.11      paf        30:                if(Junction *junction=fclass_real.get_junction(*this, name))
1.9       paf        31:                        return NEW VJunction(*junction);;
1.11      paf        32:                // $field=ffields.field
                     33:                return static_cast<Value *>(ffields.get(name));
1.1       paf        34:        }
                     35: 
                     36:        // object_instance: (field)=value
                     37:        void put_element(const String& name, Value *value) {
                     38:                // speed1:
1.4       paf        39:                //   will not check for '$CLASS(subst)' trick
1.1       paf        40:                //   will hope that user ain't THAT self-hating person
                     41:                // speed2:
                     42:                //   will not check for '$method_name(subst)' trick
                     43:                //   -same-
                     44: 
1.11      paf        45:                ffields.put(name, value);
1.1       paf        46:        }
                     47: 
                     48:        // object_class, object_instance: object_class
1.11      paf        49:        VClass *get_class() { return &fclass_real; }
1.1       paf        50: 
                     51: public: // creation
                     52: 
1.16    ! paf        53:        VObject(Pool& apool, VClass& aclass_real) : VAliased(apool, aclass_real), 
1.11      paf        54:                fclass_real(aclass_real),
1.16    ! paf        55:                ffields(apool) {
1.1       paf        56:        }
                     57: 
                     58: private:
                     59: 
1.11      paf        60:        VClass& fclass_real;
1.14      paf        61:        Hash ffields;
1.1       paf        62: };
                     63: 
                     64: #endif

E-mail: