Annotation of parser3/src/types/pa_vmethod_frame.C, revision 1.14

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.14    ! misha       8: static const char * const IDENT_VSTATELESS_CLASS_C="$Date: 2009-04-29 03:27:08 $";
1.2       paf         9: 
                     10: #include "pa_vmethod_frame.h"
                     11: #include "pa_request.h"
                     12: 
                     13: // globals
                     14: 
                     15: const String result_var_name(RESULT_VAR_NAME);
1.11      misha      16: const uint result_var_hash_code(hash_code(result_var_name));
1.14    ! misha      17: VVoid void_result; // unique value to be sure the result is changed
1.2       paf        18: 
                     19: // MethodParams: methods
                     20: 
1.7       paf        21: Value& MethodParams::get_processed(Value* value, const char* msg, int index, Request& r) {
                     22:                return r.process_to_value(as_junction(value, msg, index), false /*do not intercept string*/);
1.2       paf        23: }
                     24: 
                     25: // VMethodFrame: methods
                     26: 
                     27: VMethodFrame::VMethodFrame(
                     28:        const Junction& ajunction/*info: always method-junction*/,
                     29:        VMethodFrame *acaller) : 
                     30:        WContext(0/*empty*/, 0 /* no parent, junctions can be reattached only up to VMethodFrame */),
                     31: 
1.4       paf        32:        fcaller(acaller),
1.2       paf        33: 
1.12      misha      34:        my(0),
1.2       paf        35:        fself(0),
                     36: 
1.4       paf        37:        junction(ajunction) {
1.2       paf        38: 
1.9       misha      39:        put_element_impl=(junction.method->all_vars_local)?&VMethodFrame::put_element_local:&VMethodFrame::put_element_global;
                     40: 
1.12      misha      41:        if(!junction.method->max_numbered_params_count){ // this method uses numbered params?
1.2       paf        42:                my=new HashStringValue;
                     43: 
                     44:                const Method &method=*junction.method;
                     45:                if(method.locals_names) { // are there any local var names?
                     46:                        // remember them
                     47:                        // those are flags that fname is local == to be looked up in 'my'
                     48:                        for(Array_iterator<const String*> i(*method.locals_names); i.has_next(); ) {
                     49:                                // speedup: not checking for clash with "result" fname
                     50:                                const String& fname=*i.next();
1.10      misha      51:                                set_my_variable(fname, *VVoid::get());
1.2       paf        52:                        }
                     53:                }
1.14    ! misha      54: #ifdef OPTIMIZE_RESULT
        !            55:                if(junction.method->result_optimization!=Method::RO_USE_WCONTEXT)
        !            56: #endif
        !            57:                        set_my_variable(result_var_name, void_result);
1.2       paf        58:        }
                     59: }
                     60: 
                     61: Value* VMethodFrame::get_result_variable() {
1.11      misha      62:        if(!my)
                     63:                return 0;
                     64: 
                     65:        Value* result=my->get_by_hash_code(result_var_hash_code, result_var_name);
1.14    ! misha      66:        return result!=&void_result?result:0;
1.2       paf        67: }

E-mail: