Annotation of parser3/src/include/pa_value.h, revision 1.18
1.1 paf 1: /*
1.18 ! paf 2: $Id: pa_value.h,v 1.17 2001/02/23 10:17:28 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.9 paf 28: Array& code;
29:
30: Method(
31: Pool& apool,
1.11 paf 32: const String& aname,
33: Array& aparams_names,
34: Array& alocals_names,
1.9 paf 35: Array& acode) :
36: Pooled(apool),
37: name(aname),
1.11 paf 38: params_names(aparams_names),
39: locals_names(alocals_names),
1.9 paf 40: code(acode) {
41: }
1.1 paf 42: };
43:
1.9 paf 44: /*
1.7 paf 45: class Operator : public Method {
46: // operator module static vars stored in there
1.9 paf 47: VOperator_class *self;
1.7 paf 48: };
1.9 paf 49: */
1.7 paf 50:
1.2 paf 51: class Method_ref {
52: public:
53: Value *self;
54: Method& method;
55: };
56:
1.8 paf 57: class Junction {
1.9 paf 58: bool auto_calc;
59: Value& root;
1.8 paf 60: Value *self;
1.9 paf 61: Value& rcontext;
62: WContext& wcontext;
63: Array& code;
1.8 paf 64: };
65:
1.9 paf 66: class Value : public Pooled {
1.17 paf 67: public: // Value
1.9 paf 68:
69: // all: for error reporting after fail(), etc
1.13 paf 70: virtual const char *type() const =0;
1.18 ! paf 71: const String *name() const { return fname; }
1.9 paf 72:
1.13 paf 73: // string: value
1.16 paf 74: // unknown: ""
75: // others: 0
1.13 paf 76: virtual String *get_string() { return 0; }
1.9 paf 77:
1.13 paf 78: // string: value
79: virtual void put_string(String *astring) { failed("storing string to %s"); }
1.1 paf 80:
1.8 paf 81: // method_ref: self, method
1.13 paf 82: virtual Method_ref *get_method_ref() { failed("extracting method reference from %s"); return 0; }
1.3 paf 83:
1.9 paf 84: // junction: auto_calc,root,self,rcontext,wcontext, code
1.13 paf 85: virtual Junction *get_junction() { failed("getting junction from %s"); return 0; }
1.8 paf 86:
1.1 paf 87: // hash: (key)=value
1.2 paf 88: // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.1 paf 89: // object_instance: (field)=value;(STATIC)=hash;(method)=method_ref
1.7 paf 90: // operator_class: (field)=value - static values only
1.13 paf 91: virtual Value *get_element(const String& name) { failed("getting element from %s"); return 0; }
92:
1.15 paf 93: // hash: (key)=value
1.9 paf 94: // object_class, operator_class: (field)=value - static values only
1.13 paf 95: virtual void put_element(const String& name, Value *value) { failed("putting element to %s"); }
1.1 paf 96:
97: // object_instance, object_class: method
1.9 paf 98: virtual Method *get_method(const String& name) const { return 0; }
1.5 paf 99:
100: // object_class, object_instance: object_class
1.9 paf 101: virtual VClass *get_class() { return 0; }
102:
103: // object_class: true when this class is this or derived from 'ancestor'
1.13 paf 104: virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of %s"); return false; }
1.17 paf 105:
106: public: // usage
107:
1.18 ! paf 108: Value(Pool& apool) : Pooled(apool), fname(0) {}
1.17 paf 109:
1.18 ! paf 110: void set_name(const String& aname) { fname=&aname; }
! 111:
! 112: String& as_string() {
1.17 paf 113: String *result=get_string();
114: if(!result)
115: failed("getting string of %s");
116: return *result;
117: }
1.9 paf 118:
1.18 ! paf 119: private:
! 120:
! 121: const String *fname;
! 122:
1.9 paf 123: private:
1.6 paf 124:
1.18 ! paf 125: void failed(char *action);
1.1 paf 126: };
127:
128: /*
129: descendants:
130: text:+ value:String
131: hash:+ keys&values:Hash
132: table:+ columns_order:Array, columns:Hash, rows:Array
133: object_class:+ STATIC:Hash, methods:Hash
134: object_instance:+ object_class, fields:Hash
1.2 paf 135: method_ref:+ self:Value/object_class, method:String
1.4 paf 136: method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]
1.8 paf 137: junction:+ self:Value, code:String
1.1 paf 138: */
139:
140: #endif
E-mail: