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