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

1.1       paf         1: /*
1.9     ! paf         2:   $Id: pa_value.h,v 1.8 2001/02/15 14:18: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.9     ! paf        26:        String& name;
        !            27:        Array& param_names;
        !            28:        Array& local_names;
        !            29:        Array& code;
        !            30: 
        !            31:        Method(
        !            32:                Pool& apool,
        !            33:                String& aname,
        !            34:                Array& aparam_names,
        !            35:                Array& alocal_names,
        !            36:                Array& acode) : 
        !            37:                Pooled(apool),
        !            38:                name(aname),
        !            39:                param_names(aparam_names),
        !            40:                local_names(alocal_names),
        !            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
        !            75:        virtual const char *get_type() const =0;
        !            76: 
        !            77:        // text: value
        !            78:        // object_class: [class classname]
        !            79:        virtual String *get_string() { failed("getting string representation"); return 0; }
        !            80:        
1.1       paf        81:        // text: value
1.9     ! paf        82:        virtual void put_string(const String *astring) { failed("storing string"); }
1.1       paf        83: 
1.8       paf        84:        // method_ref: self, method
1.9     ! paf        85:        virtual Method_ref *get_method_ref() { failed("extracting method reference"); return 0; }
1.3       paf        86: 
1.9     ! paf        87:        // junction: auto_calc,root,self,rcontext,wcontext, code
        !            88:        virtual Junction *get_junction() { failed("getting junction"); }
1.8       paf        89: 
1.1       paf        90:        // hash: (key)=value
1.2       paf        91:        // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.1       paf        92:        // object_instance: (field)=value;(STATIC)=hash;(method)=method_ref
1.7       paf        93:        // operator_class: (field)=value - static values only
1.1       paf        94:        virtual Value *get_element(const String& name) const =0;
1.9     ! paf        95: 
        !            96:        // object_class, operator_class: (field)=value - static values only
        !            97:        virtual void put_element(const String& name, Value *value)=0;
1.1       paf        98: 
                     99:        // object_instance, object_class: method
1.9     ! paf       100:        virtual Method *get_method(const String& name) const { return 0; }
1.5       paf       101: 
                    102:        // object_class, object_instance: object_class
1.9     ! paf       103:        virtual VClass *get_class() { return 0; }
        !           104: 
        !           105:        // object_class: true when this class is this or derived from 'ancestor'
        !           106:        virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors"); return false; }
        !           107: 
        !           108: private: 
1.6       paf       109: 
1.9     ! paf       110:        void failed(char *action) {
        !           111:                pool().exception().raise(0,0,
        !           112:                        0,
        !           113:                        action);
        !           114:        }
1.1       paf       115: };
                    116: 
                    117: /*
                    118: descendants:
                    119:        text:+ value:String
                    120:     hash:+ keys&values:Hash
                    121:     table:+ columns_order:Array, columns:Hash, rows:Array
                    122:     object_class:+ STATIC:Hash, methods:Hash
                    123:     object_instance:+ object_class, fields:Hash
1.2       paf       124:     method_ref:+ self:Value/object_class, method:String
1.4       paf       125:     method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8       paf       126:        junction:+ self:Value, code:String
1.1       paf       127: */
                    128: 
                    129: #endif

E-mail: