Annotation of parser3/src/types/pa_vclass.h, revision 1.12
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.12 ! paf 6: $Id: pa_vclass.h,v 1.11 2001/03/24 09:44:20 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
1.11 paf 32: void put_element(const String& name, Value *value) {
33: set_field(name, value);
34: }
1.1 paf 35:
36: public: // usage
37:
1.8 paf 38: VClass(Pool& apool) : VStateless_class(apool),
39: ffields(apool) {
1.1 paf 40: }
41:
1.12 ! paf 42: private:
! 43:
1.1 paf 44: void set_field(const String& name, Value *value) {
1.12 ! paf 45: //if(value) // used in ^process to temporarily remove @main
! 46: //value->set_name(name);
1.1 paf 47: if(fbase && fbase->replace_field(name, value))
48: return;
49:
50: ffields.put(name, value);
51: }
52:
53: Value *get_field(const String& name) {
54: Value *result=static_cast<Value *>(ffields.get(name));
55: if(!result && fbase)
56: result=fbase->get_field(name);
57: return result;
58: }
1.8 paf 59:
60: protected:
1.1 paf 61:
62: bool replace_field(const String& name, Value *value) {
63: return
64: (fbase && fbase->replace_field(name, value)) ||
65: ffields.put_replace(name, value);
66: }
1.4 paf 67:
1.1 paf 68: private:
69:
70: Hash ffields;
71: };
72:
73: #endif
E-mail: