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