Exemplo n.º 1
0
        //TODO: Возможно объеденить с compiled_function_node
		private compiled_constructor_node(System.Reflection.ConstructorInfo con_info)
		{
			_con_info=con_info;
            compiled_constructors[con_info] = this;
            //type_node ret_val=null;
			System.Reflection.ParameterInfo[] pinf=_con_info.GetParameters();
			parameter_list pal=new parameter_list();
			foreach(System.Reflection.ParameterInfo pi in pinf)
			{
				Type t=null;
				type_node par_type=null;
				SemanticTree.parameter_type pt=SemanticTree.parameter_type.value;
				if (pi.ParameterType.IsByRef) 
				{
					t=pi.ParameterType.GetElementType();
					par_type=compiled_type_node.get_type_node(t);
					pt=SemanticTree.parameter_type.var;
				}
				else
				{
					par_type=compiled_type_node.get_type_node(pi.ParameterType);
				}
				string name=pi.Name;
				compiled_parameter crpar=new compiled_parameter(pi);
				crpar.SetParameterType(pt);
				pal.AddElement(crpar);
                if (pi.IsOptional && pi.DefaultValue != null)
                    _num_of_default_parameters++;
			}
			this.return_value_type=compiled_type_node.get_type_node(_con_info.DeclaringType);
			this.parameters.AddRange(pal);
		}
Exemplo n.º 2
0
        /// <summary>
        /// Конструктор узла.
        /// </summary>
        /// <param name="mi">Оборачиваемый метод.</param>
		private compiled_function_node(System.Reflection.MethodInfo mi)
		{
			_mi=mi;
			type_node ret_val=null;
			if (_mi.ReturnType!=null)
			{
				ret_val=compiled_type_node.get_type_node(mi.ReturnType);
                if (ret_val == SystemLibrary.SystemLibrary.void_type)
                {
                    ret_val = null;
                }
			}
			System.Reflection.ParameterInfo[] pinf=mi.GetParameters();
            parameter_list pal = new parameter_list();
            //if (!(_mi.IsGenericMethod))
            {
                int i = 1;
                foreach (System.Reflection.ParameterInfo pi in pinf)
                {
                    Type t = null;
                    
                    type_node par_type = null;
                    SemanticTree.parameter_type pt = SemanticTree.parameter_type.value;
//                    if (pi.ParameterType.Name.EndsWith("&") == true)
                    //(ssyy) Лучше так:
                    if (pi.ParameterType.IsByRef)
                    {
                        //t = pi.ParameterType.Assembly.GetType(pi.ParameterType.FullName.Substring(0, pi.ParameterType.FullName.Length - 1));
                        //(ssyy) Лучше так:
                        t = pi.ParameterType.GetElementType();
                        par_type = compiled_type_node.get_type_node(t);
                        pt = SemanticTree.parameter_type.var;
                    }
                    else
                    {
                        if (pi.Position == 0)
                        {
                            par_type = compiled_type_node.get_type_node(pi.ParameterType);
                            if (NetHelper.NetHelper.IsExtensionMethod(mi))
                            {
                                connected_to_type = par_type as compiled_type_node;
                            }
                        }
                    }
                    string name = pi.Name;
                    compiled_parameter crpar = new compiled_parameter(pi);
                    crpar.SetParameterType(pt);
                    pal.AddElement(crpar);
                    if (pi.IsOptional && pi.DefaultValue != null)
                        _num_of_default_parameters++;
                    i++;
                }
            }
            //else
            if (_mi.IsGenericMethod)
            {
                _generic_params_count = mi.GetGenericArguments().Length;
            }
            _is_extension_method = NetHelper.NetHelper.IsExtensionMethod(mi);
			this.return_value_type=ret_val;
			this.parameters.AddRange(pal);
		}