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