|
|
1.1 paf 1: /*
1.2 ! paf 2: $Id: pa_vframe.h,v 1.1 2001/02/23 17:12:57 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:
36: VFrame(Pool& apool, Method& amethod) : WContext(apool, 0 /* empty */),
37: method(amethod),
38: store_param_index(0),
39: my(apool),
40: self(0) {
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: void set_self(Value *aself) { self=aself; }
50:
51: void store_param(Value *value) {
52: if(params_filled())
53: THROW(0,0,
54: name(),
55: "call: too many params (max=%d)", method.params_names.size());
56:
57: my.put(*static_cast<String *>(method.params_names.get(store_param_index++)), value);
58: }
59: bool params_filled() {
60: return store_param_index==method.params_names.size();
61: }
62:
63: public:
64:
65: const Method& method;
66:
67: private:
68: int store_param_index;
69: Hash my;
70: Value *self;
71:
72: };
73:
74: #endif