Annotation of parser3/src/types/pa_vclass.h, revision 1.13

1.13    ! paf         1: /**    @file
        !             2:        Parser: class parser class decl.
        !             3: 
1.1       paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.13    ! paf         5: 
1.2       paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1       paf         7: 
1.13    ! paf         8:        $Id: pa_vclass.h,v 1.12 2001/04/04 06:16:22 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_VCLASS_H
                     12: #define PA_VCLASS_H
                     13: 
1.8       paf        14: #include "pa_vstateless_class.h"
1.1       paf        15: #include "pa_vhash.h"
                     16: #include "pa_vjunction.h"
                     17: 
1.13    ! paf        18: /**    stores 
        !            19:        - base: VClass::base()
        !            20:        - fields: VClass::ffields
        !            21: */
1.8       paf        22: class VClass : public VStateless_class {
1.1       paf        23: public: // Value
                     24:        
                     25:        // all: for error reporting after fail(), etc
                     26:        const char *type() const { return "class"; }
1.9       paf        27: 
1.1       paf        28:        // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.8       paf        29:        Value *get_element(const String& aname) {
                     30:                if(Value *result=VStateless_class::get_element(aname))
                     31:                        return result;
                     32: 
                     33:                // $field=static field
                     34:                return get_field(aname);
                     35:        }
1.1       paf        36: 
                     37:        // object_class, operator_class: (field)=value - static values only
1.11      paf        38:        void put_element(const String& name, Value *value) {
                     39:                set_field(name, value);
                     40:        }
1.1       paf        41: 
                     42: public: // usage
                     43: 
1.8       paf        44:        VClass(Pool& apool) : VStateless_class(apool), 
                     45:                ffields(apool) {
1.1       paf        46:        }
                     47: 
1.12      paf        48: private:
                     49: 
1.1       paf        50:        void set_field(const String& name, Value *value) {
1.12      paf        51:                //if(value) // used in ^process to temporarily remove @main
                     52:                        //value->set_name(name);
1.1       paf        53:                if(fbase && fbase->replace_field(name, value))
                     54:                        return;
                     55: 
                     56:                ffields.put(name, value);
                     57:        }
                     58: 
                     59:        Value *get_field(const String& name) {
                     60:                Value *result=static_cast<Value *>(ffields.get(name));
                     61:                if(!result && fbase)
                     62:                        result=fbase->get_field(name);
                     63:                return result;
                     64:        }
1.8       paf        65: 
                     66: protected:
1.1       paf        67:                
                     68:        bool replace_field(const String& name, Value *value) {
                     69:                return 
                     70:                        (fbase && fbase->replace_field(name, value)) ||
                     71:                        ffields.put_replace(name, value);
                     72:        }
1.4       paf        73: 
1.1       paf        74: private:
                     75: 
                     76:        Hash ffields;
                     77: };
                     78: 
                     79: #endif

E-mail: