Annotation of parser3/src/include/pa_vobject.h, revision 1.8
1.1 paf 1: /*
1.8 ! paf 2: $Id: pa_vobject.h,v 1.7 2001/02/25 16:36:11 paf Exp $
1.1 paf 3: */
4:
5: #ifndef PA_VOBJECT_H
6: #define PA_VOBJECT_H
7:
1.7 paf 8: #include "pa_valiased.h"
1.1 paf 9: #include "pa_vjunction.h"
1.4 paf 10:
1.7 paf 11: class Temp_class_alias;
12:
13: class VObject : public VAliased {
14: friend Temp_class_alias;
1.1 paf 15: public: // Value
16:
17: // all: for error reporting after fail(), etc
1.8 ! paf 18: const char *type() const { return "object"; }
1.1 paf 19:
1.4 paf 20: // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref
1.1 paf 21: Value *get_element(const String& name) {
1.4 paf 22: // $CLASS=my class
23: if(name==CLASS_NAME)
1.7 paf 24: return class_alias;
1.6 paf 25: // $BASE=my parent
26: if(name==BASE_NAME)
1.7 paf 27: return class_alias->base();
28: // $method=junction(self+class+method)
29: if(Junction *junction=class_real.get_junction(*this, name))
30: return NEW VJunction(*junction);
1.1 paf 31: // $field=fields.field
32: return static_cast<Value *>(fields.get(name));
33: }
34:
35: // object_instance: (field)=value
36: void put_element(const String& name, Value *value) {
37: // speed1:
1.4 paf 38: // will not check for '$CLASS(subst)' trick
1.1 paf 39: // will hope that user ain't THAT self-hating person
40: // speed2:
41: // will not check for '$method_name(subst)' trick
42: // -same-
43:
44: fields.put(name, value);
45: }
46:
47: // object_class, object_instance: object_class
1.7 paf 48: VClass *get_class() { return &class_real; }
1.1 paf 49:
50: public: // creation
51:
1.7 paf 52: VObject(Pool& apool, VClass& vclass) : VAliased(apool, vclass),
53: class_real(vclass),
1.1 paf 54: fields(apool) {
55: }
56:
57: private:
58:
1.7 paf 59: VClass& class_real;
1.1 paf 60: Hash fields;
61: };
62:
63: #endif
E-mail: