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