|
|
| version 1.15, 2001/03/08 12:19:20 | version 1.22, 2001/03/09 08:28:33 |
|---|---|
| Line 16 public: // Value | Line 16 public: // Value |
| const char *type() const { return "method_frame"; } | const char *type() const { return "method_frame"; } |
| // frame: my or self_transparent | // frame: my or self_transparent |
| Value *get_element(const String& name) { | Value *get_element(const String& name) { |
| Value *result=static_cast<Value *>(my.get(name)); | if(my) { |
| if(!result) | Value *result=static_cast<Value *>(my->get(name)); |
| result=fself->get_element(name); | if(result) |
| return result; | return result; |
| } | |
| return fself->get_element(name); | |
| } | } |
| // frame: my or self_transparent | // frame: my or self_transparent |
| void put_element(const String& name, Value *value){ | void put_element(const String& name, Value *value){ |
| if(!my.put_replace(name, value)) | if(!(my && my->put_replace(name, value))) |
| fself->put_element(name, value); | fself->put_element(name, value); |
| } | } |
| Line 35 public: // Value | Line 37 public: // Value |
| public: // usage | public: // usage |
| VMethodFrame(Pool& apool, const Junction& ajunction) : | VMethodFrame(Pool& apool, const Junction& ajunction/*info: always method-junction*/) : |
| WContext(apool, 0 /* empty */, false /* not constructing */), | WContext(apool, 0 /* empty */, false /* not constructing */), |
| junction(ajunction), | junction(ajunction), |
| store_param_index(0), | store_param_index(0), |
| my(apool), | my(0), fnumbered_params(0), |
| fself(0) { | fself(0) { |
| if(Method* method=junction.method) { // method junction? | |
| if(method->locals_names) { // there are any local var names? | Method &method=*junction.method; |
| // remember them | |
| // those are flags that name is local == to be looked up in 'my' | if(method.max_numbered_params_count) // are this method params numbered? |
| for(int i=0; i<method->locals_names->size(); i++) { | fnumbered_params=NEW Array(pool()); // create storage |
| my.put( | else // named params |
| *static_cast<String *>(method->locals_names->get(i)), | my=NEW Hash(pool()); // create storage |
| NEW VUnknown(pool())); | |
| } | if(method.locals_names) { // there are any local var names? |
| // remember them | |
| // those are flags that name is local == to be looked up in 'my' | |
| for(int i=0; i<method.locals_names->size(); i++) { | |
| Value *value=NEW VUnknown(pool()); | |
| String& name=*static_cast<String *>(method.locals_names->get(i)); | |
| my->put(name, value); | |
| value->set_name(name); | |
| } | } |
| } | } |
| } | } |
| Line 58 public: // usage | Line 67 public: // usage |
| void set_self(Value& aself) { fself=&aself; } | void set_self(Value& aself) { fself=&aself; } |
| void store_param(Value *value) { | void store_param(Value *value) { |
| Method *method=junction.method; | Method& method=*junction.method; |
| int max_params=method->params_names?method->params_names->size():0; | int max_params= |
| method.max_numbered_params_count?method.max_numbered_params_count: | |
| method.params_names?method.params_names->size(): | |
| 0; | |
| if(store_param_index==max_params) | if(store_param_index==max_params) |
| THROW(0,0, | THROW(0,0, |
| &junction.self.name(), | &junction.self.name(), |
| "%s method '%s' accepts maximum %d parameters", | "(%s) method '%s' accepts maximum %d parameter(s)", |
| junction.self.type(), | junction.self.type(), |
| method->name.cstr(), | method.name.cstr(), |
| max_params); | max_params); |
| String& name=*static_cast<String *>(method->params_names->get(store_param_index++)); | if(method.max_numbered_params_count) { // are this method params numbered? |
| my.put(name, value); | *fnumbered_params+=value; |
| value->set_name(name); | } else { // named param |
| String& name=*static_cast<String *>( | |
| method.params_names->get(store_param_index++)); | |
| my->put(name, value); // remember param | |
| value->set_name(name); // set param's 'name' | |
| } | |
| } | } |
| void fill_unspecified_params() { | void fill_unspecified_params() { |
| Array *params_names=junction.method->params_names; | Method &method=*junction.method; |
| if(params_names) // there are any parameters might need filling? | if(method.params_names) // there are any named parameters might need filling? |
| for(; store_param_index<params_names->size(); store_param_index++) | for(; store_param_index<method.params_names->size(); store_param_index++) { |
| my.put( | Value *value=NEW VUnknown(pool()); |
| *static_cast<String *>(params_names->get(store_param_index)), | String& name=*static_cast<String *>( |
| NEW VUnknown(pool())); | method.params_names->get(store_param_index)); |
| my->put(name, value); | |
| value->set_name(name); | |
| } | |
| } | } |
| Array *numbered_params() { return fnumbered_params; } | |
| public: | public: |
| const Junction& junction; | const Junction& junction; |
| private: | private: |
| int store_param_index; | int store_param_index; |
| Hash my; | Hash *my;/*OR*/Array *fnumbered_params; |
| Value *fself; | Value *fself; |
| }; | }; |