Annotation of parser3/src/types/pa_vclass.h, revision 1.10
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.10 ! paf 6: $Id: pa_vclass.h,v 1.9 2001/03/13 20:02:11 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_VCLASS_H
10: #define PA_VCLASS_H
11:
1.8 paf 12: #include "pa_vstateless_class.h"
1.1 paf 13: #include "pa_vhash.h"
14: #include "pa_vjunction.h"
15:
1.8 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"; }
1.9 paf 21:
1.1 paf 22: // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class
1.8 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: public: // usage
35:
1.8 paf 36: VClass(Pool& apool) : VStateless_class(apool),
37: ffields(apool) {
1.1 paf 38: }
39:
40: void set_field(const String& name, Value *value) {
1.4 paf 41: if(value) // used in ^process to temporarily remove @main
42: value->set_name(name);
1.1 paf 43: if(fbase && fbase->replace_field(name, value))
44: return;
45:
46: ffields.put(name, value);
47: }
48:
49: private:
50:
51: Value *get_field(const String& name) {
52: Value *result=static_cast<Value *>(ffields.get(name));
53: if(!result && fbase)
54: result=fbase->get_field(name);
55: return result;
56: }
1.8 paf 57:
58: protected:
1.1 paf 59:
60: bool replace_field(const String& name, Value *value) {
61: return
62: (fbase && fbase->replace_field(name, value)) ||
63: ffields.put_replace(name, value);
64: }
1.4 paf 65:
1.1 paf 66: private:
67:
68: Hash ffields;
69: };
70:
71: #endif
E-mail: