--- parser3/src/include/Attic/pa_value.h 2001/02/23 09:43:13 1.16 +++ parser3/src/include/Attic/pa_value.h 2001/02/24 14:17:08 1.27 @@ -1,5 +1,5 @@ /* - $Id: pa_value.h,v 1.16 2001/02/23 09:43:13 paf Exp $ + $Id: pa_value.h,v 1.27 2001/02/24 14:17:08 paf Exp $ */ /* @@ -10,11 +10,15 @@ #define PA_VALUE_H #include "pa_pool.h" -#include "pa_exception.h" #include "pa_string.h" #include "pa_array.h" //#include "pa_voperator.h" +#define NAME_NAME "NAME" +#define PARENTS_NAME "PARENTS" +#define STATIC_NAME "STATIC" +#define STATICS_NAME "STATICS" + class Value; class VClass; //class VOperator; @@ -26,14 +30,15 @@ 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), params_names(aparams_names), @@ -49,30 +54,39 @@ class Operator : public Method { }; */ -class Method_ref { +class Junction : public Pooled { public: - Value *self; - Method& method; -}; -class Junction { - bool auto_calc; - Value& root; - Value *self; - Value& rcontext; - WContext& wcontext; - Array& code; + Junction(Pool& apool, + Value& aself, + Method *amethod, + Value *aroot, + Value *arcontext, + WContext *awcontext, + const Array *acode) : Pooled(apool), + + self(aself), + method(amethod), + root(aroot), + rcontext(arcontext), + wcontext(awcontext), + code(acode) { + } + + Value& self; + Method *method; + Value *root; + Value *rcontext; + WContext *wcontext; + const Array *code; }; class Value : public Pooled { -public: - - Value(Pool& apool) : Pooled(apool) {} - -public: +public: // Value // all: for error reporting after fail(), etc virtual const char *type() const =0; + /*const*/ String *name() const { return fname; } // string: value // unknown: "" @@ -80,40 +94,60 @@ public: virtual String *get_string() { return 0; } // string: value - virtual void put_string(String *astring) { failed("storing string to %s"); } - - // method_ref: self, method - virtual Method_ref *get_method_ref() { failed("extracting method reference from %s"); return 0; } + virtual void put_string(String *astring) { failed("storing string to '%s'"); } // junction: auto_calc,root,self,rcontext,wcontext, code - virtual Junction *get_junction() { failed("getting junction from %s"); 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 // operator_class: (field)=value - static values only - virtual Value *get_element(const String& name) { failed("getting element from %s"); return 0; } + // wcontext: transparent + // frame: my or self_transparent + // codeframe: wcontext_transparent + virtual Value *get_element(const String& name) { failed("is '%s', can not get element from it"); return 0; } // hash: (key)=value // object_class, operator_class: (field)=value - static values only - virtual void put_element(const String& name, Value *value) { failed("putting element to %s"); } - - // object_instance, object_class: method - virtual Method *get_method(const String& name) const { return 0; } + // object_instance: (field)=value + // wcontext: transparent + // frame: my or self_transparent + // codeframe: wcontext_transparent + virtual void put_element(const String& name, Value *value) { failed("is '%s', can not put element to it"); } // object_class, object_instance: object_class + // frame: transparent + // wcontext: transparent + // codeframe: wcontext_transparent virtual VClass *get_class() { return 0; } // object_class: true when this class is this or derived from 'ancestor' - virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of %s"); return false; } + // frame: transparent + // wcontext: transparent + // codeframe: wcontext_transparent + virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of '%s'"); return false; } + +public: // usage + + Value(Pool& apool) : Pooled(apool), fname(0) {} + + void set_name(String& aname) { fname=&aname; } + + String& as_string() { + String *result=get_string(); + if(!result) + failed("getting string of '%s'"); + return *result; + } + +private: + + String *fname; private: - void failed(char *action) { - THROW(0,0, - 0, - action, type()); - } + void failed(char *action); }; /*