//(ssyy) Сохранение инстанции generic-класса
        private void WriteGenericTypeInstance(generic_instance_type_node gitn)
        {
            bw.Write((byte)TypeKind.GenericInstance);

            //Пишем ссылку на описание generic-типа
            WriteTypeReference(gitn.original_generic);
            WriteTypeList(gitn.instance_params);
        }
Esempio n. 2
0
 public void SetBaseTypeIgnoringScope(type_node base_type)
 {
     _base_type = base_type;
     if (base_type != null)
     {
         _base_generic_instance = base_type.base_generic_instance;
     }
 }
Esempio n. 3
0
 public void SetBaseType(type_node base_type)
 {
     if (base_type == null)
     {
         _base_type = null;
         _scope.BaseClassScope = null;
         return;
     }
     _base_type = base_type;
     if (_scope != null)
     {
         _scope.BaseClassScope = _base_type.Scope;
     }
     _base_generic_instance = base_type.base_generic_instance;
 }
Esempio n. 4
0
        public static void init_generic_instance(type_node original, generic_instance_type_node instance, /*SymbolTable.ClassScope instance_scope,*/ List<type_node> param_types)
        {
            instance.IsInterface = original.IsInterface;
            instance.is_class = original.is_class;
            instance.internal_is_value = original.is_value;
            instance.SetIsSealed(original.IsSealed);
            instance.IsDelegate = original.IsDelegate;
            instance.type_special_kind = original.type_special_kind;

            //Определяем базовый тип
            type_node btype = determine_type(
                original.base_type, param_types, false);
            instance.SetBaseTypeIgnoringScope(btype);
            
            //instance._scope = new SymbolTable.GenericTypeInstanceScope(instance, instance.original_generic.Scope, btype.Scope);

            foreach (type_node interf in original.ImplementingInterfaces)
            {
                instance.ImplementingInterfaces.Add(
                    determine_type(interf, param_types, false)
                    );
            }

            SystemLibrary.SystemLibrary.init_reference_type(instance);
            instance.conform_basic_functions();
            //(ssyy) Нужно, чтобы добавились конструкторы
            //ctnode.find_in_type(compiler_string_consts.default_constructor_name);
            instance.instance_params = param_types;

            property_node orig_pn = original.default_property_node;
            if (orig_pn != null)
            {
                if (orig_pn.comprehensive_type == original)
                {
                    //Свойство по умолчанию описано в оригинальном коде generic-a;
                    //конвертируем его
                    instance.default_property = instance.ConvertMember(orig_pn) as common_property_node;
                }
                else
                {
                    //Свойство по умолчанию описано в каком-то предке оригинального generic-a
                    if (orig_pn.comprehensive_type.is_generic_type_definition)
                    {
                        instance.default_property = instance.find_instance_type_from(orig_pn.comprehensive_type).default_property;
                    }
                }
            }

            var shouldAddToAllTypeInstances = true;
            if (LambdaHelper.processingLambdaParametersForTypeInference != 0)
            {
                foreach (var par in instance.generic_parameters)
                {
                    if (par is lambda_any_type_node)
                    {
                        shouldAddToAllTypeInstances = false;
                        break;
                    }
                }
            }

            if (shouldAddToAllTypeInstances) //lroman// Если зашли сюда при выведении типов параметров лямбды, то тип инстанцироваться может с типом lambda_any_type_node. Поэтому, если выводим типы. То данную инстанцию не добавляем
                generic_convertions.all_type_instances.Add(instance);

            internal_interface ii = original.get_internal_interface(internal_interface_kind.delegate_interface);
            if (ii != null)
            {
                delegate_internal_interface dii = ii as delegate_internal_interface;
                common_method_node inv = instance.ConvertMember(dii.invoke_method) as common_method_node;
                common_method_node constr = instance.ConvertMember(dii.constructor) as common_method_node;
                constr.function_code = new runtime_statement(SemanticTree.runtime_statement_type.ctor_delegate, null);
                delegate_internal_interface converted_dii = new delegate_internal_interface(inv.return_value_type,
                    inv, constr);
                converted_dii.parameters.AddRange(inv.parameters);
                instance.add_internal_interface(converted_dii);
            }
        }
Esempio n. 5
0
 public generic_type_instance_info(List<type_node> _param_types, generic_instance_type_node _pseudo_instance)
 {
     param_types = _param_types;
     pseudo_instance = _pseudo_instance;
 }
Esempio n. 6
0
 public type_instance_and_location(generic_instance_type_node _instance, location _loc)
 {
     instance = _instance;
     loc = _loc;
 }