--- parser3/src/include/Attic/pa_value.h 2001/02/23 22:22:07 1.22 +++ parser3/src/include/Attic/pa_value.h 2001/02/25 18:02:12 1.36 @@ -1,5 +1,5 @@ /* - $Id: pa_value.h,v 1.22 2001/02/23 22:22:07 paf Exp $ + $Id: pa_value.h,v 1.36 2001/02/25 18:02:12 paf Exp $ */ /* @@ -14,25 +14,28 @@ #include "pa_array.h" //#include "pa_voperator.h" +#define NAME_NAME "NAME" + class Value; class VClass; //class VOperator; class Junction; class WContext; +class VAliased; class Method : public Pooled { public: const String& name; Array& params_names; Array& locals_names; - Array& code; + const Array& code; Method( Pool& apool, const String& aname, Array& aparams_names, Array& alocals_names, - Array& acode) : + const Array& acode) : Pooled(apool), name(aname), @@ -53,24 +56,27 @@ class Junction : public Pooled { public: Junction(Pool& apool, - Method *amethod, + Value& aself, + VClass *avclass, Method *amethod, Value *aroot, - Value *aself, Value *arcontext, - Array *acode) : Pooled(apool), + WContext *awcontext, + const Array *acode) : Pooled(apool), - method(amethod), - root(aroot), self(aself), + vclass(avclass), method(amethod), + root(aroot), rcontext(arcontext), + wcontext(awcontext), code(acode) { } - Method *method; + Value& self; + VClass *vclass; Method *method; Value *root; - Value *self; Value *rcontext; - Array *code; + WContext *wcontext; + const Array *code; }; class Value : public Pooled { @@ -78,7 +84,7 @@ public: // Value // all: for error reporting after fail(), etc virtual const char *type() const =0; - const String *name() const { return fname; } + /*const*/ String& name() const { return *fname; } // string: value // unknown: "" @@ -86,51 +92,53 @@ public: // Value virtual String *get_string() { return 0; } // string: value - virtual void put_string(String *astring) { failed("storing string to %s:%s"); } + virtual void put_string(String *astring) { failed("storing string to '%s'"); } // junction: auto_calc,root,self,rcontext,wcontext, code - virtual Junction *get_junction() { failed("is not a method or a junction (it is '%s'), can not call it"); return 0; } + virtual Junction *get_junction() { return 0; } // hash: (key)=value // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class - // object_instance: (field)=value;(STATIC)=hash;(method)=method_ref + // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref // operator_class: (field)=value - static values only - // wcontext: transparent - // frame: my or self_transparent - virtual Value *get_element(const String& name) { failed("getting element from %s:%s"); return 0; } + // codeframe: wcontext_transparent + // methodframe: my or self_transparent + virtual Value *get_element(const String& name) { failed("type is '%s', can not get element from it"); return 0; } // hash: (key)=value // object_class, operator_class: (field)=value - static values only - // wcontext: transparent - // frame: my or self_transparent - virtual void put_element(const String& name, Value *value) { failed("putting element to %s:%s"); } + // object_instance: (field)=value + // codeframe: wcontext_transparent + // methodframe: my or self_transparent + virtual void put_element(const String& name, Value *value) { failed("type is '%s', can not put element to it"); } // object_class, object_instance: object_class - // frame: transparent - // wcontext: transparent + // wcontext: none yet | transparent virtual VClass *get_class() { return 0; } - // object_class: true when this class is this or derived from 'ancestor' - // frame: transparent + // valiased: this // wcontext: transparent - virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of %s:%s"); return false; } + // methodframe: self_transparent + virtual VAliased *get_aliased() { return 0; } public: // usage - Value(Pool& apool) : Pooled(apool), fname(0) {} + Value(Pool& apool) : Pooled(apool), fname(new(apool) String(apool)) { + fname->APPEND_CONST("unnamed"); + } - void set_name(const String& aname) { fname=&aname; } + void set_name(String& aname) { fname=&aname; } String& as_string() { String *result=get_string(); if(!result) - failed("getting string of %s:%s"); + failed("getting string of '%s'"); return *result; } private: - const String *fname; + String *fname; private: