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


C# type_node.find_in_type方法代码示例

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


在下文中一共展示了type_node.find_in_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: mark_byte_as_ordinal

        /*
        private static void mark_byte_as_ordinal()
        {
            basic_function_node inc_value_method = create_inc_value_method(SemanticTree.basic_function_type.binc, _byte_type);
            basic_function_node dec_value_method = create_dec_value_method(SemanticTree.basic_function_type.bdec, _byte_type);

            basic_function_node inc_method = create_inc_method(SemanticTree.basic_function_type.binc, _byte_type);
            basic_function_node dec_method = create_dec_method(SemanticTree.basic_function_type.bdec, _byte_type);

            SymbolInfo si = _byte_type.find_in_type(compiler_string_consts.greq_name);
            basic_function_node greq = (basic_function_node)si.sym_info;

            si = _byte_type.find(compiler_string_consts.smeq_name);
            basic_function_node loeq = (basic_function_node)si.sym_info;

            constant_node cn_max = new byte_const_node(byte.MaxValue, null);
            constant_node cn_min = new byte_const_node(byte.MinValue, null);

            basic_function_node i2i_method = create_emty_function(byte_type);

            ordinal_type_to_int ordinal_type_to_int = byte_to_int;

            ordinal_type_interface oti = new ordinal_type_interface(inc_method, dec_method, inc_value_method, dec_value_method,
                internal_inc_value, internal_dec_value, loeq, greq, cn_min, cn_max, i2i_method, ordinal_type_to_int);

            _byte_type.add_internal_interface(oti);
        }
        */
        private static void mark_type_as_ordinal(type_node type,
            SemanticTree.basic_function_type inc,SemanticTree.basic_function_type dec,
            SemanticTree.basic_function_type vinc, SemanticTree.basic_function_type vdec,
            constant_node lower_value, constant_node upper_value,
            function_node t2i,ordinal_type_to_int t2i_comp)
        {
            basic_function_node inc_value = create_oti_method(inc, type, SemanticTree.parameter_type.value);
            basic_function_node dec_value = create_oti_method(dec, type, SemanticTree.parameter_type.value);

            basic_function_node inc_var = create_oti_method(vinc, type, SemanticTree.parameter_type.var);
            basic_function_node dec_var = create_oti_method(vdec, type, SemanticTree.parameter_type.var);

            SymbolInfo si = type.find_in_type(compiler_string_consts.greq_name);
            basic_function_node greq = (basic_function_node)si.sym_info;
        
            si = type.find(compiler_string_consts.smeq_name);
            basic_function_node loeq = (basic_function_node)si.sym_info;
			
            si = type.find(compiler_string_consts.sm_name);
            basic_function_node lo = (basic_function_node)si.sym_info;
            
            si = type.find(compiler_string_consts.gr_name);
            basic_function_node gr = (basic_function_node)si.sym_info;
            
            ordinal_type_interface oti = new ordinal_type_interface(inc_value, dec_value, inc_var, dec_var,
                loeq, greq, lo, gr, lower_value, upper_value, t2i, t2i_comp);

            type.add_internal_interface(oti);
        }
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:57,代码来源:StaticSystemLib.cs

示例2: dot_node_as_type_ident

 private void dot_node_as_type_ident(type_node tn, SyntaxTree.ident id_right, motivation mot)
 {
     SymbolInfo si_right = tn.find_in_type(id_right.name, context.CurrentScope);
     if (si_right == null)
     {
         AddError(new MemberIsNotDeclaredInType(id_right, get_location(id_right), tn));
     }
     switch (mot)
     {
         case motivation.address_reciving:
             {
                 return_addressed_value(create_addressed_with_type_expression(tn, id_right, si_right));
                 return;
             }
         case motivation.expression_evaluation:
             {
                 return_value(create_static_expression(tn, id_right, si_right));
                 return;
             }
         case motivation.semantic_node_reciving:
             {
                 if (si_right.sym_info.general_node_type == general_node_type.type_node)
                     return_semantic_value(si_right.sym_info as type_node);
                 else
                     return_semantic_value(create_static_expression(tn, id_right, si_right));
                 return;
             }
     }
     throw new CompilerInternalError("Invalid motivation");
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:30,代码来源:syntax_tree_visitor.cs

示例3: type_has_default_ctor

 public static bool type_has_default_ctor(type_node tn, bool find_protected_ctors)
 {
     SymbolInfo si = tn.find_in_type(compiler_string_consts.default_constructor_name, tn.Scope);
     while (si != null)
     {
         function_node fn = si.sym_info as function_node;
         if (find_protected_ctors ||
             fn.field_access_level == PascalABCCompiler.SemanticTree.field_access_level.fal_public)
         {
             compiled_constructor_node pconstr = fn as compiled_constructor_node;
             common_method_node mconstr = fn as common_method_node;
             if ((pconstr != null ||
                 mconstr != null && mconstr.is_constructor) &&
                 (fn.parameters.Count == 0 || fn.parameters[0].default_value != null)
                 )
             {
                 //Нашли конструктор по умолчанию у предка
                 return true;
             }
         }
         si = si.Next;
     }
     return false;
 }
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:24,代码来源:generics.cs

示例4: create_constructor_call

        private base_function_call create_constructor_call(type_node tn, expressions_list exprs, location loc, Tuple<bool, List<SyntaxTree.expression>> lambdas_info = null)
        {
            if (tn.IsInterface)
            {
            	AddError(loc, "INTERFACE_{0}_CONSTRUCTOR_CALL", tn.name);
            }
            if (tn.IsAbstract)
            {
            	AddError(loc, "ABSTRACT_CONSTRUCTOR_{0}_CALL", tn.name);
            }
            SymbolInfo si = tn.find_in_type(TreeConverter.compiler_string_consts.default_constructor_name, context.CurrentScope); //tn.Scope); 
            delete_inherited_constructors(ref si, tn);
            if (si == null)
                AddError(loc, "CONSTRUCTOR_NOT_FOUND");
            function_node fnn = null;
            try
            {
                #region Если встретились лямбды в фактических параметрах, то выбираем нужную функцию из перегруженных, выводим типы, отмечаем флаг в лямбдах, говорящий о том, что мы их реально обходим 
                //lroman//
                if (lambdas_info != null && lambdas_info.Item1)
                {
                    LambdaHelper.processingLambdaParametersForTypeInference++;
                    var syntax_nodes_parameters = lambdas_info.Item2;

                    // SSM 21.05.14 - попытка обработать перегруженные функции с параметрами-лямбдами с различными возвращаемыми значениями
                    function_node_list spf = null;
                    try
                    {
                        function_node fn = convertion_data_and_alghoritms.select_function(exprs, si, loc,
                                                                                          syntax_nodes_parameters);
                        int exprCounter = 0;
                        foreach (SyntaxTree.expression en in syntax_nodes_parameters)
                        {
                            if (!(en is SyntaxTree.function_lambda_definition))
                            {
                                exprCounter++;
                                continue;
                            }
                            else
                            {
                                var enLambda = (SyntaxTree.function_lambda_definition)en;
                                LambdaHelper.InferTypesFromVarStmt(fn.parameters[exprCounter].type, enLambda, this);
                                enLambda.lambda_visit_mode = LambdaVisitMode.VisitForAdvancedMethodCallProcessing;
                                exprs[exprCounter] = convert_strong(en);
                                enLambda.lambda_visit_mode = LambdaVisitMode.VisitForInitialMethodCallProcessing;
                                exprCounter++;
                            }
                        }
                    }
                    catch (SeveralFunctionsCanBeCalled sf)
                    {
                        spf = sf.set_of_possible_functions;
                            // Возможны несколько перегруженных версий - надо выводить дальше в надежде что какие-то уйдут и останется одна
                    }

                    Exception lastmultex = null;
                    if (spf != null) // пытаемся инстанцировать одну за другой и ошибки гасим try
                    {
                        // exprs - глобальная, поэтому надо копировать
                        int spfnum = -1; // spfnum - первый номер правильно инстанцированной. Пока -1. Если потом встретился второй, то тоже ошибка
                        int GoodVersionsCount = 0;
                        int GoodVersionsCountWithSameResType = 0;
                        for (int i = 0; i < spf.Count; i++)
                        {
                            function_node fn = spf[i];
                            try
                            {
                                int exprCounter = 0;
                                expressions_list exprs1 = new expressions_list();
                                exprs1.AddRange(exprs); // сделали копию

                                foreach (SyntaxTree.expression en in syntax_nodes_parameters)
                                {
                                    if (!(en is SyntaxTree.function_lambda_definition))
                                    {
                                        exprCounter++;
                                        continue;
                                    }
                                    else
                                    {
                                        var fld = en as SyntaxTree.function_lambda_definition;

                                        var lambdaName = fld.lambda_name; //lroman Сохранять имя необходимо
                                        var fl = fld.lambda_visit_mode;

                                        // запомнили типы параметров лямбды - SSM
                                        object[] realparamstype = new object[fld.formal_parameters.params_list.Count];
                                            // здесь хранятся выведенные типы лямбд или null если типы явно заданы
                                        for (var k = 0; k < fld.formal_parameters.params_list.Count; k++)
                                        {
                                            var laminftypeK =
                                                fld.formal_parameters.params_list[k].vars_type as
                                                SyntaxTree.lambda_inferred_type;
                                            if (laminftypeK == null)
                                                realparamstype[k] = null;
                                            else realparamstype[k] = laminftypeK.real_type;
                                        }

                                        // запоминаем реальный тип возвращаемого значения если он не указан явно (это должен быть any_type или null если он указан явно) - он может измениться при следующем вызове, поэтому мы его восстановим
                                        var restype = fld.return_type as SyntaxTree.lambda_inferred_type;
//.........这里部分代码省略.........
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:101,代码来源:syntax_tree_visitor.cs

示例5: create_array_type

		private type_node create_array_type(ordinal_type_interface oti_indexer, type_node element_type,common_namespace_node _cmn, location loc)
		{
			int arr_length = oti_indexer.ordinal_type_to_int(oti_indexer.upper_value) -
				oti_indexer.ordinal_type_to_int(oti_indexer.lower_value) + 1;

			if (arr_length <= 0)
			{
				throw new SimpleSemanticError(loc, "NEGATIVE_ARRAY_LENGTH_({0})_NOT_ALLOWED", arr_length);
			}

			simple_array sa = new simple_array(element_type, arr_length);
			//sa.length = arr_length;
			//sa.element_type = element_type;

			SymbolTable.Scope top_scope = null;
			if (_cmn != null)
			{
				top_scope = _cmn.scope;
			}
			string name = get_pascal_array_name();
			//if (_cmn.namespace_name != null)
			//    name = _cmn.namespace_name + name;
			common_type_node ctn = new common_type_node(null, name, SemanticTree.type_access_level.tal_public,
			                                            _cmn, convertion_data_and_alghoritms.symbol_table.CreateClassScope(top_scope, null), loc);

			ctn.SetBaseType(SystemLibrary.SystemLibrary.object_type);
			//DarkStar Add
			//loc не нужно мне это!  и некому не нужно!
			//loc = null;
			
			//ctn.internal_is_value = true;

			class_constant_definition cdn1 = new class_constant_definition(compiler_string_consts.lower_array_const_name,
			                                                               oti_indexer.lower_value, loc, ctn, SemanticTree.field_access_level.fal_public);
			ctn.scope.AddSymbol(cdn1.name, new SymbolInfo(cdn1));

			class_constant_definition cdn2 = new class_constant_definition(compiler_string_consts.upper_array_const_name,
			                                                               oti_indexer.upper_value, loc, ctn, SemanticTree.field_access_level.fal_public);
			ctn.scope.AddSymbol(cdn2.name, new SymbolInfo(cdn2));

			class_field int_arr = new class_field(compiler_string_consts.internal_array_name, sa, ctn,
			                                      SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_public,loc);
			ctn.scope.AddSymbol(int_arr.name, new SymbolInfo(int_arr));
			ctn.fields.AddElement(int_arr);

			SystemLibrary.SystemLibrary.init_reference_type(ctn);

			ctn.const_defs.AddElement(cdn1);
			ctn.const_defs.AddElement(cdn2);

			common_method_node get_func = new common_method_node(compiler_string_consts.get_val_pascal_array_name,
			                                                     element_type, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private,
			                                                     convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope));
			common_parameter get_param = new common_parameter(compiler_string_consts.unary_param_name,
			                                                  oti_indexer.lower_value.type, SemanticTree.parameter_type.value, get_func, concrete_parameter_type.cpt_none,
			                                                  null, loc);
			get_func.parameters.AddElement(get_param);

			common_parameter_reference cpr = new common_parameter_reference(get_param, 0, loc);
			expression_node en1 = convertion_data_and_alghoritms.create_simple_function_call(oti_indexer.value_to_int,
			                                                                                 loc, cpr);
			expression_node en2 = new int_const_node(oti_indexer.ordinal_type_to_int(oti_indexer.lower_value), loc);
			expression_node sub_expr = convertion_data_and_alghoritms.create_simple_function_call(
				SystemLibrary.SystemLibrary.int_sub, loc, en1, en2);

			this_node thisnode = new this_node(ctn, loc);

			class_field_reference cfr1 = new class_field_reference(int_arr, thisnode, loc);

			expression_node index_expr = new simple_array_indexing(cfr1, sub_expr, element_type, loc);

			statement_node sn = new return_node(index_expr, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc));

			get_func.function_code = sn;

			common_method_node set_func = new common_method_node(compiler_string_consts.set_val_pascal_array_name,
			                                                     null, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private,
			                                                     convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope));
			common_parameter set_ind = new common_parameter(compiler_string_consts.left_param_name,
			                                                oti_indexer.lower_value.type, SemanticTree.parameter_type.value, set_func, concrete_parameter_type.cpt_none,
			                                                null, loc);
			set_func.parameters.AddElement(set_ind);
			common_parameter set_val = new common_parameter(compiler_string_consts.right_param_name,
			                                                element_type, SemanticTree.parameter_type.value, set_func, concrete_parameter_type.cpt_none, null, loc);
			set_func.parameters.AddElement(set_val);

			common_parameter_reference cpr2 = new common_parameter_reference(set_ind, 0, loc);
			expression_node en3 = convertion_data_and_alghoritms.create_simple_function_call(oti_indexer.value_to_int,
			                                                                                 loc, cpr2);
			expression_node en4 = new int_const_node(oti_indexer.ordinal_type_to_int(oti_indexer.lower_value), loc);
			expression_node sub_expr2 = convertion_data_and_alghoritms.create_simple_function_call(
				SystemLibrary.SystemLibrary.int_sub, loc, en3, en4);

			class_field_reference cfr2 = new class_field_reference(int_arr, thisnode, loc);

			expression_node index_expr2 = new simple_array_indexing(cfr2, sub_expr2, element_type,loc);

			SymbolInfo si = element_type.find_in_type(compiler_string_consts.assign_name);
			if (si == null)
			{
//.........这里部分代码省略.........
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:101,代码来源:type_constructor.cs


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