--- parser3/src/include/Attic/pa_value.h 2001/02/15 14:18:49 1.8 +++ parser3/src/include/Attic/pa_value.h 2001/02/21 11:10:02 1.9 @@ -1,5 +1,5 @@ /* - $Id: pa_value.h,v 1.8 2001/02/15 14:18:49 paf Exp $ + $Id: pa_value.h,v 1.9 2001/02/21 11:10:02 paf Exp $ */ /* @@ -9,19 +9,45 @@ #ifndef PA_VALUE_H #define PA_VALUE_H +#include "pa_pool.h" +#include "pa_exception.h" #include "pa_string.h" +#include "pa_array.h" +//#include "pa_voperator.h" -class Method { +class Value; +class VClass; +//class VOperator; +class Junction; +class WContext; + +class Method : public Pooled { public: - Array param_names; - Array local_names; - String code; + String& name; + Array& param_names; + Array& local_names; + Array& code; + + Method( + Pool& apool, + String& aname, + Array& aparam_names, + Array& alocal_names, + Array& acode) : + Pooled(apool), + name(aname), + param_names(aparam_names), + local_names(alocal_names), + code(acode) { + } }; +/* class Operator : public Method { // operator module static vars stored in there - Operator_class *self; + VOperator_class *self; }; +*/ class Method_ref { public: @@ -30,37 +56,62 @@ public: }; class Junction { + bool auto_calc; + Value& root; Value *self; - String code; + Value& rcontext; + WContext& wcontext; + Array& code; }; -class Value { +class Value : public Pooled { +public: + + Value(Pool& apool) : Pooled(apool) {} + public: + + // all: for error reporting after fail(), etc + virtual const char *get_type() const =0; + + // text: value + // object_class: [class classname] + virtual String *get_string() { failed("getting string representation"); return 0; } + // text: value - virtual String *get_string() const =0; - virtual String *put_string(const String *astring)=0; + virtual void put_string(const String *astring) { failed("storing string"); } // method_ref: self, method - virtual Method_ref *get_method_ref() const =0; + virtual Method_ref *get_method_ref() { failed("extracting method reference"); return 0; } - // junction: self, code - virtual Junction *get_junction() const =0; + // junction: auto_calc,root,self,rcontext,wcontext, code + virtual Junction *get_junction() { failed("getting junction"); } // 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) const =0; - virtual Value *put_element(const String& name, const Value *avalue)=0; + + // object_class, operator_class: (field)=value - static values only + virtual void put_element(const String& name, Value *value)=0; // object_instance, object_class: method - virtual Method *get_method(const String& name) const =0; + virtual Method *get_method(const String& name) const { return 0; } // object_class, object_instance: object_class - virtual Class *get_class() const =0; + 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"); return false; } + +private: - // object_class: true when this class is derived from 'parent' - virtual bool has_parent(Class *aparent) const =0; + void failed(char *action) { + pool().exception().raise(0,0, + 0, + action); + } }; /*