当前位置: 首页>>代码示例>>C#>>正文


C# TreeRealization.common_type_node类代码示例

本文整理汇总了C#中PascalABCCompiler.TreeRealization.common_type_node的典型用法代码示例。如果您正苦于以下问题:C# common_type_node类的具体用法?C# common_type_node怎么用?C# common_type_node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


common_type_node类属于PascalABCCompiler.TreeRealization命名空间,在下文中一共展示了common_type_node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: add_default_ctor

 public static void add_default_ctor(common_type_node param)
 {
     common_method_node cnode = new common_method_node(
         compiler_string_consts.default_constructor_name, param, null,
         param, SemanticTree.polymorphic_state.ps_common,
         SemanticTree.field_access_level.fal_public, null);
     cnode.is_constructor = true;
     param.methods.AddElement(cnode);
     param.add_name(compiler_string_consts.default_constructor_name, new SymbolInfo(cnode));
     param.has_default_constructor = true;
 }
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:11,代码来源:generics.cs

示例2: common_event

 	public common_event(string name, type_node del_type, common_type_node cont_type, common_method_node add_method, common_method_node remove_method, common_method_node raise_method, 
 	                    SemanticTree.field_access_level fal, SemanticTree.polymorphic_state ps, location loc)
 	{
 		this._name = name;
 		this.del_type = del_type;
 		this._add_method = add_method;
 		this._remove_method = remove_method;
 		this._raise_method = raise_method;
 		this._field_access_level = fal;
 		this._polymorphic_state = ps;
 		this._cont_type = cont_type;
 		this._loc = loc;
 	}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:13,代码来源:events.cs

