Annotation of parser3/src/types/pa_vstateless_class.C, revision 1.17.4.1
1.8 paf 1: /** @file
2: Parser: stateless class.
3:
1.12 paf 4: Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.13 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)\
1.14 paf 6: */
1.8 paf 7:
1.17.4.1! paf 8: static const char* IDENT_VSTATELESS_CLASS_C="$Date: 2002/10/15 10:05:01 $";
1.2 paf 9:
10: #include "pa_vstateless_class.h"
11: #include "pa_vstring.h"
1.17 paf 12:
13: void VStateless_class::add_method(const String& name, Method& method) {
14: if(&pool()!=&name.pool())
15: throw Exception("parser.runtime",
16: &name,
17: "can not add method to system class (maybe you have forgotten .CLASS in ^process[$caller.CLASS]{...}?)");
18: put_method(name, &method);
19: }
1.2 paf 20:
21: void VStateless_class::add_native_method(
22: const char *cstr_name,
1.7 paf 23: Method::Call_type call_type,
1.2 paf 24: Native_code_ptr native_code,
25: int min_numbered_params_count, int max_numbered_params_count) {
26:
1.4 paf 27: String& name=*NEW String(pool(), cstr_name);
1.2 paf 28:
29: Method& method=*NEW Method(pool(),
30: name,
1.7 paf 31: call_type,
1.2 paf 32: min_numbered_params_count, max_numbered_params_count,
33: 0/*params_names*/, 0/*locals_names*/,
34: 0/*parser_code*/, native_code
35: );
36: add_method(name, method);
1.16 paf 37: }
38:
39: /// VStateless_class: $CLASS, $method
1.17.4.1! paf 40: Value *VStateless_class::get_element(const String& aname, Value& aself, bool looking_up) {
! 41: // gets element from last_derivate upwards
! 42: if(!looking_up) {
! 43: // $CLASS
! 44: if(aname==CLASS_NAME)
! 45: return get_class();
! 46:
! 47: // for first call, pass call to last derived
! 48: return get_last_derived().get_element(aname, aself.get_last_derived(), true/*one of two users*/);
! 49: }
! 50:
! 51: // $method
! 52: {
! 53: // $method=junction(self+class+method)
! 54: if(Method *method=static_cast<Method *>(fmethods.get(aname)))
! 55: return new(aname.pool()) VJunction(
! 56: *new(aname.pool()) Junction(aname.pool(), aself, method, 0,0,0,0));
! 57: }
! 58:
! 59: // up the tree...
1.16 paf 60: if(fbase)
1.17.4.1! paf 61: if(Value *result=fbase->get_element(aname, * /*must have base too*/aself.base(), true))
! 62: return result;
! 63:
1.16 paf 64: return 0;
1.2 paf 65: }
E-mail: