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


C# TreeRealization.expression_node类代码示例

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


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

示例1: clip_expression_if_need

 private expression_node clip_expression_if_need(expression_node expr, type_node tn)
 {
 	if (!(tn is short_string_type_node) && tn.type_special_kind != SemanticTree.type_special_kind.set_type)
 		return expr;
 	if (tn is short_string_type_node)
 	{
 		return convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as function_node,null,convertion_data_and_alghoritms.convert_type(expr,SystemLibrary.SystemLibrary.string_type),new int_const_node((tn as short_string_type_node).Length,null));
 	}
     else if (tn.type_special_kind == SemanticTree.type_special_kind.set_type && tn.element_type != null)
     {
         ordinal_type_interface oti = tn.element_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
         if (oti != null)
         {
             base_function_call cmc = null;
             if (SystemLibrary.SystemLibInitializer.ClipFunction.sym_info is common_namespace_function_node)
                 cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipFunction.sym_info as common_namespace_function_node, null);
             else
                 cmc = new compiled_static_method_call(SystemLibrary.SystemLibInitializer.ClipFunction.sym_info as compiled_function_node, null);
             cmc.parameters.AddElement(expr);
             cmc.parameters.AddElement(oti.lower_value.get_constant_copy(null));
             cmc.parameters.AddElement(oti.upper_value.get_constant_copy(null));
             cmc.ret_type = tn;
             return cmc;
         }
         else if (tn.element_type.type_special_kind == SemanticTree.type_special_kind.short_string)
         {
             base_function_call cmc = null;
             if (SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info is common_namespace_function_node)
                 cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info as common_namespace_function_node, null);
             else
                 cmc = new compiled_static_method_call(SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info as compiled_function_node, null);
             cmc.parameters.AddElement(expr);
             cmc.parameters.AddElement(new int_const_node((tn.element_type as short_string_type_node).Length, null));
             cmc.ret_type = tn;
             return cmc;
         }
     }
 	return expr;
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:39,代码来源:syntax_tree_visitor.cs

示例2: CheckAssign

 private void CheckAssign(expression_node p)
 {
     switch (p.semantic_node_type)
     {
         case semantic_node_type.local_variable_reference: IncreaseNumAssVar((local_variable_reference)p); break;
         case semantic_node_type.namespace_variable_reference: IncreaseNumAssVar((namespace_variable_reference)p); break;
         case semantic_node_type.class_field_reference: VisitExpression((p as class_field_reference).obj); IncreaseNumAssField((class_field_reference)p); break;
         case semantic_node_type.static_class_field_reference: IncreaseNumAssField((static_class_field_reference)p); break;
         case semantic_node_type.common_parameter_reference: IncreaseNumAssParam((common_parameter_reference)p); break;
         case semantic_node_type.deref_node: CheckAssign(((dereference_node)p).deref_expr); break;
     }
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:12,代码来源:Optimizer.cs

示例3: GetConstantValue

 private RetVal GetConstantValue(expression_node en)
 {
     if (en is bool_const_node)
     {
         if ((en as bool_const_node).constant_value) return RetVal.True;
         else return RetVal.False;
     }
     else return RetVal.Undef;
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:9,代码来源:Optimizer.cs

示例4: dec_compile_time_executor

 private static expression_node dec_compile_time_executor(location call_location, expression_node[] expr)
 {
     return null;
 }
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:4,代码来源:StaticSystemLib.cs

示例5: SaveExpressionAndOffset

 private void SaveExpressionAndOffset(expression_node expr)
 {
 	List<int> lst = null;
 	if (!exprs_cache.ContainsKey(expr))
 	{
 		lst = new List<int>();
 		exprs_cache[expr] = lst;
 	}
 	else lst = exprs_cache[expr];
 	lst.Add((int)bw.BaseStream.Position);
 	//System.Diagnostics.Debug.WriteLine((int)bw.BaseStream.Position);
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:12,代码来源:PCUWriter.cs

示例6: convert_const_to_switch

        private int_const_node convert_const_to_switch(expression_node switch_expr,
            ordinal_type_interface oti, type_node case_expr_type, location loc)
        {
            convertion_data_and_alghoritms.convert_type(switch_expr, case_expr_type, loc);
            if (switch_expr is int_const_node)
                return switch_expr as int_const_node;
            //switch_expr = convertion_data_and_alghoritms.create_simple_function_call(oti.value_to_int,
            //    loc, switch_expr);
            int_const_node icn = null;//switch_expr as constant_node;

            if (switch_expr is byte_const_node)
                icn = new int_const_node((switch_expr as byte_const_node).constant_value, loc);
            else if (switch_expr is sbyte_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as sbyte_const_node).constant_value), loc);
            else if (switch_expr is short_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as short_const_node).constant_value), loc);
            else if (switch_expr is ushort_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as ushort_const_node).constant_value), loc);
            /*else if (switch_expr is uint_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as uint_const_node).constant_value),loc);
            else if (switch_expr is long_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as long_const_node).constant_value),loc);
            else if (switch_expr is ulong_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as ulong_const_node).constant_value),loc);*/
            else if (switch_expr is bool_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as bool_const_node).constant_value), loc);
            else if (switch_expr is char_const_node)
                icn = new int_const_node(Convert.ToInt32((switch_expr as char_const_node).constant_value), loc);
            else if (switch_expr is enum_const_node)
                icn = new int_const_node((switch_expr as enum_const_node).constant_value, loc);
            else if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral)
                icn = new int_const_node((int)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc);

            //учти здесь модет быть и long!
            //-DarkStar Add
            if (icn == null)
            {
                AddError(loc, "CONSTANT_EXPRESSION_EXPECTED");
            }
            return icn;
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:41,代码来源:syntax_tree_visitor.cs

示例7: return_node

		public return_node(expression_node return_expr,location loc) : base(loc)
		{
			_return_expr=return_expr;
		}
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:4,代码来源:functions.cs

示例8: check_on_loop_variable

 private void check_on_loop_variable(expression_node en)
 {
 	if (context.is_in_cycle() && !SemanticRules.AllowChangeLoopVariable)
 		if (en.semantic_node_type == semantic_node_type.namespace_variable_reference)
 		{
 			if (context.is_loop_variable((en as namespace_variable_reference).var))
                 AddError(en.location, "CANNOT_ASSIGN_TO_LOOP_VARIABLE");
 		}
 		else if (en.semantic_node_type == semantic_node_type.local_variable_reference)
 		{
 			if (context.is_loop_variable((en as local_variable_reference).var))
                 AddError(en.location, "CANNOT_ASSIGN_TO_LOOP_VARIABLE");
 		}
 		else if (en.semantic_node_type == semantic_node_type.local_block_variable_reference)
 		{
 			if (context.is_loop_variable((en as local_block_variable_reference).var))
                 AddError(en.location, "CANNOT_ASSIGN_TO_LOOP_VARIABLE");
 		}
 		
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:20,代码来源:syntax_tree_visitor.cs

示例9: create_with_expression

		private expression_node create_with_expression(expression_node expr)
		{
			location sl = expr.location;
			switch (expr.semantic_node_type)
			{
				case semantic_node_type.common_namespace_function_call:
				case semantic_node_type.common_in_function_function_call:
				case semantic_node_type.common_method_call:
				case semantic_node_type.common_static_method_call:
				case semantic_node_type.compiled_function_call:
				case semantic_node_type.compiled_constructor_call:
				case semantic_node_type.common_constructor_call:
				case semantic_node_type.compiled_static_method_call:
					return convertion_data_and_alghoritms.CreateVariableReference(context.add_var_definition(compiler_string_consts.GetTempVariableName(), sl, expr.type, expr), sl);
				case semantic_node_type.class_field_reference:
					(expr as class_field_reference).obj = create_with_expression((expr as class_field_reference).obj);
					return expr;
				case semantic_node_type.compiled_variable_reference:
					(expr as compiled_variable_reference).obj = create_with_expression((expr as compiled_variable_reference).obj);
					return expr;
				case semantic_node_type.simple_array_indexing:
					simple_array_indexing sar = expr as simple_array_indexing;
					sar.simple_arr_expr = create_with_expression(sar.simple_arr_expr);
					sar.ind_expr = create_with_expression(sar.ind_expr);
					return sar;
				case semantic_node_type.deref_node:
					(expr as dereference_node).deref_expr = create_with_expression((expr as dereference_node).deref_expr);
					return expr;
				case semantic_node_type.basic_function_call:
					return convertion_data_and_alghoritms.CreateVariableReference(context.add_var_definition(compiler_string_consts.GetTempVariableName(), sl, expr.type, expr), sl);
				case semantic_node_type.as_node:
					return convertion_data_and_alghoritms.CreateVariableReference(context.add_var_definition(compiler_string_consts.GetTempVariableName(), sl, expr.type, expr), sl);
			}
			return expr;
		}
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:35,代码来源:syntax_tree_visitor.cs

示例10: get_set_initializer

 private expressions_list get_set_initializer(expression_node cnfc)
 {
     return set_intls[cnfc];
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:4,代码来源:syntax_tree_visitor.cs

示例11: add_set_initializer

 private void add_set_initializer(expression_node cnfc, expressions_list exprs)
 {
     set_intls[cnfc] = exprs;
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:4,代码来源:syntax_tree_visitor.cs

示例12: make_assign_operator

 internal expression_node make_assign_operator(addressed_expression left, expression_node right, location loc)
 {
     return find_operator(compiler_string_consts.assign_name, left, right, loc);
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:4,代码来源:syntax_tree_visitor.cs

示例13: get_init_call_for_set_as_constr

        internal expression_node get_init_call_for_set_as_constr(var_definition_node vdn, expression_node init_value)
        {
            location loc = (vdn.type as common_type_node).loc;
            if (!SystemUnitAssigned)
                AddError(new NotSupportedError(loc));
            //Когда заработает наследование конструкторов надо вставить это
            /*
            expression_node var_ref = create_variable_reference(vdn, loc);
            expressions_list exl = new expressions_list();
            exl.AddElement(new typeof_operator(element_type, loc));
            base_function_call bfc = create_constructor_call(vdn.type, exl, loc);
            expression_node expr = find_operator(compiler_string_consts.assign_name, var_ref, bfc, loc);
            */

            type_node tn = vdn.type;
            vdn.type = SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node;

            expression_node var_ref = create_variable_reference(vdn, loc);
            expressions_list exl = new expressions_list();
            //exl.AddElement(var_ref);
            //exl.AddElement(new typeof_operator(element_type, loc));
            if (tn.element_type == SystemLibrary.SystemLibrary.byte_type)
            {
            	exl.AddElement(new byte_const_node(byte.MinValue,null));
            	exl.AddElement(new byte_const_node(byte.MaxValue,null));
            }
            else if (tn.element_type == SystemLibrary.SystemLibrary.sbyte_type)
            {
            	exl.AddElement(new sbyte_const_node(sbyte.MinValue,null));
            	exl.AddElement(new sbyte_const_node(sbyte.MaxValue,null));
            }
            else if (tn.element_type == SystemLibrary.SystemLibrary.short_type)
            {
            	exl.AddElement(new short_const_node(short.MinValue,null));
            	exl.AddElement(new short_const_node(short.MaxValue,null));
            }
            else if (tn.element_type == SystemLibrary.SystemLibrary.ushort_type)
            {
            	exl.AddElement(new ushort_const_node(ushort.MinValue,null));
            	exl.AddElement(new ushort_const_node(ushort.MaxValue,null));
            }
            else if (tn.element_type.type_special_kind == SemanticTree.type_special_kind.diap_type || tn.element_type.type_special_kind == SemanticTree.type_special_kind.enum_kind)
            {
            	ordinal_type_interface ii = tn.element_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
            	exl.AddElement(ii.lower_value);
            	exl.AddElement(ii.upper_value);
            }
            exl.AddElement(init_value);
            function_node fn = null;
            if (exl.Count > 1)
            {
                fn = convertion_data_and_alghoritms.select_function(exl, (SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node).find_in_type(compiler_string_consts.default_constructor_name), loc);
            }
            else
            {
                fn = convertion_data_and_alghoritms.select_function(exl, (SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node).find_in_type(compiler_string_consts.default_constructor_name), loc);
            }
            //expression_node expr = convertion_data_and_alghoritms.create_simple_function_call(fn, null, exl.ToArray());
            expression_node expr = create_static_method_call_with_params(fn, loc, tn, false, exl);
            vdn.type = tn;

            return expr;
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:63,代码来源:syntax_tree_visitor.cs

示例14: visit

 public override void visit(SyntaxTree.try_stmt _try_stmt)
 {
     context.enter_code_block_without_bind();
     context.enter_exception_handlers();
     statement_node try_statements = convert_strong(_try_stmt.stmt_list);
     context.leave_code_block();
     location loc = get_location(_try_stmt);
     exception_filters_list efl = new exception_filters_list();
     SyntaxTree.try_handler_except try_hand_except = _try_stmt.handler as SyntaxTree.try_handler_except;
     if (try_hand_except != null)
     {
         if (try_hand_except.except_block.handlers != null)
         {
             int hand_count = try_hand_except.except_block.handlers.handlers.Count;
             for (int i = 0; i < hand_count; i++)
             {
                 SyntaxTree.exception_handler eh = try_hand_except.except_block.handlers.handlers[i];
                 type_node filter_type = convert_strong(eh.type_name);
                 if (!SemanticRules.GenerateNativeCode && !(filter_type.is_generic_parameter ||
                     filter_type == SystemLibrary.SystemLibrary.exception_base_type ||
                     type_table.is_derived(SystemLibrary.SystemLibrary.exception_base_type, filter_type)))
                 {
                     AddError(get_location(eh.type_name), "EXCEPTION_TYPE_MUST_BE_SYSTEM_EXCEPTION_OR_DERIVED_FROM_EXCEPTION");
                 }
                 current_catch_excep = new int_const_node(2,null);//create_constructor_call(filter_type, new expressions_list(), null);
                 local_block_variable_reference lvr = null;
                 
                 context.enter_code_block_without_bind();
                 if (eh.variable != null)
                 {
                 	
                 	context.check_name_redefinition = false;
                 	
                 	local_block_variable lbv = context.add_var_definition(eh.variable.name, get_location(eh.variable), filter_type, SemanticTree.polymorphic_state.ps_common) as local_block_variable;
                     context.check_name_redefinition = true;
                 	lvr = new local_block_variable_reference(lbv, lbv.loc);
                 }
                 statement_node stm = convert_strong(eh.statements);
                 context.leave_code_block();
                 
                 /*if (eh.variable != null)
                 {
                     context.leave_scope();
                 }*/
                 exception_filter ef = new exception_filter(filter_type, lvr, stm, get_location(eh));
                 efl.AddElement(ef);
                 current_catch_excep = null;
             }
         }
         else
         {
             context.enter_code_block_without_bind();
             exception_filter ef = new exception_filter(null, null, convert_strong(try_hand_except.except_block.stmt_list), get_location(try_hand_except.except_block.stmt_list));
             context.leave_code_block();
             efl.AddElement(ef);
         }
         if (try_hand_except.except_block.else_stmt_list != null)
         {
             context.enter_code_block_without_bind();
             statement_node else_stm = convert_strong(try_hand_except.except_block.else_stmt_list);
             context.leave_code_block();
             type_node ftype = SystemLibrary.SystemLibrary.object_type;
             exception_filter else_ef = new exception_filter(ftype, null, else_stm, else_stm.location);
             efl.AddElement(else_ef);
         }
     }
     else
     {
     	type_node filter_type = compiled_type_node.get_type_node(NetHelper.NetHelper.FindType(compiler_string_consts.ExceptionName));
     	expression_node current_catch_excep = create_constructor_call(filter_type, new expressions_list(), null);
         local_block_variable_reference lvr = null;
         local_block_variable tmp_var = context.add_var_definition(context.BuildName("$try_temp" + UniqueNumStr()), null, SystemLibrary.SystemLibrary.bool_type, null) as local_block_variable;
         statements_list stm = new statements_list(null);
         SyntaxTree.try_handler_finally try_hndlr_finally = _try_stmt.handler as SyntaxTree.try_handler_finally;
         context.enter_code_block_without_bind();
         statement_node finally_stmt = convert_strong(try_hndlr_finally.stmt_list);
         context.leave_code_block();
         stm.statements.AddElement(finally_stmt);
         basic_function_call bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_not as basic_function_node,null);
         bfc.parameters.AddElement(new local_block_variable_reference(tmp_var,null));
         stm.statements.AddElement(new if_node(bfc,new rethrow_statement_node(null),null,null));
     	exception_filter ef = new exception_filter(filter_type, lvr, stm, null);
         efl.AddElement(ef);
         bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_assign as basic_function_node,null);
         bfc.parameters.AddElement(new local_block_variable_reference(tmp_var,null));
         bfc.parameters.AddElement(new bool_const_node(true,null));
         
         (try_statements as statements_list).statements.AddElement(bfc);
         (try_statements as statements_list).statements.AddElement(new throw_statement_node(current_catch_excep,null));
         return_value(new try_block(try_statements, null, efl, loc));
         context.leave_exception_handlers();
         return;
     }
     statement_node finally_st = null;
     SyntaxTree.try_handler_finally try_handler_finally = _try_stmt.handler as SyntaxTree.try_handler_finally;
     if (try_handler_finally != null)
     {
         context.enter_code_block_without_bind();
         finally_st = convert_strong(try_handler_finally.stmt_list);
         context.leave_code_block();
//.........这里部分代码省略.........
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:101,代码来源:syntax_tree_visitor.cs

示例15: dot_node_as_expression_dot_ident

        private void dot_node_as_expression_dot_ident(expression_node en, SyntaxTree.ident id_right, motivation mot, addressed_value syntax_node)
        {
            if (en is typed_expression)
                try_convert_typed_expression_to_function_call(ref en);
            SymbolInfo si = en.type.find_in_type(id_right.name, context.CurrentScope);
            if (si == null)
            {
                AddError(new MemberIsNotDeclaredInType(id_right, get_location(id_right), en.type));
            }

            try_convert_typed_expression_to_function_call(ref en);

            /*
            if (en.semantic_node_type == semantic_node_type.typed_expression)
            {
                type_node tn11=en.type;
                delegated_methods dm11=tn11 as delegated_methods;
                if (dm11!=null)
                {
                    en = dm11.empty_param_method;
                }
            }
            */

            switch (mot)
            {
                case motivation.address_reciving:
                    {
                        return_addressed_value(address_expression_reciving(id_right, si, en));
                        return;
                    }
                case motivation.expression_evaluation:
                    {
                        //en = expression_value_reciving(id_right, si, en, true);
            			//try_convert_typed_expression_to_function_call(ref en);
            			//return_value(en);
                        if (si.sym_info is function_node && (si.sym_info as function_node).is_extension_method)
                        {
                            dot_node dnode = new dot_node(syntax_node, id_right);
                            method_call mc = new method_call(dnode, new expression_list());
                            mc.visit(this);
                            return;
                        }
                        return_value(expression_value_reciving(id_right, si, en, true));
                        return;
                    }
                case motivation.semantic_node_reciving:
                    {
                        return_semantic_value(expression_value_reciving(id_right, si, en, true));
                        return;
                    }
            }
            throw new CompilerInternalError("Invalid motivation.");
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:54,代码来源:syntax_tree_visitor.cs


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