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

1.1       paf         1: /*
1.5     ! paf         2:   $Id: pa_vframe.h,v 1.4 2001/02/24 08:28:35 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) {
1.4       paf        41:                if(Method* method=junction.method) { // method junction?
                     42:                        // remember local var names
                     43:                        // those are flags that name is local == to be looked up in 'my'
                     44:                        for(int i=0; i<method->locals_names.size(); i++) {
                     45:                                my.put(
                     46:                                        *static_cast<String *>(method->locals_names.get(i)), 
                     47:                                        NEW VUnknown(pool()));
                     48:                        }
1.1       paf        49:                }
                     50:        }
                     51: 
                     52:        void set_self(Value *aself) { self=aself; }
                     53: 
                     54:        void store_param(Value *value) {
1.4       paf        55:                Method *method=junction.method;
                     56:                if(store_param_index==method->params_names.size())
1.1       paf        57:                        THROW(0,0,
                     58:                                name(),
1.4       paf        59:                                "call: too many params (max=%d)", method->params_names.size());
1.1       paf        60:                
1.4       paf        61:                my.put(*static_cast<String *>(method->params_names.get(store_param_index++)), value);
1.1       paf        62:        }
1.4       paf        63:        void fill_empty_params() {
                     64:                Method *method=junction.method;
1.5     ! paf        65:                for(; store_param_index<method->params_names.size(); store_param_index++)
1.4       paf        66:                        my.put(
                     67:                                *static_cast<String *>(method->params_names.get(store_param_index)), 
                     68:                                NEW VUnknown(pool()));
1.1       paf        69:        }
                     70: 
                     71: public:
                     72:        
1.3       paf        73:        const Junction& junction;
1.1       paf        74: 
                     75: private:
                     76:        int store_param_index;
                     77:        Hash my;
                     78:        Value *self;
                     79: 
                     80: };
                     81: 
                     82: #endif

E-mail: