Annotation of parser3/src/include/pa_value.h, revision 1.26
1.1 paf 1: /*
1.26 ! paf 2: $Id: pa_value.h,v 1.25 2001/02/24 11:46:03 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.25 paf 92: virtual void put_string(String *astring) { failed("storing string to '%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.25 paf 104: virtual Value *get_element(const String& name) { failed("is '%s', can not get element from it"); 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.26 ! paf 108: // object_instance: (field)=value
1.19 paf 109: // wcontext: transparent
110: // frame: my or self_transparent
1.24 paf 111: // codeframe: wcontext_transparent
1.25 paf 112: virtual void put_element(const String& name, Value *value) { failed("is '%s', can not put element to it"); }
1.5 paf 113:
114: // object_class, object_instance: object_class
1.19 paf 115: // frame: transparent
116: // wcontext: transparent
1.24 paf 117: // codeframe: wcontext_transparent
1.9 paf 118: virtual VClass *get_class() { return 0; }
119:
120: // object_class: true when this class is this or derived from 'ancestor'
1.19 paf 121: // frame: transparent
122: // wcontext: transparent
1.24 paf 123: // codeframe: wcontext_transparent
1.25 paf 124: virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of '%s'"); return false; }
1.17 paf 125:
126: public: // usage
127:
1.18 paf 128: Value(Pool& apool) : Pooled(apool), fname(0) {}
1.17 paf 129:
1.18 paf 130: void set_name(const String& aname) { fname=&aname; }
131:
132: String& as_string() {
1.17 paf 133: String *result=get_string();
134: if(!result)
1.25 paf 135: failed("getting string of '%s'");
1.17 paf 136: return *result;
137: }
1.9 paf 138:
1.18 paf 139: private:
140:
141: const String *fname;
142:
1.9 paf 143: private:
1.6 paf 144:
1.18 paf 145: void failed(char *action);
1.1 paf 146: };
147:
148: /*
149: descendants:
150: text:+ value:String
151: hash:+ keys&values:Hash
152: table:+ columns_order:Array, columns:Hash, rows:Array
153: object_class:+ STATIC:Hash, methods:Hash
154: object_instance:+ object_class, fields:Hash
1.2 paf 155: method_ref:+ self:Value/object_class, method:String
1.4 paf 156: method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8 paf 157: junction:+ self:Value, code:String
1.1 paf 158: */
159:
160: #endif
E-mail: