Annotation of parser3/src/include/pa_value.h, revision 1.39

1.1       paf         1: /*
1.39    ! paf         2:   $Id: pa_value.h,v 1.38 2001/03/06 14:09:35 paf Exp $
1.1       paf         3: */
                      4: 
                      5: /*
                      6:        data core
                      7: */
                      8: 
                      9: #ifndef PA_VALUE_H
                     10: #define PA_VALUE_H
                     11: 
1.9       paf        12: #include "pa_pool.h"
1.1       paf        13: #include "pa_string.h"
1.9       paf        14: #include "pa_array.h"
                     15: //#include "pa_voperator.h"
1.1       paf        16: 
1.27      paf        17: #define NAME_NAME "NAME"
                     18: 
1.9       paf        19: class Value;
                     20: class VClass;
                     21: //class VOperator;
                     22: class Junction;
                     23: class WContext;
1.33      paf        24: class VAliased;
1.9       paf        25: 
                     26: class Method : public Pooled {
1.1       paf        27: public:
1.11      paf        28:        const String& name;
                     29:        Array& params_names;
                     30:        Array& locals_names;
1.23      paf        31:        const Array& code;
1.9       paf        32: 
                     33:        Method(
                     34:                Pool& apool,
1.11      paf        35:                const String& aname,
                     36:                Array& aparams_names,
                     37:                Array& alocals_names,
1.23      paf        38:                const Array& acode) : 
1.19      paf        39: 
1.9       paf        40:                Pooled(apool),
                     41:                name(aname),
1.11      paf        42:                params_names(aparams_names),
                     43:                locals_names(alocals_names),
1.9       paf        44:                code(acode) {
                     45:        }
1.1       paf        46: };
                     47: 
1.9       paf        48: /*
1.7       paf        49: class Operator : public Method {
                     50:        // operator module static vars stored in there
1.9       paf        51:        VOperator_class *self;
1.7       paf        52: };
1.9       paf        53: */
1.7       paf        54: 
1.21      paf        55: class Junction : public Pooled {
1.2       paf        56: public:
                     57: 
1.20      paf        58:        Junction(Pool& apool,
1.34      paf        59:                Value& aself,
1.33      paf        60:                VClass *avclass, Method *amethod,
1.20      paf        61:                Value *aroot,
                     62:                Value *arcontext,
1.24      paf        63:                WContext *awcontext,
1.23      paf        64:                const Array *acode) : Pooled(apool),
1.20      paf        65:                
1.24      paf        66:                self(aself),
1.33      paf        67:                vclass(avclass), method(amethod),
1.20      paf        68:                root(aroot),
                     69:                rcontext(arcontext),
1.24      paf        70:                wcontext(awcontext),
1.20      paf        71:                code(acode) {
                     72:        }
                     73: 
1.34      paf        74:        Value& self;
1.33      paf        75:        VClass *vclass;  Method *method;
1.21      paf        76:        Value *root;
                     77:        Value *rcontext;
1.24      paf        78:        WContext *wcontext;
1.23      paf        79:        const Array *code;
1.8       paf        80: };
                     81: 
1.9       paf        82: class Value : public Pooled {
1.17      paf        83: public: // Value
1.9       paf        84: 
                     85:        // all: for error reporting after fail(), etc
1.13      paf        86:        virtual const char *type() const =0;
1.31      paf        87:        /*const*/ String& name() const { return *fname; }
1.9       paf        88: 
1.13      paf        89:        // string: value
1.16      paf        90:        // unknown: ""
1.38      paf        91:        // double: value
1.16      paf        92:        // others: 0
1.13      paf        93:        virtual String *get_string() { return 0; }
1.9       paf        94:        
1.13      paf        95:        // string: value
1.37      paf        96:        // double: value
1.39    ! paf        97:        // bool: value
1.37      paf        98:        virtual double get_double() { failed("getting numerical value of '%s'"); return 0; }
1.39    ! paf        99: 
        !           100:        // unknown: false
        !           101:        // bool: value
        !           102:        // double: 0 or !0
        !           103:        // string: empty or not
        !           104:        // others: true // junction true == method defined. others 
        !           105:        virtual bool get_bool() { return true; }
1.1       paf       106: 
1.9       paf       107:        // junction: auto_calc,root,self,rcontext,wcontext, code
1.23      paf       108:        virtual Junction *get_junction() { return 0; }
1.8       paf       109: 
1.1       paf       110:        // hash: (key)=value
1.2       paf       111:        // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.29      paf       112:        // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref
1.7       paf       113:        // operator_class: (field)=value - static values only
1.24      paf       114:        // codeframe: wcontext_transparent
1.30      paf       115:        // methodframe: my or self_transparent
1.29      paf       116:        virtual Value *get_element(const String& name) { failed("type is '%s', can not get element from it"); return 0; }
1.13      paf       117:        
1.15      paf       118:        // hash: (key)=value
1.9       paf       119:        // object_class, operator_class: (field)=value - static values only
1.26      paf       120:        // object_instance: (field)=value
1.24      paf       121:        // codeframe: wcontext_transparent
1.30      paf       122:        // methodframe: my or self_transparent
1.29      paf       123:        virtual void put_element(const String& name, Value *value) { failed("type is '%s', can not put element to it"); }
1.5       paf       124: 
                    125:        // object_class, object_instance: object_class
1.32      paf       126:        // wcontext: none yet | transparent
1.9       paf       127:        virtual VClass *get_class() { return 0; }
1.34      paf       128: 
                    129:        // valiased: this
                    130:        // wcontext: transparent
1.35      paf       131:        // methodframe: self_transparent
1.36      paf       132:        virtual VAliased *get_aliased() { return 0; }
1.9       paf       133: 
1.17      paf       134: public: // usage
                    135: 
1.28      paf       136:        Value(Pool& apool) : Pooled(apool), fname(new(apool) String(apool)) {
                    137:                fname->APPEND_CONST("unnamed");
                    138:        }
1.17      paf       139: 
1.27      paf       140:        void set_name(String& aname) { fname=&aname; }
1.18      paf       141: 
                    142:        String& as_string() {
1.17      paf       143:                String *result=get_string(); 
                    144:                if(!result)
1.25      paf       145:                        failed("getting string of '%s'");
1.17      paf       146:                return *result;
                    147:        }
1.9       paf       148: 
1.18      paf       149: private:
                    150: 
1.27      paf       151:        String *fname;
1.18      paf       152: 
1.9       paf       153: private: 
1.6       paf       154: 
1.18      paf       155:        void failed(char *action);
1.1       paf       156: };
                    157: 
                    158: /*
                    159: descendants:
                    160:        text:+ value:String
                    161:     hash:+ keys&values:Hash
                    162:     table:+ columns_order:Array, columns:Hash, rows:Array
                    163:     object_class:+ STATIC:Hash, methods:Hash
                    164:     object_instance:+ object_class, fields:Hash
1.2       paf       165:     method_ref:+ self:Value/object_class, method:String
1.4       paf       166:     method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8       paf       167:        junction:+ self:Value, code:String
1.1       paf       168: */
                    169: 
                    170: #endif

E-mail: