コード例 #1
0
ファイル: types.cs プロジェクト: Slav76/pascalabcnet
        public static compiled_type_node get_type_node(System.Type st)
		{
            //(ssyy) Обрабатываем параметры generic-типов
            //Сделаю потом, если это понадобится.
            //if (st.IsGenericParameter)
            //{
            //}
            //if (st.Name.EndsWith("&") == true)
            
            //(ssyy) Лучше так
			if (st.IsByRef)
			{
				//return get_type_node(st.Module.GetType(st.FullName.Substring(0,st.FullName.Length-1)));
                return get_type_node(st.GetElementType());
            }
			compiled_type_node ctn;//=compiled_types[st];
            if (compiled_types.TryGetValue(st, out ctn))
			{
                //ctn.reinit_scope();
                return ctn;
			}
			ctn=new compiled_type_node(st);
            
            //Если это не чистить, будет ошибка. Т.к. при следующей компиляции области видимости могут изменится.
            //Но если это чистить то тоже ошибка. нужна еще одна статическая таблица для стандартных типов
			compiled_types[st] = ctn;
			
            ctn.init_constructors();
            ctn.mark_if_delegate();
            ctn.mark_if_array();
            if (st.IsEnum)
            {
                internal_interface ii = SystemLibrary.SystemLibrary.integer_type.get_internal_interface(internal_interface_kind.ordinal_interface);
                ordinal_type_interface oti_old = (ordinal_type_interface)ii;
                enum_const_node lower_value = new enum_const_node(0, ctn, ctn.loc);
                enum_const_node upper_value = new enum_const_node(st.GetFields().Length-2, ctn, ctn.loc);
                ordinal_type_interface oti_new = new ordinal_type_interface(oti_old.inc_method, oti_old.dec_method,
                    oti_old.inc_value_method, oti_old.dec_value_method,
                    oti_old.lower_eq_method, oti_old.greater_eq_method, 
                    oti_old.lower_method, oti_old.greater_method,
                    lower_value, upper_value, oti_old.value_to_int, oti_old.ordinal_type_to_int);

                ctn.add_internal_interface(oti_new);
                SystemLibrary.SystemLibrary.make_binary_operator(compiler_string_consts.gr_name, ctn, SemanticTree.basic_function_type.enumgr, SystemLibrary.SystemLibrary.bool_type);
                SystemLibrary.SystemLibrary.make_binary_operator(compiler_string_consts.greq_name, ctn, SemanticTree.basic_function_type.enumgreq, SystemLibrary.SystemLibrary.bool_type);
                SystemLibrary.SystemLibrary.make_binary_operator(compiler_string_consts.sm_name, ctn, SemanticTree.basic_function_type.enumsm, SystemLibrary.SystemLibrary.bool_type);
                SystemLibrary.SystemLibrary.make_binary_operator(compiler_string_consts.smeq_name, ctn, SemanticTree.basic_function_type.enumsmeq, SystemLibrary.SystemLibrary.bool_type);
                InitEnumOperations(ctn);
            }
            //ctn.init_scope();
            //TODO: Тут надо подумать. Может как-то сделать по другому?
            if (!NetHelper.NetHelper.IsStandType(st))
			{
				SystemLibrary.SystemLibrary.init_reference_type(ctn);
			}
			return ctn;
		}