示例3: VisitCommonTypeHeader

 private void VisitCommonTypeHeader(common_type_node ctn)
 {
     if (ctn.base_type != null && ctn.base_type is common_type_node) VisitCommonTypeHeader(ctn.base_type as common_type_node);
     foreach (class_field fld in ctn.fields)
         helper.AddField(fld);
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:6,代码来源:Optimizer.cs

示例4: VisitTypeImplementation

 private void VisitTypeImplementation(common_type_node type)
 {
     foreach (common_method_node meth in type.methods)
         VisitMethodImplementation(meth);
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:5,代码来源:PCUWriter.cs

示例5: VisitPropertyDefinitions

        //сохранение свойств
		private void VisitPropertyDefinitions(common_type_node ctn)
		{
			int offset = GetMemberOffset(ctn);
			bw.Write(ctn.properties.Count);
			for (int i=0; i<ctn.properties.Count; i++)
				VisitPropertyDefinition(ctn.properties[i],offset);
		}
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:8,代码来源:PCUWriter.cs

示例6: VisitFieldDefinitions

        //сохранение полей
		private void VisitFieldDefinitions(common_type_node ctn)
		{
			bw.Write(ctn.fields.Count);
			int offset = GetMemberOffset(ctn);
			for (int i=0; i<ctn.fields.Count; i++)
				VisitFieldDefinition(ctn.fields[i],offset);
		}
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:8,代码来源:PCUWriter.cs

示例7: VisitTypeDefinition

		private void VisitTypeDefinition(common_type_node type)
		{
            int offset = 0;
            if (is_interface == true) offset = SavePositionAndConstPool(type);
			else offset = SavePositionAndImplementationPool(type);
			bw.Write((byte)type.semantic_node_type);
			bw.Write(is_interface);
            bw.Write(type_entity_index++);
			if (is_interface == true)
			 bw.Write(GetNameIndex(type));
			else
			 bw.Write(type.name);
            /*if (type.base_type != null)
             WriteTypeReference(type.base_type);
            else*/

            //Пишем, является ли данный класс интерфейсом
            if (type.IsInterface)
            {
                bw.Write((byte)1);
            }
            else
            {
                bw.Write((byte)0);
            }

            //Пишем, является ли данный класс делегатом
            if (type.IsDelegate)
            {
                bw.Write((byte)1);
            }
            else
            {
                bw.Write((byte)0);
            }
			
            //Является ли тип описанием дженерика
            if (type.is_generic_type_definition)
            {
                bw.Write((byte)1);
                //Число типов-параметров
                bw.Write(type.generic_params.Count);
                //Имена параметров
                foreach (common_type_node par in type.generic_params)
                {
                    bw.Write(par.name);
                }
            }
            else
            {
                bw.Write((byte)0);
            }

            int base_class_off = (int)bw.BaseStream.Position;

            bw.Seek(GetSizeOfReference(type.base_type), SeekOrigin.Current);
			
            //(ssyy) На кой чёрт это надо?
            //WriteTypeReference(SystemLibrary.SystemLibrary.object_type);
            //WriteTypeReference(type.base_type);
            bw.Write(type.internal_is_value);

            //Пишем поддерживаемые интерфейсы
            //eto nepravilno!!! a vdrug bazovye interfejsy eshe ne projdeny.
            //WriteImplementingInterfaces(type);
            int interface_impl_off = (int)bw.BaseStream.Position;
            int seek_off = sizeof(int);
            for (int k=0; k<type.ImplementingInterfaces.Count; k++)
            	seek_off += GetSizeOfReference(type.ImplementingInterfaces[k] as TreeRealization.type_node);
            bw.Seek(seek_off, SeekOrigin.Current);
            bw.Write((byte)type.type_access_level);
            bw.Write((byte)type.type_special_kind);
            bw.Write(type.IsSealed);
            bw.Write(type.IsAbstract);
            bw.Write(type.IsPartial);
            if (type.type_special_kind == SemanticTree.type_special_kind.diap_type)
            {
            	ordinal_type_interface oti = type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
            	VisitExpression(oti.lower_value);
            	VisitExpression(oti.upper_value);
            }

            if (type.is_generic_type_definition)
            {
                //Ограничители параметров
                WriteTypeParamsEliminations(type.generic_params);
            }
            if(CanWriteObject(type.element_type))
                WriteTypeReference(type.element_type);
            
			bw.Write(GetUnitReference(type.comprehensive_namespace));
			SaveOffsetForAttribute(type);
            bw.Write(0);//attributes;
            if (type.default_property != null) 
                bw.Write((byte)1);
            else 
                bw.Write((byte)0);
            int def_prop_off = (int)bw.BaseStream.Position;
            if (type.default_property != null)
                bw.Write(0);//default_property
//.........这里部分代码省略.........
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:101,代码来源:PCUWriter.cs

示例8: WriteGenericParameter

 //(ssyy) Сохранение параметров generic-типов
 private void WriteGenericParameter(common_type_node type)
 {
     if (type.generic_type_container != null)
     {
         bw.Write((byte)TypeKind.GenericParameterOfType);
         //Пишем ссылку на generic-тип, содержащий данный параметр
         WriteTypeReference(type.generic_type_container as type_node);
     }
     else
     {
         common_method_node cnode = type.generic_function_container as common_method_node;
         if (cnode != null)
         {
             bw.Write((byte)TypeKind.GenericParameterOfMethod);
             WriteMethodReference(cnode);
         }
         else
         {
             common_namespace_function_node cnfn = type.generic_function_container as common_namespace_function_node;
             bw.Write((byte)TypeKind.GenericParameterOfFunction);
             WriteFunctionReference(cnfn);
         }
     }
     bw.Write(type.generic_param_index);
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:26,代码来源:PCUWriter.cs

示例9: SameTypeAutoClasses

        public bool SameTypeAutoClasses(List<string> names, List<type_node> types, common_type_node t)
        {
            if (t.properties.Count() != names.Count())
                return false;

            var tnames = t.properties.Select(tt => tt.name);

            return types.SequenceEqual(t.fields.Select(tt => tt.type)) && names.SequenceEqual(tnames, StringComparer.OrdinalIgnoreCase); 
            //return true;
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:10,代码来源:syntax_tree_visitor.cs

示例10: generate_inherited_from_base_and_interface_function

        //\ssyy

        //ssyy
        public void generate_inherited_from_base_and_interface_function(common_type_node ctype, function_node func)
        {
            common_method_node gen_func = context.create_function(func.name, null) as common_method_node;
            gen_func.polymorphic_state = SemanticTree.polymorphic_state.ps_common;
            gen_func.newslot_awaited = true;
            gen_func.is_final = true;
            gen_func.is_overload = true;
            gen_func.field_access_level = SemanticTree.field_access_level.fal_public;
            gen_func.return_value_type = func.return_value_type;
            //gen_func.return_variable = func.retu

            foreach (parameter par in func.parameters)
            {
                concrete_parameter_type cpt =
                    (par.parameter_type == SemanticTree.parameter_type.value) ?
                    concrete_parameter_type.cpt_const :
                    concrete_parameter_type.cpt_var;
                common_parameter c_p = new common_parameter(par.name,
                    par.parameter_type, gen_func, cpt, null);
                c_p.type = par.type;
                c_p.set_param_is_params(par.is_params);
                c_p.inital_value = par.inital_value;
                gen_func.parameters.AddElement(c_p);
            }

            local_variable lv = new local_variable(compiler_string_consts.self_word, gen_func.cont_type, gen_func, null);
            gen_func.scope.AddSymbol(compiler_string_consts.self_word, new SymbolInfo(lv));
            gen_func.self_variable = lv;

            base_function_call bfc;
            this_node tn = null;

            common_method_node commn = func as common_method_node;
            if (commn != null)
            {
                tn = new this_node(commn.comperehensive_type as type_node, null);
                bfc = new common_method_call(commn, tn, null);
            }
            else
            {
                compiled_function_node compn = func as compiled_function_node;
                tn = new this_node(compn.comperehensive_type as type_node, null);
                bfc = new compiled_function_call(compn, tn, null);
            }

            foreach (parameter p in gen_func.parameters)
            {
                bfc.parameters.AddElement(
                    create_variable_reference(p, null));
            }

            //Это запретит чистку стека
            bfc.last_result_function_call = true;

            statements_list snlist = new statements_list(null);
            snlist.statements.AddElement(bfc);
            snlist.statements.AddElement(new empty_statement(null));
            gen_func.function_code = snlist;
            context.pop_top_function();
            //context.leave_block();
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:64,代码来源:syntax_tree_visitor.cs

示例11: ConvertRecordConst

 private record_constant ConvertRecordConst(common_type_node ctn, record_constant constant)
 {
     location loc = constant.location;
     if (!ctn.is_value_type)
         AddError(loc, "RECORD_CONST_NOT_ALLOWED_{0}", ctn.name);
     if (ctn.fields.Count != constant.record_const_definition_list.Count)
         AddError(loc, "INVALID_RECORD_CONST_FIELD_COUNT");
     constant.SetType(ctn);
     constant.field_values.Clear();
     bool tmp = this.is_typed_const_def;
     this.is_typed_const_def = true;
     for (int i = 0; i < ctn.fields.Count; i++)
     {
         class_field cf = ctn.fields[i];
         if (cf.name.ToLower() != constant.record_const_definition_list[i].name.name.ToLower())
             AddError(get_location(constant.record_const_definition_list[i].name), "FIELD_NAME_SHOULD_BE_EQUAL_RECORD_FIELD_NAME", cf.name);
         constant.field_values.Add(convert_strong_to_constant_node(constant.record_const_definition_list[i].val, cf.type));
     }
     this.is_typed_const_def = tmp;
     return constant;
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:21,代码来源:syntax_tree_visitor.cs

示例12: ConvertRecordInitializer

 private record_initializer ConvertRecordInitializer(common_type_node ctn, record_initializer constant)
 {
 	location loc = constant.location;
     if (!ctn.is_value_type)
         AddError(loc, "RECORD_CONST_NOT_ALLOWED_{0}", ctn.name);
     if (ctn.fields.Count != constant.record_const_definition_list.Count)
         AddError(loc, "INVALID_RECORD_CONST_FIELD_COUNT");
     constant.type = ctn;
     constant.field_values.Clear();
     for (int i = 0; i < ctn.fields.Count; i++)
     {
         class_field cf = ctn.fields[i];
         if (cf.name.ToLower() != constant.record_const_definition_list[i].name.name.ToLower())
             AddError(get_location(constant.record_const_definition_list[i].name), "FIELD_NAME_SHOULD_BE_EQUAL_RECORD_FIELD_NAME", cf.name);
         expression_node en = convert_strong_to_constant_or_function_call_for_varinit(convert_strong(constant.record_const_definition_list[i].val),cf.type);
         en.type = cf.type;
         constant.field_values.Add(en);
     }
     return constant;
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:20,代码来源:syntax_tree_visitor.cs

示例13: check_delegate_on_generic_parameters

 private void check_delegate_on_generic_parameters(common_type_node ctn, location loc)
 {
     if (ctn == null)
         return;
     foreach (common_method_node cmn in ctn.methods)
     {
         if (cmn.name == "Invoke")
         {
             foreach (common_parameter prm in cmn.parameters)
             {
                 if (is_instance_of_generic_parameter(prm.type))
                     AddError(loc, "ANONYMOUS_FUNCTION_TYPE_WITH_GENERICS");
             }
             if (cmn.return_value_type != null && is_instance_of_generic_parameter(cmn.return_value_type))
                 AddError(loc, "ANONYMOUS_FUNCTION_TYPE_WITH_GENERICS");
         }
     }
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:18,代码来源:syntax_tree_visitor.cs

示例14: add_generic_eliminations

 //Добавляет ограничители для параметра шаблона
 private void add_generic_eliminations(common_type_node param, List<SyntaxTree.type_definition> specificators)
 {
     Hashtable used_interfs = new Hashtable();
     for (int i = 0; i < specificators.Count; ++i)
     {
         SyntaxTree.declaration_specificator ds = specificators[i] as SyntaxTree.declaration_specificator;
         if (ds != null)
         {
             switch (ds.specificator)
             {
                 case SyntaxTree.DeclarationSpecificator.WhereDefClass:
                     if (i == 0)
                     {
                         param.is_class = true;
                     }
                     else
                     {
                         AddError(get_location(specificators[i]), "CLASS_OR_RECORD_SPECIFICATOR_MUST_BE_FIRST");
                     }
                     break;
                 case SyntaxTree.DeclarationSpecificator.WhereDefValueType:
                     if (i == 0)
                     {
                         param.internal_is_value = true;
                     }
                     else
                     {
                         AddError(get_location(specificators[i]), "CLASS_OR_RECORD_SPECIFICATOR_MUST_BE_FIRST");
                     }
                     break;
                 case SyntaxTree.DeclarationSpecificator.WhereDefConstructor:
                     if (i == specificators.Count - 1)
                     {
                         generic_parameter_eliminations.add_default_ctor(param);
                         //common_method_node cnode = new common_method_node(
                         //    compiler_string_consts.default_constructor_name, param, null,
                         //    param, SemanticTree.polymorphic_state.ps_common,
                         //    SemanticTree.field_access_level.fal_public, null);
                         //cnode.is_constructor = true;
                         //param.methods.AddElement(cnode);
                         //param.add_name(compiler_string_consts.default_constructor_name, new SymbolInfo(cnode));
                     }
                     else
                     {
                         AddError(get_location(specificators[i]), "CONSTRUCTOR_SPECIFICATOR_MUST_BE_LAST");
                     }
                     break;
             }
         }
         else
         {
             SyntaxTree.named_type_reference ntr = specificators[i] as SyntaxTree.named_type_reference;
             if (ntr == null)
             {
                 AddError(get_location(specificators[i]), "SPECIFICATOR_MUST_BE_TYPE_REFERENCE");
             }
             else
             {
                 type_node spec_type = ret.visit(ntr);
                 if (spec_type is ref_type_node || spec_type == SystemLibrary.SystemLibrary.void_type || spec_type == SystemLibrary.SystemLibrary.pointer_type)
                     ErrorsList.Add(new SimpleSemanticError(get_location(specificators[i]), "INAVLID_TYPE"));
                 if (spec_type.IsInterface)
                 {
                     if (used_interfs[spec_type] != null)
                     {
                         AddError(get_location(specificators[i]), "INTERFACE_{0}_ALREADY_ADDED_TO_IMPLEMENTING_LIST", spec_type.PrintableName);
                     }
                     else
                     {
                         used_interfs.Add(spec_type, spec_type);
                     }
                     //Добавляем интерфейс
                     type_table.AddInterface(param, spec_type, get_location(specificators[i]));
                 }
                 else
                 {
                     if (i != 0)
                     {
                         AddError(get_location(specificators[i]), "PARENT_SPECIFICATOR_MUST_BE_FIRST");
                     }
                     else
                     {
                         //Тип-предок
                         if (spec_type == SystemLibrary.SystemLibrary.object_type)
                         {
                             AddError(get_location(specificators[i]), "OBJECT_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR");
                         }
                         if (spec_type == SystemLibrary.SystemLibrary.enum_base_type)
                         {
                             AddError(get_location(specificators[i]), "ENUM_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR");
                         }
                         check_cycle_inheritance(param, spec_type);
                         param.SetBaseType(spec_type);
                     }
                 }
             }
         }
     }
     InitInterfaceScope(param);
//.........这里部分代码省略.........
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:101,代码来源:syntax_tree_visitor.cs

示例15: GetExtTypeReference

        //получение ссылки на тип, описанный в другом модуле
		private int GetExtTypeReference(common_type_node ctn)
		{
            ImportedEntity ie = null;
            if (ext_members.TryGetValue(ctn, out ie))
            {
                return ie.index * ie.GetSize();
            }
			ie = new ImportedEntity();
			ie.flag = ImportKind.Common;
			ie.num_unit = GetUnitToken(ctn.comprehensive_namespace);
			ie.offset = GetExternalOffset(ctn);
			int offset = imp_entitles.Count*ie.GetSize();
            ie.index = imp_entitles.Count;
            imp_entitles.Add(ie);
			ext_members[ctn] = ie;
			return offset;
		}
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:18,代码来源:PCUWriter.cs


注:本文中的PascalABCCompiler.TreeRealization.common_type_node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。