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