Annotation of parser3/src/include/pa_vmframe.h, revision 1.1
1.1 ! paf 1: /*
! 2: $Id: pa_vframe.h,v 1.5 2001/02/24 09:56:02 paf Exp $
! 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){
! 26: if(!my.replace(name, value))
! 27: self->put_element(name, value);
! 28: }
! 29:
! 30: // frame: none yet | transparent
! 31: VClass *get_class() const { return self->get_class(); }
! 32: // frame: none yet | transparent
! 33: bool is_or_derived_from(VClass& ancestor) { return self->is_or_derived_from(ancestor); }
! 34:
! 35: public: // usage
! 36:
! 37: VMethodFrame(Pool& apool, const Junction& ajunction) : WContext(apool, 0 /* empty */),
! 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:
! 53: void set_self(Value *aself) { self=aself; }
! 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,
! 59: name(),
! 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;
! 79: Value *self;
! 80:
! 81: };
! 82:
! 83: #endif
E-mail: