|
|
| version 1.40, 2001/03/07 11:14:11 | version 1.48, 2001/03/09 08:19:47 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| $Id$ | $Id$ |
| */ | */ |
| Line 12 | Line 13 |
| #include "pa_pool.h" | #include "pa_pool.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" | #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 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; |
| const 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, |
| const 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 Junction : public Pooled { | class Junction : public Pooled { |
| public: | public: |
| Line 71 public: | Line 81 public: |
| code(acode) { | code(acode) { |
| } | } |
| // always present | |
| Value& self; | Value& self; |
| // either these // so called 'method-junction' | |
| VClass *vclass; Method *method; | VClass *vclass; Method *method; |
| // or these are present // so called 'code-junction' | |
| Value *root; | Value *root; |
| Value *rcontext; | Value *rcontext; |
| WContext *wcontext; | WContext *wcontext; |
| Line 84 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; |
| /*const*/ String& name() const { return *fname; } | String& name() const { return *fname; } |
| // unknown: false | // unknown: false |
| // others: true | // others: true |
| virtual bool get_defined() { return 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 | // 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 |
| // double: value | // double: value |
| // integer: finteger | |
| // bool: value | // bool: value |
| virtual double get_double() { failed("getting numerical value of '%s'"); return 0; } | virtual double get_double() { failed("getting numerical value of '%s'"); return 0; } |
| Line 158 private: | Line 178 private: |
| 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 | #endif |