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

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

E-mail: