Diff for /parser3/src/include/Attic/pa_value.h between versions 1.17 and 1.48

version 1.17, 2001/02/23 10:17:28 version 1.48, 2001/03/09 08:19:47
Line 1 Line 1
   
 /*  /*
   $Id$    $Id$
 */  */
Line 10 Line 11
 #define PA_VALUE_H  #define PA_VALUE_H
   
 #include "pa_pool.h"  #include "pa_pool.h"
 #include "pa_exception.h"  
 #include "pa_string.h"  #include "pa_string.h"
 #include "pa_array.h"  #include "pa_array.h"
 //#include "pa_voperator.h"  #include "pa_exception.h"
   
   #define NAME_NAME "NAME"
   
 class Value;  class Value;
 class VClass;  class VClass;
 //class VOperator;  
 class Junction;  class Junction;
 class WContext;  class WContext;
   class VAliased;
   class Request;
   
   typedef void (*Native_code_ptr)(Request& request, Array *params);
   
 class Method : public Pooled {  class Method : public Pooled {
 public:  public:
         const String& name;          const String& name;
         Array& params_names;          // either numbered params // for native-code methods = operators
         Array& locals_names;          int min_numbered_params_count, max_numbered_params_count;
         Array& code;          // or named params&locals // for parser-code methods
           Array *params_names;  Array *locals_names;
           // the Code
           const Array *parser_code;/*OR*/Native_code_ptr native_code;
   
         Method(          Method(
                 Pool& apool,                  Pool& apool,
                 const String& aname,                  const String& aname,
                 Array& aparams_names,                  int amin_numbered_params_count, int amax_numbered_params_count,
                 Array& alocals_names,                  Array *aparams_names, Array *alocals_names,
                 Array& acode) :                   const Array *aparser_code, Native_code_ptr anative_code) : 
   
                 Pooled(apool),                  Pooled(apool),
                 name(aname),                  name(aname),
                 params_names(aparams_names),                  min_numbered_params_count(amin_numbered_params_count),
                 locals_names(alocals_names),                  max_numbered_params_count(amax_numbered_params_count),
                 code(acode) {                  params_names(aparams_names), locals_names(alocals_names),
                   parser_code(aparser_code), native_code(anative_code) {
         }          }
 };  
   
 /*          void check_actual_numbered_params(Array *actual_numbered_params) {
 class Operator : public Method {                  int actual_count=actual_numbered_params?actual_numbered_params->size():0;
         // operator module static vars stored in there                  if(actual_count<min_numbered_params_count) // not proper count? bark
         VOperator_class *self;                          THROW(0, 0,
                                   &name,
                                   "native method accepts minimum %d parameters", 
                                           min_numbered_params_count);
   
           }
 };  };
 */  
   
 class Method_ref {  class Junction : public Pooled {
 public:  public:
         Value *self;  
         Method& method;  
 };  
   
 class Junction {          Junction(Pool& apool,
         bool auto_calc;                  Value& aself,
         Value& root;                  VClass *avclass, Method *amethod,
         Value *self;                  Value *aroot,
         Value& rcontext;                  Value *arcontext,
         WContext& wcontext;                  WContext *awcontext,
         Array& code;                  const Array *acode) : Pooled(apool),
                   
                   self(aself),
                   vclass(avclass), method(amethod),
                   root(aroot),
                   rcontext(arcontext),
                   wcontext(awcontext),
                   code(acode) {
           }
   
           // always present
           Value& self;
           // either these // so called 'method-junction'
           VClass *vclass;  Method *method;
           // or these are present // so called 'code-junction'
           Value *root;
           Value *rcontext;
           WContext *wcontext;
           const Array *code;
 };  };
   
 class Value : public Pooled {  class Value : public Pooled {
Line 69  public: // Value Line 97  public: // Value
   
         // all: for error reporting after fail(), etc          // all: for error reporting after fail(), etc
         virtual const char *type() const =0;          virtual const char *type() const =0;
           String& name() const { return *fname; }
   
           // unknown: false
           // others: true
           virtual bool get_defined() { return true; }
           // string: fvalue as VDouble
           // bool: this
           // double: this
           // int: this
           virtual Value *get_expr_result() { failed("getting expression result of '%s'"); return 0; }
   
         // string: value          // string: value
         // unknown: ""          // unknown: ""
           // double: value
           // bool: must be 0: so in ^if(1>2) it would'nt become "FALSE" string which is 'true'
         // others: 0          // others: 0
         virtual String *get_string() { return 0; }          virtual String *get_string() { return 0; }
                   
         // string: value          // string: value
         virtual void put_string(String *astring) { failed("storing string to %s"); }          // double: value
           // integer: finteger
         // method_ref: self, method          // bool: value
         virtual Method_ref *get_method_ref() { failed("extracting method reference from %s"); return 0; }          virtual double get_double() { failed("getting numerical value of '%s'"); return 0; }
   
           // unknown: false
           // bool: value
           // double: 0 or !0
           // string: empty or not
           // hash: size!=0
           // TODO table: count!=0
           // others: true
           virtual bool get_bool() { return true; }
   
         // junction: auto_calc,root,self,rcontext,wcontext, code          // 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          // hash: (key)=value
         // object_class: (field)=STATIC.value;(STATIC)=hash;(method)=method_ref with self=object_class          // 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          // operator_class: (field)=value - static values only
         virtual Value *get_element(const String& name) { failed("getting element from %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          // hash: (key)=value
         // object_class, operator_class: (field)=value - static values only          // 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: (field)=value
           // codeframe: wcontext_transparent
         // object_instance, object_class: method          // methodframe: my or self_transparent
         virtual Method *get_method(const String& name) const { return 0; }          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          // object_class, object_instance: object_class
           // wcontext: none yet | transparent
         virtual VClass *get_class() { return 0; }          virtual VClass *get_class() { return 0; }
   
         // object_class: true when this class is this or derived from 'ancestor'          // valiased: this
         virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of %s"); return false; }          // wcontext: transparent
           // methodframe: self_transparent
           virtual VAliased *get_aliased() { return 0; }
   
 public: // usage  public: // usage
   
         Value(Pool& apool) : Pooled(apool) {}          Value(Pool& apool) : Pooled(apool), fname(new(apool) String(apool)) {
                   fname->APPEND_CONST("unnamed");
           }
   
           void set_name(String& aname) { fname=&aname; }
   
         operator String() {           String& as_string() {
                 String *result=get_string();                   String *result=get_string(); 
                 if(!result)                  if(!result)
                         failed("getting string of %s");                          failed("getting string of '%s'");
                 return *result;                  return *result;
         }          }
   
   private:
   
           String *fname;
   
 private:   private: 
   
         void failed(char *action) {          void failed(char *action) const;
                 THROW(0,0,  
                         0,  
                         action, type());  
         }  
 };  };
   
 /*  
 descendants:  
         text:+ value:String  
     hash:+ keys&values:Hash  
     table:+ columns_order:Array, columns:Hash, rows:Array  
     object_class:+ STATIC:Hash, methods:Hash  
     object_instance:+ object_class, fields:Hash  
     method_ref:+ self:Value/object_class, method:String  
     method_self_n_params_n_locals:+ self:Value/object_class[1st try], params_locals&values:Hash[2nd try]  
         junction:+ self:Value, code:String  
 */  
   
 #endif  #endif

Removed from v.1.17  
changed lines
  Added in v.1.48


E-mail: