Annotation of parser3/src/include/pa_vmframe.h, revision 1.15
1.1 paf 1: /*
1.15 ! paf 2: $Id: pa_vmframe.h,v 1.14 2001/03/08 12:13:35 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
1.11 paf 16: const char *type() const { return "method_frame"; }
1.1 paf 17: // frame: my or self_transparent
1.13 paf 18: Value *get_element(const String& name) {
1.1 paf 19: Value *result=static_cast<Value *>(my.get(name));
20: if(!result)
1.15 ! paf 21: result=fself->get_element(name);
1.1 paf 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.15 ! paf 27: fself->put_element(name, value);
1.1 paf 28: }
29:
1.6 paf 30: // frame: self_transparent
1.15 ! paf 31: VClass* get_class() { return fself->get_class(); }
1.6 paf 32:
1.8 paf 33: // methodframe: self_transparent
1.15 ! paf 34: VAliased *get_aliased() { return fself->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),
1.15 ! paf 44: fself(0) {
1.1 paf 45: if(Method* method=junction.method) { // method junction?
1.14 paf 46: if(method->locals_names) { // there are any local var names?
47: // remember them
48: // those are flags that name is local == to be looked up in 'my'
49: for(int i=0; i<method->locals_names->size(); i++) {
50: my.put(
51: *static_cast<String *>(method->locals_names->get(i)),
52: NEW VUnknown(pool()));
53: }
1.1 paf 54: }
55: }
56: }
57:
1.15 ! paf 58: void set_self(Value& aself) { fself=&aself; }
1.1 paf 59:
60: void store_param(Value *value) {
61: Method *method=junction.method;
1.14 paf 62: int max_params=method->params_names?method->params_names->size():0;
63: if(store_param_index==max_params)
1.1 paf 64: THROW(0,0,
1.12 paf 65: &junction.self.name(),
66: "%s method '%s' accepts maximum %d parameters",
67: junction.self.type(),
68: method->name.cstr(),
1.14 paf 69: max_params);
1.1 paf 70:
1.14 paf 71: String& name=*static_cast<String *>(method->params_names->get(store_param_index++));
1.10 paf 72: my.put(name, value);
73: value->set_name(name);
1.1 paf 74: }
75: void fill_unspecified_params() {
1.14 paf 76: Array *params_names=junction.method->params_names;
77: if(params_names) // there are any parameters might need filling?
78: for(; store_param_index<params_names->size(); store_param_index++)
79: my.put(
80: *static_cast<String *>(params_names->get(store_param_index)),
81: NEW VUnknown(pool()));
1.1 paf 82: }
83:
84: public:
85:
86: const Junction& junction;
87:
88: private:
89: int store_param_index;
90: Hash my;
1.15 ! paf 91: Value *fself;
1.1 paf 92:
93: };
94:
95: #endif
E-mail: