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