--- parser3/src/include/Attic/pa_value.h 2001/02/24 13:18:19 1.26 +++ parser3/src/include/Attic/pa_value.h 2001/03/10 16:34:35 1.50 @@ -1,5 +1,9 @@ /* - $Id: pa_value.h,v 1.26 2001/02/24 13:18:19 paf Exp $ + Parser + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan + + $Id: pa_value.h,v 1.50 2001/03/10 16:34:35 paf Exp $ */ /* @@ -12,64 +16,80 @@ #include "pa_pool.h" #include "pa_string.h" #include "pa_array.h" -//#include "pa_voperator.h" +#include "pa_exception.h" +#include "core.h" + +#define NAME_NAME "NAME" class Value; class VClass; -//class VOperator; class Junction; class WContext; +class VAliased; +class Request; + +typedef void (*Native_code_ptr)(Request& request, Array *params); class Method : public Pooled { public: const String& name; - Array& params_names; - Array& locals_names; - const Array& code; + // either numbered params // for native-code methods = operators + int min_numbered_params_count, max_numbered_params_count; + // 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( Pool& apool, const String& aname, - Array& aparams_names, - Array& alocals_names, - const Array& acode) : + int amin_numbered_params_count, int amax_numbered_params_count, + Array *aparams_names, Array *alocals_names, + const Array *aparser_code, Native_code_ptr anative_code) : Pooled(apool), name(aname), - params_names(aparams_names), - locals_names(alocals_names), - code(acode) { + min_numbered_params_count(amin_numbered_params_count), + max_numbered_params_count(amax_numbered_params_count), + params_names(aparams_names), locals_names(alocals_names), + parser_code(aparser_code), native_code(anative_code) { } -}; -/* -class Operator : public Method { - // operator module static vars stored in there - VOperator_class *self; + void check_actual_numbered_params(Array *actual_numbered_params) { + int actual_count=actual_numbered_params?actual_numbered_params->size():0; + if(actual_count2) it would'nt become "FALSE" string which is 'true' // others: 0 - virtual String *get_string() { return 0; } + virtual const String *get_string() { return 0; } // string: value - virtual void put_string(String *astring) { failed("storing string to '%s'"); } + // double: value + // integer: finteger + // bool: value + 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 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 // codeframe: wcontext_transparent - virtual Value *get_element(const String& name) { failed("is '%s', can not get element from it"); return 0; } + // 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 // 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"); } + // 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 - // codeframe: 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 - // codeframe: wcontext_transparent - virtual bool is_or_derived_from(VClass& ancestor) { failed("thoghts of ancestors of '%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(unnamed_name) { + } void set_name(const String& aname) { fname=&aname; } - String& as_string() { - String *result=get_string(); + const String& as_string() { + const String *result=get_string(); if(!result) failed("getting string of '%s'"); return *result; @@ -142,19 +181,7 @@ private: private: - void failed(char *action); + void failed(char *action) const; }; -/* -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