Annotation of parser3/src/types/pa_vstateless_class.C, revision 1.19.2.1
1.8 paf 1: /** @file
2: Parser: stateless class.
3:
1.19 paf 4: Copyright (c) 2001, 2003 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.19.2.1! paf 8: static const char* IDENT_VSTATELESS_CLASS_C="$Date: 2003/01/21 15:51:20 $";
1.2 paf 9:
10: #include "pa_vstateless_class.h"
1.19.2.1! paf 11: #include "pa_value_includes.h"
1.17 paf 12:
1.19.2.1! paf 13: void VStateless_class::add_method(ConstStringPtr name, MethodPtr method) {
! 14: if(flocked)
1.17 paf 15: throw Exception("parser.runtime",
1.19.2.1! paf 16: name,
1.17 paf 17: "can not add method to system class (maybe you have forgotten .CLASS in ^process[$caller.CLASS]{...}?)");
1.19.2.1! paf 18:
! 19: put_method(name, method);
1.17 paf 20: }
1.2 paf 21:
22: void VStateless_class::add_native_method(
23: const char *cstr_name,
1.7 paf 24: Method::Call_type call_type,
1.19.2.1! paf 25: NativeCodePtr native_code,
1.2 paf 26: int min_numbered_params_count, int max_numbered_params_count) {
27:
1.19.2.1! paf 28: StringPtr name(new String(cstr_name));
1.2 paf 29:
1.19.2.1! paf 30: MethodPtr method(new Method(
1.2 paf 31: name,
1.7 paf 32: call_type,
1.2 paf 33: min_numbered_params_count, max_numbered_params_count,
1.19.2.1! paf 34: ArrayConstStringPtr(0)/*params_names*/, ArrayConstStringPtr(0)/*locals_names*/,
! 35: ArrayOperationPtr(0)/*parser_code*/, native_code
! 36: ));
1.2 paf 37: add_method(name, method);
1.16 paf 38: }
39:
40: /// VStateless_class: $CLASS, $method
1.19.2.1! paf 41: ValuePtr VStateless_class::get_element(ConstStringPtr aname, Value& aself, bool looking_up) {
1.16 paf 42: // $CLASS
1.19.2.1! paf 43: if(*aname==CLASS_NAME)
1.16 paf 44: return this;
45:
46: // $method=junction(self+class+method)
1.19.2.1! paf 47: if(Method *method=get_method(aname))
! 48: return ValuePtr(
! 49: new VJunction(
! 50: JunctionPtr(
! 51: new Junction(aself, method, 0, 0, 0, ArrayOperationPtr(0)))));
1.18 paf 52:
53: // base monkey
1.16 paf 54: if(fbase)
1.19.2.1! paf 55: if(ValuePtr lbase=aself.base()) // one check would be enough...
1.18 paf 56: return fbase->get_element(aname, *lbase, looking_up);
57:
1.16 paf 58: return 0;
1.2 paf 59: }
E-mail: