Annotation of parser3/src/include/pa_vframe.h, revision 1.1
1.1 ! paf 1: /*
! 2: $Id: pa_frame.h,v 1.11 2001/02/23 12:47:08 paf Exp $
! 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: transparent
! 30: Method *get_method(const String& name) const { return self->get_method(name); }
! 31: // frame: none yet | transparent
! 32: VClass *get_class() const { return self->get_class(); }
! 33: // frame: none yet | transparent
! 34: bool is_or_derived_from(VClass& ancestor) { return self->is_or_derived_from(ancestor); }
! 35:
! 36: public: // usage
! 37:
! 38: VFrame(Pool& apool, Method& amethod) : WContext(apool, 0 /* empty */),
! 39: method(amethod),
! 40: store_param_index(0),
! 41: my(apool),
! 42: self(0) {
! 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: }
! 49: }
! 50:
! 51: void set_self(Value *aself) { self=aself; }
! 52:
! 53: void store_param(Value *value) {
! 54: if(params_filled())
! 55: THROW(0,0,
! 56: name(),
! 57: "call: too many params (max=%d)", method.params_names.size());
! 58:
! 59: my.put(*static_cast<String *>(method.params_names.get(store_param_index++)), value);
! 60: }
! 61: bool params_filled() {
! 62: return store_param_index==method.params_names.size();
! 63: }
! 64:
! 65: public:
! 66:
! 67: const Method& method;
! 68:
! 69: private:
! 70: int store_param_index;
! 71: Hash my;
! 72: Value *self;
! 73:
! 74: };
! 75:
! 76: #endif
E-mail: