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