Esempio n. 1
0
        private static type_intersection_node[] get_type_intersections_in_specific_order(type_node left, type_node right)
        {
            type_intersection_node tin1 = left.get_type_intersection(right);
            type_intersection_node tin2 = right.get_type_intersection(left);

            if (tin1 == null)
            {
                if (tin2 == null)
                {
                    return(new type_intersection_node[0]);
                }
                else
                {
                    if (tin2.another_to_this != null && tin2.another_to_this.is_explicit)
                    {
                        return(new type_intersection_node[0]);
                    }
                    type_intersection_node[] tinarr  = new type_intersection_node[1];
                    type_intersection_node   new_tin = null;
                    if (tin2.type_compare == type_compare.greater_type)
                    {
                        new_tin = new type_intersection_node(type_compare.less_type);
                    }
                    else if (tin2.type_compare == type_compare.less_type)
                    {
                        new_tin = new type_intersection_node(type_compare.greater_type);
                    }
                    else
                    {
                        new_tin = new type_intersection_node(type_compare.non_comparable_type);
                    }
                    new_tin.another_to_this = tin2.another_to_this;
                    new_tin.this_to_another = tin2.this_to_another;
                    tinarr[0] = new_tin;
                    return(tinarr);
                }
            }
            else
            {
                if (tin2 == null)
                {
                    if (tin1.this_to_another != null && tin1.this_to_another.is_explicit)
                    {
                        return(new type_intersection_node[0]);
                    }
                    type_intersection_node[] tinarr2 = new type_intersection_node[1];
                    tinarr2[0] = tin1;
                    return(tinarr2);
                }
                else
                {
                    type_intersection_node[] tinarr3 = new type_intersection_node[2];
                    tinarr3[0] = tin1;
                    tinarr3[1] = tin2;
                    return(tinarr3);
                }
            }
        }
Esempio n. 2
0
        private static type_intersection_node[] get_type_intersections(type_node left, type_node right)
        {
            type_intersection_node tin1 = left.get_type_intersection(right);
            type_intersection_node tin2 = right.get_type_intersection(left);

            if (tin1 == null)
            {
                if (tin2 == null)
                {
                    return(new type_intersection_node[0]);
                }
                else
                {
                    type_intersection_node[] tinarr  = new type_intersection_node[1];
                    type_intersection_node   new_tin = new type_intersection_node();

                    new_tin.another_to_this = tin2.another_to_this;
                    new_tin.this_to_another = tin2.this_to_another;
                    if (tin2.type_compare == type_compare.greater_type)
                    {
                        new_tin.type_compare = type_compare.less_type;
                    }
                    else
                    {
                        new_tin.type_compare = type_compare.greater_type;
                    }
                    tinarr[0] = new_tin;
                    return(tinarr);
                }
            }
            else
            {
                if (tin2 == null)
                {
                    type_intersection_node[] tinarr2 = new type_intersection_node[1];
                    tinarr2[0] = tin1;
                    return(tinarr2);
                }
                else
                {
                    type_intersection_node[] tinarr3 = new type_intersection_node[2];
                    tinarr3[0] = tin1;
                    tinarr3[1] = tin2;
                    return(tinarr3);
                }
            }
        }
Esempio n. 3
0
        public static void add_type_conversion_from_defined(type_node from, type_node to,
                                                            function_node convertion_method, type_compare comp, bool is_implicit, bool is_generated)
        {
            type_intersection_node tin = from.get_type_intersection(to);

            if (tin == null)
            {
                tin = new type_intersection_node(comp);
                from.add_intersection_node(to, tin, is_generated);
            }
#if (DEBUG)
            else
            {
                if (tin.this_to_another != null)
                {
                    throw new PascalABCCompiler.TreeConverter.CompilerInternalError("Duplicate type conversion added");
                }
            }
#endif
            tin.this_to_another = new type_conversion(convertion_method, !is_implicit);
        }
