Annotation of parser3/src/types/pa_vmethod_frame.C, revision 1.17
1.2 paf 1: /** @file
2: Parser: method frame class.
3:
1.10 misha 4: Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)\
6: */
7:
1.17 ! misha 8: static const char * const IDENT_VSTATELESS_CLASS_C="$Date: 2009-06-17 01:08:55 $";
1.2 paf 9:
10: #include "pa_vmethod_frame.h"
11: #include "pa_request.h"
12:
13: // globals
14:
1.15 misha 15: const String result_var_name(RESULT_VAR_NAME), caller_element_name(CALLER_ELEMENT_NAME), self_element_name(SELF_ELEMENT_NAME);
1.14 misha 16: VVoid void_result; // unique value to be sure the result is changed
1.2 paf 17:
18: // MethodParams: methods
19:
1.7 paf 20: Value& MethodParams::get_processed(Value* value, const char* msg, int index, Request& r) {
21: return r.process_to_value(as_junction(value, msg, index), false /*do not intercept string*/);
1.2 paf 22: }
23:
24: // VMethodFrame: methods
25:
26: VMethodFrame::VMethodFrame(
27: const Junction& ajunction/*info: always method-junction*/,
28: VMethodFrame *acaller) :
1.16 misha 29: WContext(0 /* no parent, junctions can be reattached only up to VMethodFrame */),
1.2 paf 30:
1.4 paf 31: fcaller(acaller),
1.2 paf 32:
1.12 misha 33: my(0),
1.2 paf 34: fself(0),
35:
1.4 paf 36: junction(ajunction) {
1.2 paf 37:
1.9 misha 38: put_element_impl=(junction.method->all_vars_local)?&VMethodFrame::put_element_local:&VMethodFrame::put_element_global;
39:
1.12 misha 40: if(!junction.method->max_numbered_params_count){ // this method uses numbered params?
1.17 ! misha 41: my=new HashString<Value*>;
1.2 paf 42:
43: const Method &method=*junction.method;
44: if(method.locals_names) { // are there any local var names?
45: // remember them
46: // those are flags that fname is local == to be looked up in 'my'
47: for(Array_iterator<const String*> i(*method.locals_names); i.has_next(); ) {
48: // speedup: not checking for clash with "result" fname
49: const String& fname=*i.next();
1.10 misha 50: set_my_variable(fname, *VVoid::get());
1.2 paf 51: }
52: }
1.14 misha 53: #ifdef OPTIMIZE_RESULT
54: if(junction.method->result_optimization!=Method::RO_USE_WCONTEXT)
55: #endif
56: set_my_variable(result_var_name, void_result);
1.2 paf 57: }
58: }
59:
60: Value* VMethodFrame::get_result_variable() {
1.11 misha 61: if(!my)
62: return 0;
63:
1.15 misha 64: Value* result=my->get(result_var_name);
1.14 misha 65: return result!=&void_result?result:0;
1.2 paf 66: }
E-mail: