Annotation of parser3/src/types/pa_vclass.h, revision 1.7.6.1
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 5:
1.7.6.1 ! paf 6: $Id: pa_vclass.h,v 1.7 2001/03/12 18:13:50 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_VCLASS_H
10: #define PA_VCLASS_H
11:
1.7.6.1 ! paf 12: #include "pa_vstateless_class.h"
1.1 paf 13: #include "pa_vhash.h"
14: #include "pa_vjunction.h"
15:
1.7.6.1 ! paf 16: class VClass : public VStateless_class {
1.1 paf 17: public: // Value
18:
19: // all: for error reporting after fail(), etc
20: const char *type() const { return "class"; }
21:
22: // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.7.6.1 ! paf 23: Value *get_element(const String& aname) {
! 24: if(Value *result=VStateless_class::get_element(aname))
! 25: return result;
! 26:
! 27: // $field=static field
! 28: return get_field(aname);
! 29: }
1.1 paf 30:
31: // object_class, operator_class: (field)=value - static values only
32: void put_element(const String& name, Value *value);
33:
34: // object_class, object_instance: object_class
1.7.6.1 ! paf 35: VStateless_class *get_class() { return this; }
1.1 paf 36:
37: public: // usage
38:
1.7.6.1 ! paf 39: VClass(Pool& apool) : VStateless_class(apool),
! 40: ffields(apool) {
1.1 paf 41: }
42:
43: void set_field(const String& name, Value *value) {
1.4 paf 44: if(value) // used in ^process to temporarily remove @main
45: value->set_name(name);
1.1 paf 46: if(fbase && fbase->replace_field(name, value))
47: return;
48:
49: ffields.put(name, value);
50: }
51:
52: private:
53:
54: Value *get_field(const String& name) {
55: Value *result=static_cast<Value *>(ffields.get(name));
56: if(!result && fbase)
57: result=fbase->get_field(name);
58: return result;
59: }
1.7.6.1 ! paf 60:
! 61: protected:
1.1 paf 62:
63: bool replace_field(const String& name, Value *value) {
64: return
65: (fbase && fbase->replace_field(name, value)) ||
66: ffields.put_replace(name, value);
67: }
1.4 paf 68:
1.1 paf 69: private:
70:
71: Hash ffields;
72: };
73:
74: #endif
E-mail: