--- parser3/src/include/Attic/pa_vclass.h 2001/02/25 16:36:11 1.19 +++ parser3/src/include/Attic/pa_vclass.h 2001/03/10 16:34:36 1.29 @@ -1,5 +1,9 @@ /* - $Id: pa_vclass.h,v 1.19 2001/02/25 16:36:11 paf Exp $ + Parser + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan + + $Id: pa_vclass.h,v 1.29 2001/03/10 16:34:36 paf Exp $ */ #ifndef PA_VCLASS_H @@ -7,7 +11,6 @@ #include "pa_valiased.h" #include "pa_vhash.h" -#include "pa_vstring.h" #include "pa_vjunction.h" #define CLASS_NAME "CLASS" @@ -17,30 +20,13 @@ class VClass : public VAliased { public: // Value // all: for error reporting after fail(), etc - const char *type() const { return "Class"; } + const char *type() const { return "class"; } // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class - Value *get_element(const String& aname) { - // $NAME=my name - if(aname==NAME_NAME) - return NEW VString(class_alias->name()); - // $CLASS=my class=myself - if(aname==CLASS_NAME) - return class_alias; - // $BASE=my parent - if(aname==BASE_NAME) - return class_alias->base(); - // $method=junction(self+class+method) - if(Junction *junction=get_junction(*this, aname)) - return NEW VJunction(*junction); - // $field=static field - return get_field(aname); - } + Value *get_element(const String& aname); // object_class, operator_class: (field)=value - static values only - void put_element(const String& name, Value *value) { - set_field(name, value); - } + void put_element(const String& name, Value *value); // object_class, object_instance: object_class VClass *get_class() { return this; } @@ -48,9 +34,9 @@ public: // Value public: // usage VClass(Pool& apool) : VAliased(apool, *this), - fields(apool), - fmethods(apool), - fbase(0) { + fbase(0), + ffields(apool), + fmethods(apool) { } void add_method(const String& name, Method& method) { @@ -78,31 +64,33 @@ public: // usage return 0; } + void set_field(const String& name, Value *value) { + value->set_name(name); + if(fbase && fbase->replace_field(name, value)) + return; + + ffields.put(name, value); + } + private: Value *get_field(const String& name) { - Value *result=static_cast(fields.get(name)); + Value *result=static_cast(ffields.get(name)); if(!result && fbase) result=fbase->get_field(name); return result; } - void set_field(const String& name, Value *value) { - if(fbase && fbase->replace_field(name, value)) - return; - - fields.put(name, value); - } bool replace_field(const String& name, Value *value) { return (fbase && fbase->replace_field(name, value)) || - fields.put_replace(name, value); + ffields.put_replace(name, value); } private: VClass *fbase; - Hash fields; + Hash ffields; Hash fmethods; };