Esempio n. 4
0
        private static void add_std_convertions()
        {
            type_intersection_node inter = new type_intersection_node(type_compare.greater_type);

            Type t = typeof(char);
            Type[] types = new Type[1];
            types[0] = typeof(char);
            System.Reflection.MethodInfo mi = t.GetMethod(compiler_string_consts.to_string_method_name, types);
            compiled_function_node cfn = compiled_function_node.get_compiled_method(mi);

            inter.another_to_this = new type_conversion(cfn);
            _string_type.add_intersection_node(_char_type, inter,false);
            _char_to_string = cfn;
        }
Esempio n. 5
0
        /// <summary>
        /// Добавляет узел пересечения типов.
        /// </summary>
        /// <param name="tn">Тип с которым нужно добавить узел пересечения типов.</param>
        /// <param name="intersection">Узел пересечения типов.</param>
		public void add_intersection_node(type_node tn, type_intersection_node intersection, bool is_generated)
		{
			if (type_intersections == null)
				type_intersections = new System.Collections.Generic.Dictionary<type_node, type_intersection_node>(32);
#if (DEBUG)
            type_intersection_node ti;
			if (type_intersections.TryGetValue(tn,out ti))
			{
				throw new CompilerInternalError("Duplicate type intersection");
			}
#endif
			type_intersections[tn]=intersection;
            if (is_generated)
            {
            	if (generated_type_intersections == null)
            		generated_type_intersections = new List<type_node>(32);
            	
            	generated_type_intersections.Add(tn);
            }
		}
Esempio n. 6
0
        public static bool is_derived(type_node base_class, type_node derived_class)
        {
            if (derived_class == null)  //void?
            {
                return(false);
            }
            if (base_class == null)
            {
                return(false);
            }
            type_node tn = derived_class.base_type;

            //TODO: Проверить на ссылочный и размерный тип.
            if (derived_class.semantic_node_type == semantic_node_type.null_type_node)
            {
                if (is_with_nil_allowed(base_class) || base_class.IsPointer)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (base_class.type_special_kind == SemanticTree.type_special_kind.short_string && derived_class.type_special_kind == SemanticTree.type_special_kind.short_string)
            {
                return(true);
            }
            else if (derived_class == SystemLibrary.SystemLibrary.string_type && base_class.type_special_kind == SemanticTree.type_special_kind.short_string)
            {
                return(true);
            }
            else if (base_class == SystemLibrary.SystemLibrary.string_type && derived_class.type_special_kind == SemanticTree.type_special_kind.short_string)
            {
                return(true);
            }
            if (SystemLibrary.SystemLibInitializer.TypedSetType != null && SystemLibrary.SystemLibInitializer.TypedSetType.Found &&
                base_class.type_special_kind == SemanticTree.type_special_kind.set_type && derived_class == SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node
                )
            {
                return(true);
            }
            if (base_class.type_special_kind == SemanticTree.type_special_kind.set_type && derived_class.type_special_kind == SemanticTree.type_special_kind.set_type)
            {
                if (base_class.element_type == derived_class.element_type)
                {
                    return(true);
                }
                type_compare tc = get_table_type_compare(base_class.element_type, derived_class.element_type);
                if (tc == type_compare.non_comparable_type)
                {
                    if (base_class.element_type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type)
                    {
                        if (derived_class.element_type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type)
                        {
                            if (base_class.element_type.base_type == derived_class.element_type.base_type)
                            {
                                return(true);
                            }
                            tc = get_table_type_compare(base_class.element_type.base_type, derived_class.element_type.base_type);
                            if (tc == type_compare.non_comparable_type)
                            {
                                return(false);
                            }
                            type_intersection_node tin = base_class.element_type.base_type.get_type_intersection(derived_class.element_type.base_type);
                            if (tin == null || tin.this_to_another == null)
                            {
                                if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type)
                                {
                                    if ((derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                                    {
                                        return(false);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    return(true);
                                }
                            }
                            if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type &&
                                (derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                            {
                                return(false);
                            }
                            return(!tin.this_to_another.is_explicit);
                        }
                        else
                        {
                            if (base_class.element_type.base_type == derived_class.element_type)
                            {
                                return(true);
                            }
                            tc = get_table_type_compare(base_class.element_type.base_type, derived_class.element_type);
                            if (tc == type_compare.non_comparable_type)
                            {
                                return(false);
                            }
                            type_intersection_node tin = base_class.element_type.base_type.get_type_intersection(derived_class.element_type);
                            if (tin == null || tin.this_to_another == null)
                            {
                                if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type)
                                {
                                    if ((derived_class.element_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type == SystemLibrary.SystemLibrary.float_type))
                                    {
                                        return(false);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    return(true);
                                }
                            }
                            if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type &&
                                (derived_class.element_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type == SystemLibrary.SystemLibrary.float_type))
                            {
                                return(false);
                            }
                            return(!tin.this_to_another.is_explicit);
                        }
                    }
                    else
                    if (derived_class.element_type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type)
                    {
                        if (base_class.element_type == derived_class.element_type.base_type)
                        {
                            return(true);
                        }
                        tc = get_table_type_compare(base_class.element_type, derived_class.element_type.base_type);
                        if (tc == type_compare.non_comparable_type)
                        {
                            return(false);
                        }
                        type_intersection_node tin = base_class.element_type.get_type_intersection(derived_class.element_type.base_type);
                        if (tin == null || tin.this_to_another == null)
                        {
                            if (base_class.element_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type != SystemLibrary.SystemLibrary.float_type)
                            {
                                if ((derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                                {
                                    return(false);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(true);
                            }
                        }
                        if (base_class.element_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type != SystemLibrary.SystemLibrary.float_type &&
                            (derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                        {
                            return(false);
                        }
                        return(!tin.this_to_another.is_explicit);
                    }
                    else if (base_class.element_type.type_special_kind == SemanticTree.type_special_kind.short_string && derived_class.element_type == SystemLibrary.SystemLibrary.string_type ||
                             derived_class.element_type.type_special_kind == SemanticTree.type_special_kind.short_string && base_class.element_type == SystemLibrary.SystemLibrary.string_type)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    type_intersection_node tin = base_class.element_type.get_type_intersection(derived_class.element_type);
                    if (tin == null || tin.this_to_another == null)
                    {
                        //proverka na diapasony
                        if (base_class.element_type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type)
                        {
                            if (derived_class.element_type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type)
                            {
                                if (base_class.element_type.base_type == derived_class.element_type.base_type)
                                {
                                    return(true);
                                }
                                tc = get_table_type_compare(base_class.element_type.base_type, derived_class.element_type.base_type);
                                if (tc == type_compare.non_comparable_type)
                                {
                                    return(false);
                                }
                                type_intersection_node tin2 = base_class.element_type.base_type.get_type_intersection(derived_class.element_type.base_type);
                                if (tin == null || tin.this_to_another == null)
                                {
                                    if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type)
                                    {
                                        if ((derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                                        {
                                            return(false);
                                        }
                                        else
                                        {
                                            return(false);
                                        }
                                    }
                                    else
                                    {
                                        return(true);
                                    }
                                }
                                if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type &&
                                    (derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                                {
                                    return(false);
                                }
                                return(!tin.this_to_another.is_explicit);
                            }
                            else
                            {
                                if (base_class.element_type.base_type == derived_class.element_type)
                                {
                                    return(true);
                                }
                                tc = get_table_type_compare(base_class.element_type.base_type, derived_class.element_type);
                                if (tc == type_compare.non_comparable_type)
                                {
                                    return(false);
                                }
                                type_intersection_node tin2 = base_class.element_type.base_type.get_type_intersection(derived_class.element_type);
                                if (tin == null || tin.this_to_another == null)
                                {
                                    if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type)
                                    {
                                        if ((derived_class.element_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type == SystemLibrary.SystemLibrary.float_type))
                                        {
                                            return(false);
                                        }
                                        else
                                        {
                                            return(false);
                                        }
                                    }
                                    else
                                    {
                                        return(true);
                                    }
                                }
                                if (base_class.element_type.base_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type.base_type != SystemLibrary.SystemLibrary.float_type &&
                                    (derived_class.element_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type == SystemLibrary.SystemLibrary.float_type))
                                {
                                    return(false);
                                }
                                return(!tin.this_to_another.is_explicit);
                            }
                        }
                        else
                        if (derived_class.element_type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type)
                        {
                            if (base_class.element_type == derived_class.element_type.base_type)
                            {
                                return(true);
                            }
                            tc = get_table_type_compare(base_class.element_type, derived_class.element_type.base_type);
                            if (tc == type_compare.non_comparable_type)
                            {
                                return(false);
                            }
                            type_intersection_node tin2 = base_class.element_type.get_type_intersection(derived_class.element_type.base_type);
                            if (tin == null || tin.this_to_another == null)
                            {
                                if (base_class.element_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type != SystemLibrary.SystemLibrary.float_type)
                                {
                                    if ((derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                                    {
                                        return(false);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    return(true);
                                }
                            }
                            if (base_class.element_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type != SystemLibrary.SystemLibrary.float_type &&
                                (derived_class.element_type.base_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type.base_type == SystemLibrary.SystemLibrary.float_type))
                            {
                                return(false);
                            }
                            return(!tin.this_to_another.is_explicit);
                        }
                        if (base_class.element_type != SystemLibrary.SystemLibrary.double_type && base_class.element_type != SystemLibrary.SystemLibrary.float_type)
                        {
                            if ((derived_class.element_type == SystemLibrary.SystemLibrary.double_type || derived_class.element_type == SystemLibrary.SystemLibrary.float_type))
                            {
                                return(false);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    return(!tin.this_to_another.is_explicit);
                }
            }
            //ssyy Рассматриваем случай интерфейса
            if (base_class.IsInterface)
            {
                bool      implements = false;
                type_node tnode      = derived_class;
                while (!implements && tnode != null && tnode.ImplementingInterfaces != null)
                {
                    implements = tnode.ImplementingInterfaces.Contains(base_class);
                    tnode      = tnode.base_type;
                }
                return(implements);
            }
            //\ssyy

            if (base_class.type_special_kind == SemanticTree.type_special_kind.diap_type && derived_class.type_special_kind == SemanticTree.type_special_kind.diap_type)
            {
                if (base_class.base_type == derived_class.base_type)
                {
                    return(true);
                }
                type_compare tc = get_table_type_compare(base_class.base_type, derived_class.base_type);
                if (tc == type_compare.non_comparable_type)
                {
                    return(false);
                }
                type_intersection_node tin = base_class.base_type.get_type_intersection(derived_class.base_type);
                if (tin == null || tin.this_to_another == null)
                {
                    return(false);
                }
                return(!tin.this_to_another.is_explicit);
            }

            while ((tn != null) && (tn != base_class))
            {
                tn = tn.base_type;
            }
            if (tn == null)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
        //TODO: Возможно стоит если пересечение типов найдено в откомпилированных типах, добавлять к нашим структурам и не искать повторно.
        public static possible_type_convertions get_convertions(type_node from, type_node to, bool is_implicit)
        {
            possible_type_convertions ret = new possible_type_convertions();

            ret.first  = null;
            ret.second = null;

            if ((from == null) || (to == null))
            {
                return(ret);
            }

            type_intersection_node tin_from = from.get_type_intersection(to);
            type_intersection_node tin_to   = to.get_type_intersection(from);

            if (tin_from != null)
            {
                if (tin_from.this_to_another != null)
                {
                    if ((!is_implicit) || (!(tin_from.this_to_another.is_explicit)))
                    {
                        add_conversion(ret, tin_from.this_to_another.convertion_method, from, to);
                    }
                }
            }
            if (tin_to != null)
            {
                if (tin_to.another_to_this != null)
                {
                    if ((!is_implicit) || (!(tin_to.another_to_this.is_explicit)))
                    {
                        add_conversion(ret, tin_to.another_to_this.convertion_method, from, to);
                    }
                }
            }
            if (ret.second != null)
            {
                return(ret);
            }

            if (is_derived(to, from) || (from.IsInterface && to == SystemLibrary.SystemLibrary.object_type) || from.is_generic_type_instance && to == SystemLibrary.SystemLibrary.object_type)
            {
                add_conversion(ret, TreeConverter.convertion_data_and_alghoritms.get_empty_conversion(from, to, true), from, to);
                //add_conversion(ret, SystemLibrary.SystemLibrary.empty_method, from, to);
            }

            if (ret.second != null)
            {
                return(ret);
            }

            wrapped_type ctn_to   = to as wrapped_type;
            wrapped_type ctn_from = from as wrapped_type;

            if (ctn_to != null)
            {
                function_node fnode1 = null;
                fnode1 = ctn_to.get_implicit_conversion_from(from);
                add_conversion(ret, fnode1, from, to);
                if (ret.second != null)
                {
                    return(ret);
                }
                fnode1 = null;
                if (!is_implicit)
                {
                    fnode1 = ctn_to.get_explicit_conversion_from(from);
                }
                add_conversion(ret, fnode1, from, to);
                if (ret.second != null)
                {
                    return(ret);
                }
            }
            if (ctn_from != null)
            {
                function_node fnode2 = null;
                fnode2 = ctn_from.get_implicit_conversion_to(to);
                add_conversion(ret, fnode2, from, to);
                if (ret.second != null)
                {
                    return(ret);
                }
                fnode2 = null;
                if (!is_implicit)
                {
                    fnode2 = ctn_from.get_explicit_conversion_to(to);
                }
                add_conversion(ret, fnode2, from, to);
                if (ret.second != null)
                {
                    return(ret);
                }
            }

            //TODO: Вот это должно быть в каком нибудь другом месте.
            internal_interface ii = from.get_internal_interface(internal_interface_kind.delegate_interface);

            if (ii != null)
            {
                delegate_internal_interface dii = (delegate_internal_interface)ii;

                internal_interface to_ii = to.get_internal_interface(internal_interface_kind.delegate_interface);
                if (to_ii != null)
                {
                    delegate_internal_interface to_dii = (delegate_internal_interface)to_ii;
                    if (dii.parameters.Count == to_dii.parameters.Count)
                    {
                        //ms100 error fixed (DS)
                        bool eq = TreeConverter.convertion_data_and_alghoritms.function_eq_params_and_result(dii.invoke_method, to_dii.invoke_method);
                        if (eq)
                        {
                            delegate_to_delegate_type_converter dtdtc = new delegate_to_delegate_type_converter(to);
                            add_conversion(ret, new convert_types_function_node(dtdtc.convert_delegates_to_delegates, false), from, to);
                        }
                    }
                }

                if (dii.parameters.Count == 0)
                {
                    if (dii.return_value_type == to)
                    {
                        add_conversion(ret, new convert_types_function_node(convert_delegate_to_return_value_type, true), from, to);
                    }
                    else
                    {
                        possible_type_convertions ptcc = get_convertions(dii.return_value_type, to);
                        if ((ptcc.first != null) && (ptcc.first.convertion_method != null))
                        {
                            delegate_type_converter dtc = new delegate_type_converter(ptcc.first.convertion_method);
                            add_conversion(ret, new convert_types_function_node(dtc.convert_delegate_to_return_value_type_with_convertion, false), from, to);
                        }
                        if ((ptcc.second != null) && (ptcc.second.convertion_method != null))
                        {
                            delegate_type_converter dtc = new delegate_type_converter(ptcc.second.convertion_method);
                            add_conversion(ret, new convert_types_function_node(dtc.convert_delegate_to_return_value_type_with_convertion, false), from, to);
                        }
                    }
                }
            }

            return(ret);
        }
        public static void add_type_conversion_from_defined(type_node from, type_node to,
			function_node convertion_method,type_compare comp,bool is_implicit,bool is_generated)
		{
			type_intersection_node tin=from.get_type_intersection(to);
			if (tin==null)
			{
				tin=new type_intersection_node(comp);
				from.add_intersection_node(to,tin,is_generated);
			}
#if (DEBUG)
			else
			{
				if (tin.this_to_another!=null)
				{
					throw new PascalABCCompiler.TreeConverter.CompilerInternalError("Duplicate type conversion added");
				}
			}
#endif
			tin.this_to_another=new type_conversion(convertion_method,!is_implicit);		
		}
		private static type_intersection_node[] get_type_intersections(type_node left,type_node right)
		{
			type_intersection_node tin1=left.get_type_intersection(right);
			type_intersection_node tin2=right.get_type_intersection(left);

			if (tin1==null)
			{
				if (tin2==null)
				{
					return new type_intersection_node[0];
				}
				else
				{
					type_intersection_node[] tinarr=new type_intersection_node[1];
                    type_intersection_node new_tin = new type_intersection_node();

                    new_tin.another_to_this = tin2.another_to_this;
                    new_tin.this_to_another = tin2.this_to_another;
                    if (tin2.type_compare == type_compare.greater_type)
                        new_tin.type_compare = type_compare.less_type;
                    else
                        new_tin.type_compare = type_compare.greater_type;
					tinarr[0]= new_tin;
					return tinarr;
				}
			}
			else
			{
				if (tin2==null)
				{
					type_intersection_node[] tinarr2=new type_intersection_node[1];
					tinarr2[0]=tin1;
					return tinarr2;
				}
				else
				{
					type_intersection_node[] tinarr3=new type_intersection_node[2];
					tinarr3[0]=tin1;
					tinarr3[1]=tin2;
					return tinarr3;
				}
			}
		}
		private static type_intersection_node[] get_type_intersections_in_specific_order(type_node left,type_node right)
		{
			type_intersection_node tin1=left.get_type_intersection(right);
			type_intersection_node tin2=right.get_type_intersection(left);

			if (tin1==null)
			{
				if (tin2==null)
				{
					return new type_intersection_node[0];
				}
				else
				{
					if (tin2.another_to_this != null && tin2.another_to_this.is_explicit)
						return new type_intersection_node[0];
					type_intersection_node[] tinarr=new type_intersection_node[1];
					type_intersection_node new_tin = null;
					if (tin2.type_compare == type_compare.greater_type)
						new_tin = new type_intersection_node(type_compare.less_type);
					else if (tin2.type_compare == type_compare.less_type)
						new_tin = new type_intersection_node(type_compare.greater_type);
					else
						new_tin = new type_intersection_node(type_compare.non_comparable_type);
					new_tin.another_to_this = tin2.another_to_this;
					new_tin.this_to_another = tin2.this_to_another;
					tinarr[0]=new_tin;
					return tinarr;
				}
			}
			else
			{
				if (tin2==null)
				{
					if (tin1.this_to_another != null && tin1.this_to_another.is_explicit)
						return new type_intersection_node[0];
					type_intersection_node[] tinarr2=new type_intersection_node[1];
					tinarr2[0]=tin1;
					return tinarr2;
				}
				else
				{
					type_intersection_node[] tinarr3=new type_intersection_node[2];
					tinarr3[0]=tin1;
					tinarr3[1]=tin2;
					return tinarr3;
				}
			}
		}
 public short_string_type_node create_short_string_type(int length, location def_loc)
 {
     if (ShortStringTypes.ContainsKey(length))
         return ShortStringTypes[length];
     SymbolTable.ClassScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassScope(null, SystemLibrary.SystemLibrary.string_type.Scope);
     short_string_type_node tctn = new short_string_type_node(//SemanticTree.type_access_level.tal_public, _cmn,
         scope, def_loc, length);
     tctn.add_name(compiler_string_consts.assign_name,new SymbolInfo(SystemLibrary.SystemLibrary.make_assign_operator(tctn,PascalABCCompiler.SemanticTree.basic_function_type.objassign)));
     tctn.add_name(compiler_string_consts.plus_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_add));
     tctn.scope.AddSymbol(compiler_string_consts.plusassign_name,new SymbolInfo(make_short_string_plus_assign(tctn)));
     type_intersection_node inter = new type_intersection_node(type_compare.greater_type);
     inter.another_to_this = new type_conversion(SystemLibrary.SystemLibrary.char_to_string);
     tctn.add_intersection_node(SystemLibrary.SystemLibrary.char_type, inter,false);
     ShortStringTypes.Add(length, tctn);
     return tctn;
 }
Esempio n. 12
0
 public short_string_type_node create_short_string_type(int length, location def_loc)
 {
     if (ShortStringTypes.ContainsKey(length))
         return ShortStringTypes[length];
     //type_node base_type = SystemLibrary.SystemLibInitializer.ShortStringType.sym_info as type_node;
     //check_name_free(name, def_loc);
     SymbolTable.ClassScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassScope(null, SystemLibrary.SystemLibrary.string_type.Scope);
     short_string_type_node tctn = new short_string_type_node(//SemanticTree.type_access_level.tal_public, _cmn,
         scope, def_loc, length);
     //tctn.IsFictive = true;
     //set_field_access_level(SemanticTree.field_access_level.fal_public);
     //_cmn.scope.AddSymbol(name, new SymbolInfo(tctn));
     //tctn.internal_is_value = false;//base_type.is_value;
     //tctn.is_class = false;//base_type.is_class;
     //common_property_node cpn = new common_property_node(compiler_string_consts.index_property_pascal_array_name,tctn,SystemLibrary.SystemLibrary.char_type,SystemLibrary.SystemLibInitializer.GetCharInShortStringProcedure.sym_info as function_node,
     //                                                    null,null,SemanticTree.field_access_level.fal_public,SemanticTree.polymorphic_state.ps_common);
    	//tctn.default_property = cpn;
     //SystemLibrary.SystemLibrary.make_type_conversion(tctn,SystemLibrary.SystemLibrary.string_type,type_compare.less_type,SemanticTree.basic_function_type.none,true);
     //SystemLibrary.SystemLibrary.make_type_conversion(SystemLibrary.SystemLibrary.string_type,tctn,type_compare.greater_type,SemanticTree.basic_function_type.none,true);
     //SystemLibrary.SystemLibrary.make_equivalence_operator(tctn);
     //SystemLibrary.SystemLibrary.make_not_equivalence_operator(tctn);
     tctn.add_name(compiler_string_consts.assign_name,new SymbolInfo(SystemLibrary.SystemLibrary.make_assign_operator(tctn,PascalABCCompiler.SemanticTree.basic_function_type.objassign)));
     tctn.add_name(compiler_string_consts.plus_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_add));
     //tctn.add_name(compiler_string_consts.eq_name,new SymbolInfo(SystemLibrary.SystemLibrary));
     //tctn.add_name(compiler_string_consts.noteq_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_type.find_in_type(compiler_string_consts.noteq_name).sym_info as function_node));
     /*tctn.add_name(compiler_string_consts.smeq_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_type.find_in_type(compiler_string_consts.smeq_name).sym_info as function_node));
     tctn.add_name(compiler_string_consts.sm_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_type.find_in_type(compiler_string_consts.sm_name).sym_info as function_node));
     tctn.add_name(compiler_string_consts.greq_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_type.find_in_type(compiler_string_consts.greq_name).sym_info as function_node));
     tctn.add_name(compiler_string_consts.gr_name,new SymbolInfo(SystemLibrary.SystemLibrary.string_type.find_in_type(compiler_string_consts.gr_name).sym_info as function_node));*/
     //_ctn = tctn;
     //SystemLibrary.SystemLibrary.init_reference_type(tctn);
     //converted_namespace.types.AddElement(tctn);
     tctn.scope.AddSymbol(compiler_string_consts.plusassign_name,new SymbolInfo(make_short_string_plus_assign(tctn)));
     type_intersection_node inter = new type_intersection_node(type_compare.greater_type);
     inter.another_to_this = new type_conversion(SystemLibrary.SystemLibrary.char_to_string);
     tctn.add_intersection_node(SystemLibrary.SystemLibrary.char_type, inter,false);
     ShortStringTypes.Add(length, tctn);
     return tctn;
 }