Annotation of parser3/src/include/pa_vmframe.h, revision 1.5
1.1 paf 1: /*
1.5 ! paf 2: $Id: pa_vmframe.h,v 1.4 2001/02/25 13:23:01 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
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){
1.4 paf 26: if(!my.put_replace(name, value))
1.1 paf 27: self->put_element(name, value);
28: }
29:
30: public: // usage
31:
1.5 ! paf 32: VMethodFrame(Pool& apool, const Junction& ajunction) :
! 33: WContext(apool, 0 /* empty */, false /* not constructing */),
! 34:
1.1 paf 35: junction(ajunction),
36: store_param_index(0),
37: my(apool),
38: self(0) {
39: if(Method* method=junction.method) { // method junction?
40: // remember local var names
41: // those are flags that name is local == to be looked up in 'my'
42: for(int i=0; i<method->locals_names.size(); i++) {
43: my.put(
44: *static_cast<String *>(method->locals_names.get(i)),
45: NEW VUnknown(pool()));
46: }
47: }
48: }
49:
50: void set_self(Value *aself) { self=aself; }
51:
52: void store_param(Value *value) {
53: Method *method=junction.method;
54: if(store_param_index==method->params_names.size())
55: THROW(0,0,
1.4 paf 56: &name(),
1.1 paf 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: void fill_unspecified_params() {
62: Method *method=junction.method;
63: for(; store_param_index<method->params_names.size(); store_param_index++)
64: my.put(
65: *static_cast<String *>(method->params_names.get(store_param_index)),
66: NEW VUnknown(pool()));
67: }
68:
69: public:
70:
71: const Junction& junction;
72:
73: private:
74: int store_param_index;
75: Hash my;
76: Value *self;
77:
78: };
79:
80: #endif
E-mail: