internal expression_node convert_typed_expression_to_function_call(typed_expression te)
        {
            delegated_methods dm = te.type as delegated_methods;
            if (dm == null)
            {
                return te;
            }
            base_function_call bfc = dm.empty_param_method;
            if (bfc == null)
            {
                return te;
            }
            if (bfc.type == null) 
            	return te;
            function_node fn = bfc.simple_function_node;
            common_namespace_function_node cnfn = fn as common_namespace_function_node;
            if ((fn.parameters.Count == 1 || cnfn != null && fn.parameters.Count == 2 && cnfn.ConnectedToType != null)
                && (fn.parameters[fn.parameters.Count - 1].is_params || fn.parameters[fn.parameters.Count - 1].default_value != null))
            {
                fn = convertion_data_and_alghoritms.select_function(bfc.parameters, new SymbolInfo(fn), bfc.location);
                if (fn.polymorphic_state == SemanticTree.polymorphic_state.ps_static || fn is common_namespace_function_node || fn is basic_function_node)
                    bfc = convertion_data_and_alghoritms.create_simple_function_call(fn, bfc.location, bfc.parameters.ToArray()) as base_function_call;
                else
                {
                    expression_node obj = null;
                    if (bfc is common_method_call)
                        obj = (bfc as common_method_call).obj;
                    else if (bfc is compiled_function_call)
                        obj = (bfc as compiled_function_call).obj;
                    bfc = convertion_data_and_alghoritms.create_method_call(fn, bfc.location, obj, bfc.parameters.ToArray()) as base_function_call;

                }   
            }
            else
            {
                function_node[] empty_param_methods = dm.empty_param_methods;
                SymbolInfo si = new SymbolInfo(empty_param_methods[0]);
                SymbolInfo root_si = si;
                for (int i = 1; i < empty_param_methods.Length; i++)
                {
                    si.Next = new SymbolInfo(empty_param_methods[i]);
                    si = si.Next;
                }
                compiled_function_node cfn = fn as compiled_function_node;
                if ((fn.parameters.Count == 1 || cfn != null && fn.parameters.Count == 2 && cfn.ConnectedToType != null)
                    && (fn.parameters[fn.parameters.Count - 1].is_params || fn.parameters[fn.parameters.Count - 1].default_value != null))
                {
                    fn = convertion_data_and_alghoritms.select_function(bfc.parameters, root_si, bfc.location);
                    bfc = create_static_method_call_with_params(fn, bfc.location, fn.return_value_type, true, bfc.parameters);
                }
                else if (fn.parameters.Count == 1 && cfn != null && cfn.ConnectedToType != null)
                {
                    fn = convertion_data_and_alghoritms.select_function(bfc.parameters, root_si, bfc.location);
                    bfc = create_static_method_call_with_params(fn, bfc.location, fn.return_value_type, true, bfc.parameters);
                }
            }
            return bfc;
        }
 internal typed_expression make_delegate_wrapper(expression_node obj, function_node func, location loc, bool is_static)
 {
     base_function_call_list fnl = create_possible_delegates_list(obj, func, loc, is_static);
     if (fnl.Count == 0)
     {
         if (is_static)
         {
             AddError(loc, "EXPECTED_STATIC_METHOD");
         }
         else
         {
             AddError(loc, "EXPECTED_NON_STATIC_METHOD");
         }
     }
     delegated_methods dm = new delegated_methods();
     dm.proper_methods.AddRange(fnl);
     typed_expression te = new typed_expression(dm, loc);
     return te;
 }
 public override void visit(SyntaxTree.ident_with_templateparams _ident_with_templateparams)
 {
     SyntaxTree.expression ex = _ident_with_templateparams.name;
     SyntaxTree.ident id_ex = _ident_with_templateparams.name as SyntaxTree.ident;
     dot_node dn = _ident_with_templateparams.name as dot_node;
     int par_count = _ident_with_templateparams.template_params.params_list.Count;
     if (id_ex != null)
     {
         SymbolInfo type_si = context.find(id_ex.name + compiler_string_consts.generic_params_infix + par_count.ToString());
         if (type_si != null)
         {
             return_value(get_generic_instance(type_si, _ident_with_templateparams.template_params.params_list));
             return;
         }
         type_si = context.find(id_ex.name);
         if (type_si != null && type_si.sym_info.general_node_type == general_node_type.template_type)
         {
             template_class tc = type_si.sym_info as template_class;
             List<type_node> tpars = visit_type_list(_ident_with_templateparams.template_params.params_list);
             return_value(instance_any(tc, tpars, get_location(_ident_with_templateparams)));
             return;
         }
     }
     else if (dn != null && dn.right is ident)
     {
         semantic_node sn = convert_semantic_strong(dn.left);
         id_ex = dn.right as SyntaxTree.ident;
         type_node tn = null;
         namespace_node nn = null;
         unit_node un = null;
         switch (sn.general_node_type)
         {
             case general_node_type.expression: tn = (sn as expression_node).type; break;
             case general_node_type.type_node: tn = sn as type_node; break;
             case general_node_type.namespace_node: nn = sn as namespace_node; break;
             case general_node_type.unit_node: un = sn as unit_node; break;
             default:
                 AddError(get_location(dn.left), "EXPECTED_ANOTHER_KIND_OF_OBJECT"); break;
         }
         SymbolInfo type_si = null;
         if (tn != null)
             type_si = tn.find_in_type(id_ex.name + compiler_string_consts.generic_params_infix + par_count.ToString());
         else if (nn != null)
             type_si = nn.find(id_ex.name + compiler_string_consts.generic_params_infix + par_count.ToString());
         else if (un != null)
             type_si = un.find_only_in_namespace(id_ex.name + compiler_string_consts.generic_params_infix + par_count.ToString());
         if (type_si != null)
         {
             return_value(get_generic_instance(type_si, _ident_with_templateparams.template_params.params_list));
             return;
         }
         if (tn != null)
             type_si = tn.find_in_type(id_ex.name);
         else if (nn != null)
             type_si = nn.find(id_ex.name);
         else if (un != null)
             type_si = un.find_only_in_namespace(id_ex.name);
         if (type_si != null && type_si.sym_info.general_node_type == general_node_type.template_type)
         {
             template_class tc = type_si.sym_info as template_class;
             List<type_node> tpars = visit_type_list(_ident_with_templateparams.template_params.params_list);
             return_value(instance_any(tc, tpars, get_location(_ident_with_templateparams)));
             return;
         }
     }
     expression_node adr = ret.visit(ex);
     typed_expression te = adr as typed_expression;
     if (te != null)
     {
         delegated_methods dm = te.type as delegated_methods;
         if (dm != null)
         {
             List<type_node> ptypes = visit_type_list(_ident_with_templateparams.template_params.params_list);
             base_function_call_list bfcl = new base_function_call_list();
             common_method_node cnode;
             compiled_function_node comp_node;
             function_node fnode;
             int generic_count = 0;
             foreach (base_function_call bfc in dm.proper_methods)
             {
                 if (bfc.simple_function_node.is_generic_function)
                 {
                     generic_count++;
                 }
             }
             bool one_function = false;
             switch (generic_count)
             {
                 case 0:
                     AddError(get_location(_ident_with_templateparams), "TRIANGLE_BRACKETS_NOT_ALLOWED_WITH_COMMON_FUNCTIONS"); break;
                 case 1:
                     one_function = true;
                     break;
                 default:
                     one_function = false;
                     break;
             }
             foreach (base_function_call bfc in dm.proper_methods)
             {
                 if (!bfc.simple_function_node.is_generic_function)
                 {
                     continue;
                 }
                 switch (bfc.semantic_node_type)
                 {
                     case semantic_node_type.common_namespace_function_call:
                         common_namespace_function_node cnfn = bfc.simple_function_node.get_instance(ptypes, one_function, get_location(_ident_with_templateparams)) as common_namespace_function_node;
                         if (cnfn != null)
                         {
                             bfcl.AddElement(new common_namespace_function_call(cnfn, bfc.location));
                         }
                         break;
                     case semantic_node_type.common_method_call:
                         cnode = bfc.simple_function_node.get_instance(ptypes, one_function, get_location(_ident_with_templateparams)) as common_method_node;
                         if (cnode != null)
                         {
                             bfcl.AddElement(new common_method_call(cnode, (bfc as common_method_call).obj, bfc.location));
                         }
                         break;
                     case semantic_node_type.compiled_function_call:
                         fnode = bfc.simple_function_node.get_instance(ptypes, one_function, get_location(_ident_with_templateparams));
                         cnode = fnode as common_method_node;
                         if (cnode != null)
                         {
                             bfcl.AddElement(new common_method_call(cnode, (bfc as compiled_function_call).obj, bfc.location));
                         }
                         else
                         {
                             comp_node = fnode as compiled_function_node;
                             if (comp_node != null)
                             {
                                 bfcl.AddElement(new compiled_function_call(comp_node, (bfc as compiled_function_call).obj, bfc.location));
                             }
                         }
                         break;
                     case semantic_node_type.common_static_method_call:
                     case semantic_node_type.compiled_static_method_call:
                         fnode = bfc.simple_function_node.get_instance(ptypes, one_function, get_location(_ident_with_templateparams));
                         cnode = fnode as common_method_node;
                         if (cnode != null)
                         {
                             bfcl.AddElement(new common_static_method_call(cnode, bfc.location));
                         }
                         else
                         {
                             comp_node = fnode as compiled_function_node;
                             if (comp_node != null)
                             {
                                 bfcl.AddElement(new compiled_static_method_call(comp_node, bfc.location));
                             }
                         }
                         break;
                 }
             }
             if (bfcl.Count == 0)
             {
                 AddError(get_location(_ident_with_templateparams.template_params), "NO_FUNCTIONS_{0}_CAN_BE_USED_WITH_THIS_SPECIFICATION", dm.proper_methods[0].function.name);
             }
             delegated_methods dm1 = new delegated_methods();
             dm1.proper_methods.AddRange(bfcl);
             typed_expression te1 = new typed_expression(dm1, te.location);
             return_value(te1);
             return;
         }
     }
     AddError(get_location(_ident_with_templateparams.name), "TRIANGLE_BRACKETS_NOT_AWAITED");
  }
 internal expression_node convert_typed_expression_to_function_call(typed_expression te)
 {
     delegated_methods dm = te.type as delegated_methods;
     if (dm == null)
     {
         return te;
     }
     base_function_call bfc = dm.empty_param_method;
     if (bfc == null)
     {
         return te;
     }
     if (bfc.type == null) 
     	return te;
     function_node fn = bfc.simple_function_node;
     common_namespace_function_node cnfn = fn as common_namespace_function_node;
     if ((fn.parameters.Count == 1 || cnfn != null && fn.parameters.Count == 2 && cnfn.ConnectedToType != null)
         && (fn.parameters[fn.parameters.Count - 1].is_params || fn.parameters[fn.parameters.Count - 1].default_value != null))
     {
         fn = convertion_data_and_alghoritms.select_function(bfc.parameters, new SymbolInfo(fn), bfc.location);
         bfc = convertion_data_and_alghoritms.create_simple_function_call(fn, bfc.location, bfc.parameters.ToArray()) as base_function_call;
     }
     else
     {
         compiled_function_node cfn = fn as compiled_function_node;
         if ((fn.parameters.Count == 1 || cfn != null && fn.parameters.Count == 2 && cfn.ConnectedToType != null)
             && (fn.parameters[fn.parameters.Count - 1].is_params || fn.parameters[fn.parameters.Count - 1].default_value != null))
         {
             fn = convertion_data_and_alghoritms.select_function(bfc.parameters, new SymbolInfo(fn), bfc.location);
             bfc = create_static_method_call_with_params(fn, bfc.location, fn.return_value_type, true, bfc.parameters);
         }
         else if (fn.parameters.Count == 1 && cfn != null && cfn.ConnectedToType != null)
         {
             fn = convertion_data_and_alghoritms.select_function(bfc.parameters, new SymbolInfo(fn), bfc.location);
             bfc = create_static_method_call_with_params(fn, bfc.location, fn.return_value_type, true, bfc.parameters);
         }
     }
     return bfc;
 }