Annotation of parser3/src/include/pa_vframe.h, revision 1.3

1.1       paf         1: /*
1.3     ! paf         2:   $Id: pa_vframe.h,v 1.2 2001/02/23 18:12:44 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef PA_VFRAME_H
                      6: #define PA_VFRAME_H
                      7: 
                      8: #include "pa_wcontext.h"
                      9: #include "pa_vunknown.h"
                     10: 
                     11: class VFrame : public WContext {
                     12: public: // Value
                     13: 
                     14:        // all: for error reporting after fail(), etc
                     15:        const char *type() const { return "VFrame"; }
                     16:        // frame: my or self_transparent
                     17:        Value *get_element(const String& name) { 
                     18:                Value *result=static_cast<Value *>(my.get(name));
                     19:                if(!result)
                     20:                        result=self->get_element(name);
                     21:                return result; 
                     22:        }
                     23:        // frame: my or self_transparent
                     24:        void put_element(const String& name, Value *value){ 
                     25:                if(!my.replace(name, value))
                     26:                        self->put_element(name, value);
                     27:        }
                     28: 
                     29:        // frame: none yet | transparent
                     30:        VClass *get_class() const { return self->get_class(); }
                     31:        // frame: none yet | transparent
                     32:        bool is_or_derived_from(VClass& ancestor) { return self->is_or_derived_from(ancestor); }
                     33: 
                     34: public: // usage
                     35: 
1.3     ! paf        36:        VFrame(Pool& apool, const Junction& ajunction) : WContext(apool, 0 /* empty */),
        !            37:                junction(ajunction),
1.1       paf        38:                store_param_index(0),
                     39:                my(apool),
                     40:                self(0) {
                     41:                // those are flags that name is local == to be looked up in 'my'
1.3     ! paf        42:                for(int i=0; i<junction.method->locals_names.size(); i++) {
1.1       paf        43:                        my.put(
1.3     ! paf        44:                                *static_cast<String *>(junction.method->locals_names.get(i)), 
1.1       paf        45:                                NEW VUnknown(pool()));
                     46:                }
                     47:        }
                     48: 
                     49:        void set_self(Value *aself) { self=aself; }
                     50: 
                     51:        void store_param(Value *value) {
                     52:                if(params_filled())
                     53:                        THROW(0,0,
                     54:                                name(),
1.3     ! paf        55:                                "call: too many params (max=%d)", junction.method->params_names.size());
1.1       paf        56:                
1.3     ! paf        57:                my.put(*static_cast<String *>(junction.method->params_names.get(store_param_index++)), value);
1.1       paf        58:        }
                     59:        bool params_filled() {
1.3     ! paf        60:                return store_param_index==junction.method->params_names.size();
1.1       paf        61:        }
                     62: 
                     63: public:
                     64:        
1.3     ! paf        65:        const Junction& junction;
1.1       paf        66: 
                     67: private:
                     68:        int store_param_index;
                     69:        Hash my;
                     70:        Value *self;
                     71: 
                     72: };
                     73: 
                     74: #endif

E-mail: