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

1.1       paf         1: /*
1.6     ! paf         2:   $Id: pa_vmframe.h,v 1.5 2001/02/25 14:23:31 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
                     16:        const char *type() const { return "MethodFrame"; }
                     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.1       paf        33: public: // usage
                     34: 
1.5       paf        35:        VMethodFrame(Pool& apool, const Junction& ajunction) : 
                     36:                WContext(apool, 0 /* empty */, false /* not constructing */),
                     37: 
1.1       paf        38:                junction(ajunction),
                     39:                store_param_index(0),
                     40:                my(apool),
                     41:                self(0) {
                     42:                if(Method* method=junction.method) { // method junction?
                     43:                        // remember local var names
                     44:                        // those are flags that name is local == to be looked up in 'my'
                     45:                        for(int i=0; i<method->locals_names.size(); i++) {
                     46:                                my.put(
                     47:                                        *static_cast<String *>(method->locals_names.get(i)), 
                     48:                                        NEW VUnknown(pool()));
                     49:                        }
                     50:                }
                     51:        }
                     52: 
1.6     ! paf        53:        void set_self(VAliased& aself) { self=&aself; }
1.1       paf        54: 
                     55:        void store_param(Value *value) {
                     56:                Method *method=junction.method;
                     57:                if(store_param_index==method->params_names.size())
                     58:                        THROW(0,0,
1.4       paf        59:                                &name(),
1.1       paf        60:                                "call: too many params (max=%d)", method->params_names.size());
                     61:                
                     62:                my.put(*static_cast<String *>(method->params_names.get(store_param_index++)), value);
                     63:        }
                     64:        void fill_unspecified_params() {
                     65:                Method *method=junction.method;
                     66:                for(; store_param_index<method->params_names.size(); store_param_index++)
                     67:                        my.put(
                     68:                                *static_cast<String *>(method->params_names.get(store_param_index)), 
                     69:                                NEW VUnknown(pool()));
                     70:        }
                     71: 
                     72: public:
                     73:        
                     74:        const Junction& junction;
                     75: 
                     76: private:
                     77:        int store_param_index;
                     78:        Hash my;
1.6     ! paf        79:        VAliased *self;
1.1       paf        80: 
                     81: };
                     82: 
                     83: #endif

E-mail: