Annotation of parser3/src/include/pa_vmframe.h, revision 1.11

1.1       paf         1: /*
1.11    ! paf         2:   $Id: pa_vmframe.h,v 1.10 2001/03/01 13:52:59 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef PA_VMFRAME_H
                      6: #define PA_VMFRAME_H
                      7: 
                      8: #include "pa_wcontext.h"
                      9: #include "pa_vunknown.h"
                     10: #include "pa_vjunction.h"
                     11: 
                     12: class VMethodFrame : public WContext {
                     13: public: // Value
                     14: 
                     15:        // all: for error reporting after fail(), etc
1.11    ! paf        16:        const char *type() const { return "method_frame"; }
1.1       paf        17:        // frame: my or self_transparent
                     18:        Value *get_element(const String& name) { 
                     19:                Value *result=static_cast<Value *>(my.get(name));
                     20:                if(!result)
                     21:                        result=self->get_element(name);
                     22:                return result; 
                     23:        }
                     24:        // frame: my or self_transparent
                     25:        void put_element(const String& name, Value *value){ 
1.4       paf        26:                if(!my.put_replace(name, value))
1.1       paf        27:                        self->put_element(name, value);
                     28:        }
                     29: 
1.6       paf        30:        // frame: self_transparent
                     31:        VClass* get_class() { return self->get_class(); }
                     32: 
1.8       paf        33:        // methodframe: self_transparent
1.9       paf        34:        VAliased *get_aliased() { return self->get_aliased(); }
1.7       paf        35: 
1.1       paf        36: public: // usage
                     37: 
1.5       paf        38:        VMethodFrame(Pool& apool, const Junction& ajunction) : 
                     39:                WContext(apool, 0 /* empty */, false /* not constructing */),
                     40: 
1.1       paf        41:                junction(ajunction),
                     42:                store_param_index(0),
                     43:                my(apool),
                     44:                self(0) {
                     45:                if(Method* method=junction.method) { // method junction?
                     46:                        // remember local var names
                     47:                        // those are flags that name is local == to be looked up in 'my'
                     48:                        for(int i=0; i<method->locals_names.size(); i++) {
                     49:                                my.put(
                     50:                                        *static_cast<String *>(method->locals_names.get(i)), 
                     51:                                        NEW VUnknown(pool()));
                     52:                        }
                     53:                }
                     54:        }
                     55: 
1.7       paf        56:        void set_self(Value& aself) { self=&aself; }
1.1       paf        57: 
                     58:        void store_param(Value *value) {
                     59:                Method *method=junction.method;
                     60:                if(store_param_index==method->params_names.size())
                     61:                        THROW(0,0,
1.4       paf        62:                                &name(),
1.1       paf        63:                                "call: too many params (max=%d)", method->params_names.size());
                     64:                
1.10      paf        65:                String& name=*static_cast<String *>(method->params_names.get(store_param_index++));
                     66:                my.put(name, value);
                     67:                value->set_name(name);
1.1       paf        68:        }
                     69:        void fill_unspecified_params() {
                     70:                Method *method=junction.method;
                     71:                for(; store_param_index<method->params_names.size(); store_param_index++)
                     72:                        my.put(
                     73:                                *static_cast<String *>(method->params_names.get(store_param_index)), 
                     74:                                NEW VUnknown(pool()));
                     75:        }
                     76: 
                     77: public:
                     78:        
                     79:        const Junction& junction;
                     80: 
                     81: private:
                     82:        int store_param_index;
                     83:        Hash my;
1.7       paf        84:        Value *self;
1.1       paf        85: 
                     86: };
                     87: 
                     88: #endif

E-mail: