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

1.1       paf         1: /*
1.38    ! paf         2:   $Id: pa_value.h,v 1.37 2001/03/06 12:22:57 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.25      paf        96:        virtual void put_string(String *astring) { failed("storing string to '%s'"); }
1.37      paf        97: 
                     98:        // string: value
                     99:        // double: value
                    100:        virtual double get_double() { failed("getting numerical value of '%s'"); return 0; }
1.1       paf       101: 
1.9       paf       102:        // junction: auto_calc,root,self,rcontext,wcontext, code
1.23      paf       103:        virtual Junction *get_junction() { return 0; }
1.8       paf       104: 
1.1       paf       105:        // hash: (key)=value
1.2       paf       106:        // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.29      paf       107:        // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref
1.7       paf       108:        // operator_class: (field)=value - static values only
1.24      paf       109:        // codeframe: wcontext_transparent
1.30      paf       110:        // methodframe: my or self_transparent
1.29      paf       111:        virtual Value *get_element(const String& name) { failed("type is '%s', can not get element from it"); return 0; }
1.13      paf       112:        
1.15      paf       113:        // hash: (key)=value
1.9       paf       114:        // object_class, operator_class: (field)=value - static values only
1.26      paf       115:        // object_instance: (field)=value
1.24      paf       116:        // codeframe: wcontext_transparent
1.30      paf       117:        // methodframe: my or self_transparent
1.29      paf       118:        virtual void put_element(const String& name, Value *value) { failed("type is '%s', can not put element to it"); }
1.5       paf       119: 
                    120:        // object_class, object_instance: object_class
1.32      paf       121:        // wcontext: none yet | transparent
1.9       paf       122:        virtual VClass *get_class() { return 0; }
1.34      paf       123: 
                    124:        // valiased: this
                    125:        // wcontext: transparent
1.35      paf       126:        // methodframe: self_transparent
1.36      paf       127:        virtual VAliased *get_aliased() { return 0; }
1.9       paf       128: 
1.17      paf       129: public: // usage
                    130: 
1.28      paf       131:        Value(Pool& apool) : Pooled(apool), fname(new(apool) String(apool)) {
                    132:                fname->APPEND_CONST("unnamed");
                    133:        }
1.17      paf       134: 
1.27      paf       135:        void set_name(String& aname) { fname=&aname; }
1.18      paf       136: 
                    137:        String& as_string() {
1.17      paf       138:                String *result=get_string(); 
                    139:                if(!result)
1.25      paf       140:                        failed("getting string of '%s'");
1.17      paf       141:                return *result;
                    142:        }
1.9       paf       143: 
1.18      paf       144: private:
                    145: 
1.27      paf       146:        String *fname;
1.18      paf       147: 
1.9       paf       148: private: 
1.6       paf       149: 
1.18      paf       150:        void failed(char *action);
1.1       paf       151: };
                    152: 
                    153: /*
                    154: descendants:
                    155:        text:+ value:String
                    156:     hash:+ keys&values:Hash
                    157:     table:+ columns_order:Array, columns:Hash, rows:Array
                    158:     object_class:+ STATIC:Hash, methods:Hash
                    159:     object_instance:+ object_class, fields:Hash
1.2       paf       160:     method_ref:+ self:Value/object_class, method:String
1.4       paf       161:     method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8       paf       162:        junction:+ self:Value, code:String
1.1       paf       163: */
                    164: 
                    165: #endif

E-mail: