|
|
| version 1.17, 2001/03/08 15:32:51 | 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 40 public: // usage | Line 42 public: // usage |
| junction(ajunction), | junction(ajunction), |
| store_param_index(0), | store_param_index(0), |
| my(0), fself(0) { | my(0), fnumbered_params(0), |
| fself(0) { | |
| Method &method=*junction.method; | Method &method=*junction.method; |
| if(method.numbered_params_count) // are this method params numbered? | if(method.max_numbered_params_count) // are this method params numbered? |
| fnumbered_params=NEW Array(pool()); // create storage | fnumbered_params=NEW Array(pool()); // create storage |
| else // named params | else // named params |
| my=NEW Hash(pool()); // create storage | my=NEW Hash(pool()); // create storage |
| Line 55 public: // usage | Line 58 public: // usage |
| for(int i=0; i<method.locals_names->size(); i++) { | for(int i=0; i<method.locals_names->size(); i++) { |
| Value *value=NEW VUnknown(pool()); | Value *value=NEW VUnknown(pool()); |
| String& name=*static_cast<String *>(method.locals_names->get(i)); | String& name=*static_cast<String *>(method.locals_names->get(i)); |
| value->set_name(name); | |
| my->put(name, value); | my->put(name, value); |
| value->set_name(name); | |
| } | } |
| } | } |
| } | } |
| Line 66 public: // usage | Line 69 public: // usage |
| void store_param(Value *value) { | void store_param(Value *value) { |
| Method& method=*junction.method; | Method& method=*junction.method; |
| int max_params= | int max_params= |
| method.numbered_params_count?method.numbered_params_count: | method.max_numbered_params_count?method.max_numbered_params_count: |
| method.params_names?method.params_names->size(): | method.params_names?method.params_names->size(): |
| 0; | 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); |
| if(method.numbered_params_count) { // are this method params numbered? | if(method.max_numbered_params_count) { // are this method params numbered? |
| *fnumbered_params+=value; | *fnumbered_params+=value; |
| } else { // named params | } else { // named param |
| String& name=*static_cast<String *>( | String& name=*static_cast<String *>( |
| method.params_names->get(store_param_index++)); | method.params_names->get(store_param_index++)); |
| my->put(name, value); | my->put(name, value); // remember param |
| value->set_name(name); | value->set_name(name); // set param's 'name' |
| } | } |
| } | } |
| void fill_unspecified_params() { | void fill_unspecified_params() { |
| Method &method=*junction.method; | Method &method=*junction.method; |
| if(method.numbered_params_count) { // are this method params numbered? | if(method.params_names) // there are any named parameters might need filling? |
| for(; store_param_index<method.numbered_params_count; store_param_index++) { | for(; store_param_index<method.params_names->size(); store_param_index++) { |
| Value *value=NEW VUnknown(pool()); | Value *value=NEW VUnknown(pool()); |
| //value->set_name(/*"Param#" . store_param_index*/); | String& name=*static_cast<String *>( |
| *fnumbered_params+=value; | method.params_names->get(store_param_index)); |
| my->put(name, value); | |
| value->set_name(name); | |
| } | } |
| } else { // named params | |
| if(method.params_names) // there are any parameters might need filling? | |
| for(; store_param_index<method.params_names->size(); store_param_index++) { | |
| Value *value=NEW VUnknown(pool()); | |
| String& name=*static_cast<String *>(method.params_names->get(store_param_index)); | |
| value->set_name(name); | |
| my->put(name, value); | |
| } | |
| } | |
| } | } |
| Array& numbered_params() { return *fnumbered_params; } | Array *numbered_params() { return fnumbered_params; } |
| public: | public: |