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

1.1     ! paf         1: /*
        !             2:   $Id: pa_vclass.h,v 1.10 2001/02/24 11:20:32 paf Exp $
        !             3: */
        !             4: 
        !             5: #ifndef PA_VOBJECT_H
        !             6: #define PA_VOBJECT_H
        !             7: 
        !             8: #include "pa_value.h"
        !             9: #include "pa_vjunction.h"
        !            10: 
        !            11: class VObject : public Value {
        !            12: public: // Value
        !            13:        
        !            14:        // all: for error reporting after fail(), etc
        !            15:        const char *type() const { return "Object"; }
        !            16: 
        !            17:        // object_instance: (field)=value;(STATIC)=hash;(method)=method_ref
        !            18:        Value *get_element(const String& name) {
        !            19:                // $STATIC=STATIC hash
        !            20:                if(name==STATIC_NAME)
        !            21:                        return &vclass.STATIC;
        !            22: 
        !            23:                // $method=junction(this+method)
        !            24:                if(Method *method=static_cast<Method *>(vclass.methods.get(name))) {
        !            25:                        Junction& j=*NEW Junction(pool(), 
        !            26:                                *this,
        !            27:                                method,0,0,0,0);
        !            28: 
        !            29:                        return NEW VJunction(j);
        !            30:                }
        !            31: 
        !            32:                // $field=fields.field
        !            33:                return static_cast<Value *>(fields.get(name));
        !            34:        }
        !            35: 
        !            36:        // object_instance: (field)=value
        !            37:        void put_element(const String& name, Value *value) {
        !            38:                // speed1:
        !            39:                //   will not check for '$STATIC(subst)' trick
        !            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: 
        !            45:                fields.put(name, value);
        !            46:        }
        !            47: 
        !            48:        // object_class, object_instance: object_class
        !            49:        VClass *get_class() { return &vclass; }
        !            50: 
        !            51: public: // creation
        !            52: 
        !            53:        VObject(Pool& apool, VClass& vclass) : 
        !            54:                Value(apool), 
        !            55:                vclass(vclass),
        !            56:                fields(apool) {
        !            57:        }
        !            58: 
        !            59: private:
        !            60: 
        !            61:        VClass& vclass;
        !            62:        Hash fields;
        !            63: };
        !            64: 
        !            65: #endif

E-mail: