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

1.1       paf         1: /*
1.16    ! paf         2:   $Id: pa_value.h,v 1.15 2001/02/22 16:21:49 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"
                     13: #include "pa_exception.h"
1.1       paf        14: #include "pa_string.h"
1.9       paf        15: #include "pa_array.h"
                     16: //#include "pa_voperator.h"
1.1       paf        17: 
1.9       paf        18: class Value;
                     19: class VClass;
                     20: //class VOperator;
                     21: class Junction;
                     22: class WContext;
                     23: 
                     24: class Method : public Pooled {
1.1       paf        25: public:
1.11      paf        26:        const String& name;
                     27:        Array& params_names;
                     28:        Array& locals_names;
1.9       paf        29:        Array& code;
                     30: 
                     31:        Method(
                     32:                Pool& apool,
1.11      paf        33:                const String& aname,
                     34:                Array& aparams_names,
                     35:                Array& alocals_names,
1.9       paf        36:                Array& acode) : 
                     37:                Pooled(apool),
                     38:                name(aname),
1.11      paf        39:                params_names(aparams_names),
                     40:                locals_names(alocals_names),
1.9       paf        41:                code(acode) {
                     42:        }
1.1       paf        43: };
                     44: 
1.9       paf        45: /*
1.7       paf        46: class Operator : public Method {
                     47:        // operator module static vars stored in there
1.9       paf        48:        VOperator_class *self;
1.7       paf        49: };
1.9       paf        50: */
1.7       paf        51: 
1.2       paf        52: class Method_ref {
                     53: public:
                     54:        Value *self;
                     55:        Method& method;
                     56: };
                     57: 
1.8       paf        58: class Junction {
1.9       paf        59:        bool auto_calc;
                     60:        Value& root;
1.8       paf        61:        Value *self;
1.9       paf        62:        Value& rcontext;
                     63:        WContext& wcontext;
                     64:        Array& code;
1.8       paf        65: };
                     66: 
1.9       paf        67: class Value : public Pooled {
                     68: public:
                     69: 
                     70:        Value(Pool& apool) : Pooled(apool) {}
                     71: 
1.1       paf        72: public:
1.9       paf        73: 
                     74:        // all: for error reporting after fail(), etc
1.13      paf        75:        virtual const char *type() const =0;
1.9       paf        76: 
1.13      paf        77:        // string: value
1.16    ! paf        78:        // unknown: ""
        !            79:        // others: 0
1.13      paf        80:        virtual String *get_string() { return 0; }
1.9       paf        81:        
1.13      paf        82:        // string: value
                     83:        virtual void put_string(String *astring) { failed("storing string to %s"); }
1.1       paf        84: 
1.8       paf        85:        // method_ref: self, method
1.13      paf        86:        virtual Method_ref *get_method_ref() { failed("extracting method reference from %s"); return 0; }
1.3       paf        87: 
1.9       paf        88:        // junction: auto_calc,root,self,rcontext,wcontext, code
1.13      paf        89:        virtual Junction *get_junction() { failed("getting junction from %s"); return 0; }
1.8       paf        90: 
1.1       paf        91:        // hash: (key)=value
1.2       paf        92:        // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.1       paf        93:        // object_instance: (field)=value;(STATIC)=hash;(method)=method_ref
1.7       paf        94:        // operator_class: (field)=value - static values only
1.13      paf        95:        virtual Value *get_element(const String& name) { failed("getting element from %s"); return 0; }
                     96:        
1.15      paf        97:        // hash: (key)=value
1.9       paf        98:        // object_class, operator_class: (field)=value - static values only
1.13      paf        99:        virtual void put_element(const String& name, Value *value) { failed("putting element to %s"); }
1.1       paf       100: 
                    101:        // object_instance, object_class: method
1.9       paf       102:        virtual Method *get_method(const String& name) const { return 0; }
1.5       paf       103: 
                    104:        // object_class, object_instance: object_class
1.9       paf       105:        virtual VClass *get_class() { return 0; }
                    106: 
                    107:        // object_class: true when this class is this or derived from 'ancestor'
1.13      paf       108:        virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of %s"); return false; }
1.9       paf       109: 
                    110: private: 
1.6       paf       111: 
1.9       paf       112:        void failed(char *action) {
1.14      paf       113:                THROW(0,0,
1.9       paf       114:                        0,
1.13      paf       115:                        action, type());
1.9       paf       116:        }
1.1       paf       117: };
                    118: 
                    119: /*
                    120: descendants:
                    121:        text:+ value:String
                    122:     hash:+ keys&values:Hash
                    123:     table:+ columns_order:Array, columns:Hash, rows:Array
                    124:     object_class:+ STATIC:Hash, methods:Hash
                    125:     object_instance:+ object_class, fields:Hash
1.2       paf       126:     method_ref:+ self:Value/object_class, method:String
1.4       paf       127:     method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8       paf       128:        junction:+ self:Value, code:String
1.1       paf       129: */
                    130: 
                    131: #endif

E-mail: