M method

MfuncTuple M(
  1. Uint8List candidbytes,
  2. CandidBytes_i start_i
)
override

Implementation

MfuncTuple M(Uint8List candidbytes, CandidBytes_i start_i) {
    late CandidBytes_i next_i;
    ServiceReference? service_value;
    Text? method_name_value;
    if (candidbytes[start_i] == 0) {
        next_i = start_i + 1;
    } else if (candidbytes[start_i] == 1) {
        MfuncTuple service_m_func_tuple = ServiceReference(isTypeStance: true, methods_types: {}).M(candidbytes, start_i + 1); // .M on a type-stance gives-back a with the istypestance=false
        service_value = service_m_func_tuple.item1 as ServiceReference;
        MfuncTuple method_name_text_m_func_tuple = Text().M(candidbytes, service_m_func_tuple.item2);
        method_name_value = method_name_text_m_func_tuple.item1 as Text;
        next_i = method_name_text_m_func_tuple.item2;
    }
    for (List<CandidType> types_list in [this.in_types, this.out_types]) {
        for(int i=0;i<types_list.length;i++) {
            if (types_list[i] is TypeTableReference) {
                types_list[i] = type_table_ference_as_a_type_stance(types_list[i] as TypeTableReference);
            }
        }
    }
    FunctionReference func_fer = FunctionReference(
        in_types: this.in_types,
        out_types: this.out_types,
        isQuery: this.isQuery,
        isOneWay: this.isOneWay,
        service: service_value,
        method_name: method_name_value
    );
    if (func_fer.service != null) {
        func_fer.service!.methods[func_fer.method_name!] = func_fer; // putting this function-reference as a method on this function_reference.service
    }
    return MfuncTuple(func_fer, next_i);
}