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

1.1       paf         1: /*
1.8     ! paf         2:   $Id: pa_vmframe.h,v 1.7 2001/02/25 17:33:43 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.8     ! paf        33:        // methodframe: self_transparent
        !            34:        Value *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:                
                     65:                my.put(*static_cast<String *>(method->params_names.get(store_param_index++)), value);
                     66:        }
                     67:        void fill_unspecified_params() {
                     68:                Method *method=junction.method;
                     69:                for(; store_param_index<method->params_names.size(); store_param_index++)
                     70:                        my.put(
                     71:                                *static_cast<String *>(method->params_names.get(store_param_index)), 
                     72:                                NEW VUnknown(pool()));
                     73:        }
                     74: 
                     75: public:
                     76:        
                     77:        const Junction& junction;
                     78: 
                     79: private:
                     80:        int store_param_index;
                     81:        Hash my;
1.7       paf        82:        Value *self;
1.1       paf        83: 
                     84: };
                     85: 
                     86: #endif

E-mail: