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

1.1       paf         1: /*
1.32    ! paf         2:   $Id: pa_value.h,v 1.31 2001/02/25 13:23:01 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;
                     24: 
                     25: class Method : public Pooled {
1.1       paf        26: public:
1.11      paf        27:        const String& name;
                     28:        Array& params_names;
                     29:        Array& locals_names;
1.23      paf        30:        const Array& code;
1.9       paf        31: 
                     32:        Method(
                     33:                Pool& apool,
1.11      paf        34:                const String& aname,
                     35:                Array& aparams_names,
                     36:                Array& alocals_names,
1.23      paf        37:                const Array& acode) : 
1.19      paf        38: 
1.9       paf        39:                Pooled(apool),
                     40:                name(aname),
1.11      paf        41:                params_names(aparams_names),
                     42:                locals_names(alocals_names),
1.9       paf        43:                code(acode) {
                     44:        }
1.1       paf        45: };
                     46: 
1.9       paf        47: /*
1.7       paf        48: class Operator : public Method {
                     49:        // operator module static vars stored in there
1.9       paf        50:        VOperator_class *self;
1.7       paf        51: };
1.9       paf        52: */
1.7       paf        53: 
1.21      paf        54: class Junction : public Pooled {
1.2       paf        55: public:
                     56: 
1.20      paf        57:        Junction(Pool& apool,
1.24      paf        58:                Value& aself,
1.20      paf        59:                Method *amethod,
                     60:                Value *aroot,
                     61:                Value *arcontext,
1.24      paf        62:                WContext *awcontext,
1.23      paf        63:                const Array *acode) : Pooled(apool),
1.20      paf        64:                
1.24      paf        65:                self(aself),
1.20      paf        66:                method(amethod),
                     67:                root(aroot),
                     68:                rcontext(arcontext),
1.24      paf        69:                wcontext(awcontext),
1.20      paf        70:                code(acode) {
                     71:        }
                     72: 
1.24      paf        73:        Value& self;
1.21      paf        74:        Method *method;
                     75:        Value *root;
                     76:        Value *rcontext;
1.24      paf        77:        WContext *wcontext;
1.23      paf        78:        const Array *code;
1.8       paf        79: };
                     80: 
1.9       paf        81: class Value : public Pooled {
1.17      paf        82: public: // Value
1.9       paf        83: 
                     84:        // all: for error reporting after fail(), etc
1.13      paf        85:        virtual const char *type() const =0;
1.31      paf        86:        /*const*/ String& name() const { return *fname; }
1.9       paf        87: 
1.13      paf        88:        // string: value
1.16      paf        89:        // unknown: ""
                     90:        // others: 0
1.13      paf        91:        virtual String *get_string() { return 0; }
1.9       paf        92:        
1.13      paf        93:        // string: value
1.25      paf        94:        virtual void put_string(String *astring) { failed("storing string to '%s'"); }
1.1       paf        95: 
1.9       paf        96:        // junction: auto_calc,root,self,rcontext,wcontext, code
1.23      paf        97:        virtual Junction *get_junction() { return 0; }
1.8       paf        98: 
1.1       paf        99:        // hash: (key)=value
1.2       paf       100:        // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.29      paf       101:        // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref
1.7       paf       102:        // operator_class: (field)=value - static values only
1.24      paf       103:        // codeframe: wcontext_transparent
1.30      paf       104:        // methodframe: my or self_transparent
1.29      paf       105:        virtual Value *get_element(const String& name) { failed("type is '%s', can not get element from it"); return 0; }
1.13      paf       106:        
1.15      paf       107:        // hash: (key)=value
1.9       paf       108:        // object_class, operator_class: (field)=value - static values only
1.26      paf       109:        // object_instance: (field)=value
1.24      paf       110:        // codeframe: wcontext_transparent
1.30      paf       111:        // methodframe: my or self_transparent
1.29      paf       112:        virtual void put_element(const String& name, Value *value) { failed("type is '%s', can not put element to it"); }
1.5       paf       113: 
                    114:        // object_class, object_instance: object_class
1.32    ! paf       115:        // wcontext: none yet | transparent
1.9       paf       116:        virtual VClass *get_class() { return 0; }
                    117: 
1.17      paf       118: public: // usage
                    119: 
1.28      paf       120:        Value(Pool& apool) : Pooled(apool), fname(new(apool) String(apool)) {
                    121:                fname->APPEND_CONST("unnamed");
                    122:        }
1.17      paf       123: 
1.27      paf       124:        void set_name(String& aname) { fname=&aname; }
1.18      paf       125: 
                    126:        String& as_string() {
1.17      paf       127:                String *result=get_string(); 
                    128:                if(!result)
1.25      paf       129:                        failed("getting string of '%s'");
1.17      paf       130:                return *result;
                    131:        }
1.9       paf       132: 
1.18      paf       133: private:
                    134: 
1.27      paf       135:        String *fname;
1.18      paf       136: 
1.9       paf       137: private: 
1.6       paf       138: 
1.18      paf       139:        void failed(char *action);
1.1       paf       140: };
                    141: 
                    142: /*
                    143: descendants:
                    144:        text:+ value:String
                    145:     hash:+ keys&values:Hash
                    146:     table:+ columns_order:Array, columns:Hash, rows:Array
                    147:     object_class:+ STATIC:Hash, methods:Hash
                    148:     object_instance:+ object_class, fields:Hash
1.2       paf       149:     method_ref:+ self:Value/object_class, method:String
1.4       paf       150:     method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8       paf       151:        junction:+ self:Value, code:String
1.1       paf       152: */
                    153: 
                    154: #endif

E-mail: