private void add_overloads_for_default_parameter()
        {
            List<parameter> default_params = new List<parameter>();
            foreach (parameter p in top_function.parameters)
            {
                if (p.default_value != null)
                {
                    default_params.Add(p);
                }
            }
            int num_of_defaults = default_params.Count-1;
            if (default_params.Count > 0 && converted_func_stack.size == 1)
                while (num_of_defaults >= 0)
                {

                    if (converted_type == null)
                    {
                        common_namespace_function_node cnfn = new common_namespace_function_node(top_function.name, top_function.return_value_type, null, converted_namespace, null);
                        foreach (parameter p in top_function.parameters)
                        {
                            if (p.default_value == null)
                                cnfn.parameters.AddElement(p);
                        }
                        for (int i = 0; i < num_of_defaults; i++)
                            cnfn.parameters.AddElement(default_params[i]);
                        statements_list sl = new statements_list(null);
                        common_namespace_function_call cnfc = new common_namespace_function_call(top_function as common_namespace_function_node, null);
                        foreach (common_parameter p in cnfn.parameters)
                        {
                            cnfc.parameters.AddElement(new common_parameter_reference(p, 0, null));
                        }
                        for (int i = num_of_defaults; i < default_params.Count; i++)
                            cnfc.parameters.AddElement(default_params[i].default_value);
                        if (cnfn.return_value_type != null)
                            sl.statements.AddElement(new return_node(cnfc, null));
                        else
                            sl.statements.AddElement(cnfc);
                        cnfn.function_code = sl;
                        converted_namespace.functions.AddElement(cnfn);
                    }
                    else
                    {
                        common_method_node cmn = top_function as common_method_node;
                        common_method_node cnfn = new common_method_node(top_function.name, top_function.return_value_type, null, converted_type, top_function.polymorphic_state, top_function.field_access_level, null);
                        foreach (parameter p in top_function.parameters)
                        {
                            if (p.default_value == null)
                                cnfn.parameters.AddElement(p);
                        }
                        for (int i = 0; i < num_of_defaults; i++)
                            cnfn.parameters.AddElement(default_params[i]);
                        statements_list sl = new statements_list(null);
                        common_method_call cnfc = new common_method_call(cmn, (cnfn.polymorphic_state != SemanticTree.polymorphic_state.ps_static) ? new this_node(converted_type, null) : null, null);
                        foreach (common_parameter p in cnfn.parameters)
                        {
                            cnfc.parameters.AddElement(new common_parameter_reference(p, 0, null));
                        }
                        for (int i = num_of_defaults; i < default_params.Count; i++)
                            cnfc.parameters.AddElement(default_params[i].default_value);
                        if (cnfn.return_value_type != null)
                            sl.statements.AddElement(new return_node(cnfc, null));
                        else
                            sl.statements.AddElement(cnfc);
                        cnfn.function_code = sl;
                        cnfn.is_constructor = cmn.is_constructor;
                        converted_type.methods.AddElement(cnfn);
                    }
                    num_of_defaults--;
                }
        }
        private void VisitFunctionDefinition(common_namespace_function_node func)
        {
            int pos;
            if (is_interface == true)
                pos = SavePositionAndConstPool(func);
            else
                pos = SavePositionAndImplementationPool(func);

            //Переделать это!
            if (cun.main_function == func)
                InitializationMethodOffset = pos;
            if (cun.finalization_method == func)
                FinalizationMethodOffset = pos;

            bw.Write((byte)func.semantic_node_type);
            int connected_to_type_pos = (int)bw.BaseStream.Position;
            bw.Write(0);
            if (CanWriteObject(func.ConnectedToType))
                WriteTypeReference(func.ConnectedToType);
            int cur_pos = (int)bw.BaseStream.Position;
            bw.Seek(connected_to_type_pos, SeekOrigin.Begin);
            bw.Write(cur_pos);
            bw.Seek(cur_pos, SeekOrigin.Begin);
            bw.Write(is_interface);
            if (is_interface == true)
                bw.Write(GetNameIndex(func));
            else
                bw.Write(func.name);

            //Является ли метод описанием дженерика
            WriteGenericFunctionInformation(func);
            //if (func.is_generic_function)
            //{
            //    bw.Write((byte)1);
            //    //Число типов-параметров
            //    bw.Write(func.generic_params.Count);
            //    //Имена параметров
            //    foreach (common_type_node par in func.generic_params)
            //    {
            //        bw.Write(par.name);
            //    }
            //    WriteTypeParamsEliminations(func.generic_params);
            //}
            //else
            //{
            //    bw.Write((byte)0);
            //}

            if (func.return_value_type == null) bw.Write((byte)0);
            else
            {
                bw.Write((byte)1);
                WriteTypeReference(func.return_value_type);
                VisitLocalVariable(func.return_variable);
            }
            bw.Write(func.parameters.Count);
            foreach (common_parameter p in func.parameters)
                VisitParameter(p);
            bw.Write(GetUnitReference(func.namespace_node));
            SaveOffsetForAttribute(func);
            bw.Write(0);//attributes;
            bw.Write(func.is_forward);
            bw.Write(func.is_overload);
            bw.Write(func.num_of_default_variables);
            bw.Write(func.num_of_for_cycles);
            bw.Write(func.var_definition_nodes_list.Count);
            foreach (local_variable var in func.var_definition_nodes_list)
                if (var != func.return_variable)
                    VisitLocalVariable(var);
            bw.Write(func.constants.Count);
            foreach (function_constant_definition cnst in func.constants)
            	VisitFunctionConstant(cnst);
            bw.Write(func.functions_nodes_list.Count);
            foreach (common_in_function_function_node nest_func in func.functions_nodes_list)
                VisitNestedFunctionDefinition(nest_func);
            WriteDebugInfo(func.loc);
            SaveCodeReference(func);
            bw.Write(0);
        }
        //(ssyy) Может быть, соединить следующие 2 метода в один?
		private void VisitFunctionImplementation(common_namespace_function_node func)
		{
			foreach (common_in_function_function_node nested in func.functions_nodes_list)
				VisitNestedFunctionImplementation(nested);
            //(ssyy) метки
            VisitLabelDeclarations(func.label_nodes_list);
			FixupCode(func);
			VisitStatement(func.function_code);
		}
        public void visit_implementation(SyntaxTree.unit_module _unit_module)
        {
            if (_unit_module.initialization_part != null)
            {
                var lambdaSearcher = new LambdaSearcher(_unit_module.initialization_part);
                if (lambdaSearcher.CheckIfContainsLambdas())
                {
                    AddError(new LambdasNotAllowedInInitializationPartOfModule(get_location(lambdaSearcher.FoundLambda)));
                }
            }

            if (_unit_module.finalization_part != null)
            {
                var lambdaSearcher = new LambdaSearcher(_unit_module.finalization_part);
                if (lambdaSearcher.CheckIfContainsLambdas())
                {
                    AddError(new LambdasNotAllowedInFinalizationPartOfModule(get_location(lambdaSearcher.FoundLambda)));
                }
            }

            //using_list.AddRange(implementation_using_list);
            /*if (_unit_module.implementation_part != null)
            {
                weak_node_test_and_visit(_unit_module.implementation_part.using_namespaces);
            }*/

            SymbolTable.Scope[] used_units = build_referenced_units(referenced_units,false);            

            _compiled_unit.implementation_scope =
                convertion_data_and_alghoritms.symbol_table.CreateUnitImplementationScope(_compiled_unit.scope, used_units);

            location loc = null;
            if (_unit_module.unit_name != null)
            {
                loc = get_location(_unit_module.unit_name);
            }

            common_namespace_node cnsn = context.create_namespace(_unit_module.unit_name.idunit_name.name + compiler_string_consts.ImplementationSectionNamespaceName,
                _compiled_unit, _compiled_unit.implementation_scope, loc);

            //cnsn.scope=_compiled_unit.implementation_scope;

            if (_unit_module.implementation_part != null)
            {
                hard_node_test_and_visit(_unit_module.implementation_part);
            }

            //weak_node_test_and_visit(_unit_module.initialization_part);
            context.enter_code_block_without_bind();

            statement_node init_statements = convert_weak(_unit_module.initialization_part);
            context.leave_code_block();
            common_namespace_function_node initialization_function = null;
            if (init_statements != null)
            {
                context.check_labels(context.converted_namespace.labels);
                //(ssyy) Блокируем поставленные метки, чтобы не допустить переход из finalization-секции
                //context.block_defined_labels(context.converted_namespace.labels);
                initialization_function = new common_namespace_function_node(compiler_string_consts.initialization_function_name,
                    null, init_statements.location, context.converted_namespace, convertion_data_and_alghoritms.symbol_table.CreateScope(context.converted_namespace.scope));
                initialization_function.function_code = init_statements;
                cnsn.functions.AddElement(initialization_function);
                _compiled_unit.main_function = initialization_function;
                context.apply_special_local_vars(_compiled_unit.main_function);
            }

            context.enter_code_block_without_bind();
            statement_node final_statements = convert_weak(_unit_module.finalization_part);
            context.leave_code_block();
            common_namespace_function_node finalization_function = null;
            if (final_statements != null)
            {
                context.check_labels(context.converted_namespace.labels);
                finalization_function = new common_namespace_function_node(compiler_string_consts.finalization_function_name,
                    null, final_statements.location, context.converted_namespace, convertion_data_and_alghoritms.symbol_table.CreateScope(context.converted_namespace.scope));
                finalization_function.function_code = final_statements;
                cnsn.functions.AddElement(finalization_function);
                _compiled_unit.finalization_method = finalization_function;
                context.apply_special_local_vars(_compiled_unit.finalization_method);
            }

            context.check_all_name_unit_defined(_compiled_unit);
        }
        //получение ссылки на функцию
		private int GetFunctionReference(common_namespace_function_node fn, ref byte is_def)
		{
            int off = 0;
            if (members.TryGetValue(fn, out off)) //если этот тип описан в этом модуле
            {
                is_def = 1;
                return off;//возвращаем его смещение
            }
			is_def = 0;
            ImportedEntity ie = null;
            if (ext_members.TryGetValue(fn, out ie))
            {
                return ie.index * ie.GetSize();
            }
			ie = new ImportedEntity();
			ie.flag = ImportKind.Common;
			ie.num_unit = GetUnitToken(fn.namespace_node);
			ie.offset = GetExternalOffset(fn);
			int offset = imp_entitles.Count*ie.GetSize();
            ie.index = imp_entitles.Count;
            imp_entitles.Add(ie);
			ext_members[fn] = ie;
			return offset;
		}
		private common_namespace_function_call create_common_namespace_function_call(common_namespace_function_node cnfn,
			SemanticTree.ILocation loc,params expression_node[] exprs)
		{
			common_namespace_function_call cnc=new common_namespace_function_call(cnfn,loc_to_loc(loc));
			cnc.parameters.AddRange(exprs);
			return cnc;
		}
Exemplo n.º 7
0
		public common_function_node create_function(string name,location def_loc)
		{
			check_function_name(name,def_loc);
			common_function_node cfn=null;
			switch (converting_block())
			{
				case block_type.function_block:
				{
                    common_function_node top_func = _func_stack.top();
                    SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateScope(top_func.scope);
					common_in_function_function_node ciffn;
					ciffn=new common_in_function_function_node(name,def_loc,top_func,scope);
					top_func.functions_nodes_list.AddElement(ciffn);
					_last_created_function=new SymbolInfo(ciffn);
					top_func.scope.AddSymbol(name,_last_created_function);
					cfn=ciffn;
					break;
				}
				case block_type.type_block:
				{
					common_method_node cmmn;
                    SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope, _ctn.Scope);
                    //TODO:сделать static и virtual.
                    //TODO: interface and implementation scopes.
					cmmn=new common_method_node(name,def_loc,_ctn,SemanticTree.polymorphic_state.ps_common,_fal,scope);
					_last_created_function=new SymbolInfo(cmmn);
					_ctn.Scope.AddSymbol(name,_last_created_function);
					_ctn.methods.AddElement(cmmn);

                    local_variable lv = new local_variable(compiler_string_consts.self_word, _ctn, cmmn, def_loc);
                    cmmn.scope.AddSymbol(compiler_string_consts.self_word, new SymbolInfo(lv));
                    cmmn.self_variable = lv;
                    cmmn.var_definition_nodes_list.AddElement(lv);

					cfn=cmmn;
					break;
				}
				case block_type.namespace_block:
				{
					common_namespace_function_node cnfnn;
                    SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateScope(_cmn.scope);
					cnfnn=new common_namespace_function_node(name,def_loc,_cmn,scope);
					_cmn.functions.AddElement(cnfnn);
					_last_created_function=new SymbolInfo(cnfnn);
					_cmn.scope.AddSymbol(name,_last_created_function);
					cfn=cnfnn;
					break;
				}
			}
			_func_stack.push(cfn);
			return cfn;
		}
Exemplo n.º 8
0
        public void create_main_function(string[] used_stand_modules, Dictionary<string, object> config)
        {
        	add_needed_cctors();
        	common_namespace_function_node temp = _main_function;
            _main_function = new common_namespace_function_node("Main", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null);
            location loc = temp.loc;
            statements_list sl = new statements_list(loc);
            _main_function.function_code = sl;
//            if (units[0].MainArgsParameter!=null)
//            {
//                _main_function.parameters.AddElement(units[0].MainArgsParameter);
//                sl.statements.AddElement(units[0].MainArgsAssignExpr);
//            }
//            if (units[0].IsConsoleApplicationVariableAssignExpr!=null)
//            {
//                sl.statements.AddElement(units[0].IsConsoleApplicationVariableAssignExpr);
//            }
            statements_list sl2 = sl;
            sl = new statements_list(null);
            common_namespace_function_node init_func = new common_namespace_function_node("$_Init_",null,null,(common_namespace_node)_main_function.comprehensive_namespace,null);
            ((common_namespace_node)_main_function.comprehensive_namespace).functions.AddElement(init_func);
            namespace_variable init_var = new namespace_variable("$is_init",SystemLibrary.SystemLibrary.bool_type,(common_namespace_node)_main_function.comprehensive_namespace,null);
            ((common_namespace_node)_main_function.comprehensive_namespace).variables.AddElement(init_var);
            if (SystemLibrary.SystemLibInitializer.ConfigVariable.Found)
            {
                namespace_variable conf_nv = null;
                compiled_variable_definition conf_cf = null;
                if (SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info is namespace_variable)
                    conf_nv = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as namespace_variable;
                else
                    conf_cf = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as compiled_variable_definition;
                foreach (string config_var in config.Keys)
                {
                    var config_value = config[config_var];
                    compiled_function_call cfc = new compiled_function_call(compiled_function_node.get_compiled_method(NetHelper.NetHelper.AddToDictionaryMethod), 
                        (conf_nv != null) ? (expression_node)new namespace_variable_reference(conf_nv, null) : (expression_node)new static_compiled_variable_reference(conf_cf, null), null);
                    cfc.parameters.AddElement(new string_const_node(config_var, null));
                    switch (Type.GetTypeCode(config_value.GetType()))
                    {
                        case TypeCode.String:
                            cfc.parameters.AddElement(new string_const_node((string)config_value, null));
                            break;
                        case TypeCode.Int32:
                            cfc.parameters.AddElement(new int_const_node((int)config_value, null));
                            break;
                        case TypeCode.Boolean:
                            cfc.parameters.AddElement(new bool_const_node((bool)config_value, null));
                            break;
                        case TypeCode.Double:
                            cfc.parameters.AddElement(new double_const_node((double)config_value, null));
                            break;
                        default:
                            throw new NotSupportedException("Config value type is nort supported");
                    }
                    sl.statements.AddElement(cfc);
                }
            }
            if (units[0].MainArgsParameter!=null)
            {
                _main_function.parameters.AddElement(units[0].MainArgsParameter);
                sl.statements.AddElementFirst(units[0].MainArgsAssignExpr);
            }
            if (units[0].IsConsoleApplicationVariableAssignExpr!=null)
            {
                sl.statements.AddElementFirst(units[0].IsConsoleApplicationVariableAssignExpr);
            }
            for (int i = 0; i < units.Count; i++)
            {
                if (units[i].main_function != null)
                {
                	if (units[i].main_function.name != TreeConverter.compiler_string_consts.temp_main_function_name)
                	{
                		common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc);
                    	sl.statements.AddElement(cnfc);
                	}
                	else
                	{
                		common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc);
                    	sl2.statements.AddElement(cnfc);
                	}
                }
            }
            //if (units.Count == 1)
            for (int i = 0; i < used_stand_modules.Length; i++)
            {
                Type t = NetHelper.NetHelper.FindRtlType(used_stand_modules[i] + "." + used_stand_modules[i]);
                if (t == null)
                    continue;
                compiled_type_node ctn = compiled_type_node.get_type_node(t);
                System.Reflection.MethodInfo mi = ctn.compiled_type.GetMethod("__InitModule__");
                if (mi == null)
                {
                    continue;
                }
                compiled_static_method_call csmc = new compiled_static_method_call(compiled_function_node.get_compiled_method(mi), null);
                sl.statements.AddElement(csmc);
            }
            for (int i = units.Count - 1; i >= 0; i--)
            {
                if (units[i].finalization_method != null)
                {
                    common_namespace_function_call cnfc = new common_namespace_function_call(units[i].finalization_method, loc);
                    sl2.statements.AddElement(cnfc);
                }
            }
            //if (units.Count == 1)
            for (int i = 0; i < used_stand_modules.Length; i++)
            {
                Type t = NetHelper.NetHelper.FindRtlType(used_stand_modules[i] + "." + used_stand_modules[i]);
                if (t == null)
                    continue;
                compiled_type_node ctn = compiled_type_node.get_type_node(t);
                System.Reflection.MethodInfo mi = ctn.compiled_type.GetMethod("__FinalizeModule__");
                if (mi == null)
                    continue;
                compiled_static_method_call csmc = new compiled_static_method_call(compiled_function_node.get_compiled_method(mi), null);
                sl2.statements.AddElement(csmc);
            }
            sl2 = new statements_list(loc);
            basic_function_call bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_assign as basic_function_node,null);
            bfc.parameters.AddElement(new namespace_variable_reference(init_var,null));
            bfc.parameters.AddElement(new bool_const_node(true,null));
            sl.statements.AddElementFirst(bfc);
            bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_not as basic_function_node,null);
            bfc.parameters.AddElement(new namespace_variable_reference(init_var,null));
            sl2.statements.AddElement(new if_node(bfc,sl,null,null));
            init_func.function_code = sl2;
            sl = new statements_list(null);
            
            sl.statements.AddElement(new common_namespace_function_call(init_func,null));
            common_namespace_function_node init_variables_func = new common_namespace_function_node("$_InitVariables_", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null);
            init_variables_func.function_code = new statements_list(null);
            ((common_namespace_node)_main_function.comprehensive_namespace).functions.AddElement(init_variables_func);
            
            sl.statements.AddElement(new common_namespace_function_call(init_variables_func,null));
            _init_code = sl;
            
        }
Exemplo n.º 9
0
 public void create_main_function_as_in_module()
 {
     add_needed_cctors();
     statements_list sl = new statements_list(loc);
     statements_list intern_sl = new statements_list(loc);
     statements_list sl2 = sl;
     sl = new statements_list(null);
     common_namespace_function_node init_func = new common_namespace_function_node("$_Init_", null, null, common_namespaces[0], null);
     common_namespaces[0].functions.AddElement(init_func);
     namespace_variable init_var = new namespace_variable("$is_init", SystemLibrary.SystemLibrary.bool_type, common_namespaces[0], null);
     common_namespaces[0].variables.AddElement(init_var);
     for (int i = 0; i < units.Count; i++)
     {
         if (units[i].main_function != null)
         {
             common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc);
             sl.statements.AddElement(cnfc);
         }
     }
     /*for (int i = units.Count - 1; i >= 0; i--)
     {
         if (units[i].finalization_method != null)
         {
             common_namespace_function_call cnfc = new common_namespace_function_call(units[i].finalization_method, loc);
             sl.statements.AddElement(cnfc);
         }
     }*/
     sl2 = new statements_list(loc);
     basic_function_call bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_assign as basic_function_node, null);
     bfc.parameters.AddElement(new namespace_variable_reference(init_var, null));
     bfc.parameters.AddElement(new bool_const_node(true, null));
     sl.statements.AddElementFirst(bfc);
     bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_not as basic_function_node, null);
     bfc.parameters.AddElement(new namespace_variable_reference(init_var, null));
     sl2.statements.AddElement(new if_node(bfc, sl, null, null));
     init_func.function_code = sl2;
     _init_code = new common_namespace_function_call(init_func, null);
     add_initialization_to_cctors();
 }
		public SymbolInfo(common_namespace_function_node value)
		{
			//_name_information_type=name_information_type.nit_common_namespace_function;
			_sym_info=value;
			_access_level=access_level.al_public;
			_symbol_kind=get_function_kind(value);
		}
Exemplo n.º 11
0
        /// <summary>
        /// Конструктор класса.
        /// </summary>
        /// <param name="main_function">Главная функция программы.</param>
        /// <param name="loc">Расположение программы.</param>
		public program_node(common_namespace_function_node main_function,location loc) : base(loc)
		{
			_main_function=main_function;
		}
Exemplo n.º 12
0
        private static void init_temp_methods_and_consts(common_namespace_node system_namespace,SymbolTable.Scope where_add,
            initialization_properties initialization_properties,location system_unit_location)
        {
            //SymbolTable.Scope sc = system_namespace.scope;
            SymbolTable.Scope sc = where_add;
            namespace_constant_definition _true_constant_definition = new namespace_constant_definition(
                PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name, SystemLibrary.true_constant, system_unit_location, system_namespace);
            system_namespace.constants.AddElement(_true_constant_definition);

            namespace_constant_definition _false_constant_definition = new namespace_constant_definition(
                PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name, SystemLibrary.false_constant, system_unit_location, system_namespace);
            system_namespace.constants.AddElement(_false_constant_definition);

            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name, new PascalABCCompiler.TreeConverter.SymbolInfo(_true_constant_definition));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name, new PascalABCCompiler.TreeConverter.SymbolInfo(_false_constant_definition));
            

            //TODO: Сделано по быстрому. Переделать. Можно просто один раз сериализовать модуль system и не инициализировать его всякий раз подобным образом. Неплохо-бы использовать NetHelper.GetMethod.
            Type tp = typeof(Console);
            compiled_function_node cfn;
            System.Type[] arr = new System.Type[1];
            System.Reflection.MethodInfo mi;

            //TODO: Сделать узел или базовый метод создания и удаления объекта.
            common_namespace_function_node cnfn = new common_namespace_function_node(TreeConverter.compiler_string_consts.new_procedure_name, null, null, system_namespace, null);
            cnfn.parameters.AddElement(new common_parameter("ptr", SystemLibrary.pointer_type, SemanticTree.parameter_type.value, cnfn,
                concrete_parameter_type.cpt_var, null, null));
            cnfn.SpecialFunctionKind = SemanticTree.SpecialFunctionKind.New;
            _NewProcedure = new PascalABCCompiler.TreeConverter.SymbolInfo(cnfn);
            _NewProcedure.symbol_kind = PascalABCCompiler.TreeConverter.symbol_kind.sk_overload_function;
            _NewProcedure.access_level = PascalABCCompiler.TreeConverter.access_level.al_public;
            _NewProcedureDecl = cnfn;
            sc.AddSymbol(TreeConverter.compiler_string_consts.new_procedure_name, _NewProcedure);

            cnfn = new common_namespace_function_node(TreeConverter.compiler_string_consts.dispose_procedure_name, null, null, system_namespace, null);
            cnfn.parameters.AddElement(new common_parameter("ptr", SystemLibrary.pointer_type, SemanticTree.parameter_type.value,
                cnfn, concrete_parameter_type.cpt_var, null, null));
            _DisposeProcedure = new PascalABCCompiler.TreeConverter.SymbolInfo(cnfn);
            _DisposeProcedure.symbol_kind = PascalABCCompiler.TreeConverter.symbol_kind.sk_overload_function;
            _DisposeProcedure.access_level = PascalABCCompiler.TreeConverter.access_level.al_public;
            _DisposeProcedureDecl = cnfn;
            cnfn.SpecialFunctionKind = SemanticTree.SpecialFunctionKind.Dispose;
            sc.AddSymbol(TreeConverter.compiler_string_consts.dispose_procedure_name, _DisposeProcedure);

            cnfn = new common_namespace_function_node(TreeConverter.compiler_string_consts.new_array_procedure_name, compiled_type_node.get_type_node(typeof(Array)), null, system_namespace, null);
            cnfn.parameters.AddElement(new common_parameter("t", compiled_type_node.get_type_node(typeof(Type)), SemanticTree.parameter_type.value, cnfn,
                concrete_parameter_type.cpt_none, null, null));
            cnfn.parameters.AddElement(new common_parameter("n", SystemLibrary.integer_type, SemanticTree.parameter_type.value, cnfn,
                concrete_parameter_type.cpt_none, null, null));
            cnfn.SpecialFunctionKind = SemanticTree.SpecialFunctionKind.NewArray;
            _NewArrayProcedure = new PascalABCCompiler.TreeConverter.SymbolInfo(cnfn);
            _NewArrayProcedureDecl = cnfn;
            //sc.AddSymbol(TreeConverter.compiler_string_consts.new_procedure_name, _NewProcedure);
            
            basic_function_node break_procedure = new basic_function_node(SemanticTree.basic_function_type.none,
                null, true);
            break_procedure.compile_time_executor = initialization_properties.break_executor;
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.break_procedure_name, new PascalABCCompiler.TreeConverter.SymbolInfo(break_procedure));
            
            basic_function_node continue_procedure = new basic_function_node(SemanticTree.basic_function_type.none,
                null, true);
            continue_procedure.compile_time_executor = initialization_properties.continue_executor;
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.continue_procedure_name, new PascalABCCompiler.TreeConverter.SymbolInfo(continue_procedure));

            basic_function_node exit_procedure = new basic_function_node(SemanticTree.basic_function_type.none,
                null, true);
            exit_procedure.compile_time_executor = initialization_properties.exit_executor;
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.exit_procedure_name, new PascalABCCompiler.TreeConverter.SymbolInfo(exit_procedure));

            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.set_length_procedure_name,
                new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.resize_func, PascalABCCompiler.TreeConverter.access_level.al_public, PascalABCCompiler.TreeConverter.symbol_kind.sk_overload_function));
        }
Exemplo n.º 13
0
 public common_unit_node(SymbolTable.UnitInterfaceScope scope,
     SymbolTable.UnitImplementationScope implementation_scope,
     common_namespace_function_node main_function,
     common_namespace_function_node finalization_method)
 {
     _scope = scope;
     _implementation_scope = implementation_scope;
     _main_function = main_function;
     _finalization_method = finalization_method;
 }
        //\ssyy

        public function_node FindMethodToOverride(common_namespace_function_node cmn)
        {
            type_node base_class = _compiled_tn;
            if (base_class == null)
            {
                return null;
            }
            SymbolInfo si = base_class.find_in_type(cmn.name);
            function_node fn = null;
            while (si != null)
            {
                if (si.sym_info.general_node_type != general_node_type.function_node)
                {
                    return null;
                }
                fn = si.sym_info as function_node;
                //(ssyy) Сверяем как параметры функций, так и типы возвращаемых значений
                if (cmn != fn && convertion_data_and_alghoritms.function_eq_params_and_result(cmn, fn))
                {
                    break;
                }
                si = si.Next;
            }
            if (si == null)
            {
                return null;
            }
            compiled_function_node cfn_sec = fn as compiled_function_node;

            if (cfn_sec != null)
            {
                if (cfn_sec.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual && cfn_sec.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual_abstract && !cfn_sec.IsFinal)
                {
                    return null;
                }
            }

            return fn;
        }
        private common_namespace_function_node GetNamespaceFunction(int offset, bool restore_code = true)
		{
            definition_node dn = null;
            if (members.TryGetValue(offset, out dn))
                return dn as common_namespace_function_node;
			common_namespace_function_node cnfn = null;
            
            int pos = (int)br.BaseStream.Position;
			br.BaseStream.Seek(start_pos+offset,SeekOrigin.Begin);
			br.ReadByte();
            int func_pos = start_pos + br.ReadInt32();
            int connected_to_type_pos = (int)br.BaseStream.Position;
            br.BaseStream.Seek(func_pos, SeekOrigin.Begin);
			string name;
            type_node ConnectedToType = null; 
            /*if (CanReadObject())
                ConnectedToType = GetTypeReference();*/
			bool is_interface = br.ReadBoolean();
			if (is_interface)//пропускаем флаг - интерфейсности
			{
				name = GetString(br.ReadInt32());
			}
			else
			{
				name = br.ReadString();
			}
			if (is_interface)
			{
                cnfn = new common_namespace_function_node(name,null,cun.namespaces[0],null);
                int_members.Add(cnfn);
			}
			else
			{
                cnfn = new common_namespace_function_node(name,null,cun.namespaces[1],null);
                impl_members.Add(cnfn);
			}
            AddMember(cnfn, offset);
            ReadGenericFunctionInformation(cnfn);
            int cur_pos = (int)br.BaseStream.Position;
            br.BaseStream.Seek(connected_to_type_pos, SeekOrigin.Begin);
            if (CanReadObject())
                ConnectedToType = GetTypeReference();
            br.BaseStream.Seek(cur_pos, SeekOrigin.Begin);
            if (br.ReadByte() == 1)
			{
				cnfn.return_value_type = GetTypeReference();
				cnfn.return_variable = GetLocalVariable(cnfn);
				cnfn.var_definition_nodes_list.AddElement(cnfn.return_variable);
			}
            //members[offset] = cnfn;
			int num_par = br.ReadInt32();
			for (int i=0; i<num_par; i++)
				cnfn.parameters.AddElement(GetParameter(cnfn));
			br.ReadInt32(); //namespace
			cnfn.attributes.AddRange(GetAttributes());
			cnfn.is_forward = br.ReadBoolean();
			cnfn.is_overload = br.ReadBoolean();
			cnfn.num_of_default_variables = br.ReadInt32();
			cnfn.num_of_for_cycles = br.ReadInt32();
			int num_var = br.ReadInt32();
			if (cnfn.return_value_type != null) num_var--;
            for (int i = 0; i < num_var; i++)
            {
                local_variable lv = GetLocalVariable(cnfn);
                if (lv != cnfn.return_variable)
                    cnfn.var_definition_nodes_list.AddElement(lv);
            }
            int num_consts = br.ReadInt32();
            for (int i = 0; i < num_consts; i++)
            {
            	cnfn.constants.AddElement(GetFunctionConstant(cnfn));
            }
            int num_nest_funcs = br.ReadInt32();
			for (int i=0; i<num_nest_funcs; i++)
				cnfn.functions_nodes_list.AddElement(GetNestedFunction());
			//br.ReadInt32();//code;
			cnfn.loc = ReadDebugInfo();
            cnfn.function_code = (restore_code /*|| cnfn.is_generic_function*/) ? GetCode(br.ReadInt32()) : new wrapped_function_body(this, br.ReadInt32());
            cnfn.ConnectedToType = ConnectedToType;
            if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind && cnfn.ConnectedToType.element_type.is_generic_parameter)
                cnfn.ConnectedToType.base_type.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.is_generic_parameter)
                cnfn.ConnectedToType.base_type.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            else if (cnfn.ConnectedToType is compiled_generic_instance_type_node && cnfn.ConnectedToType.original_generic.Scope != null)
                cnfn.ConnectedToType.original_generic.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            br.BaseStream.Seek(pos,SeekOrigin.Begin);
			return cnfn;
		}
Exemplo n.º 16
0
        /// <summary>
        /// Конструктор корневого узла dll.
        /// </summary>
        /// <param name="initialization_function">Метод инициализации dll.</param>
        /// <param name="finalization_function">Метод финализации dll.</param>
        /// <param name="loc">Расположение заголовка главного unit-а dll.</param>
		public dll_node(common_namespace_function_node initialization_function,
			common_namespace_function_node finalization_function, location loc) : base(loc)
		{
			_initialization_function=initialization_function;
			_finalization_function=finalization_function;
		}
 private common_namespace_function_node GetNamespaceFunctionWithImplementation(int offset)
 {
     int tmp = (int)br.BaseStream.Position;
     string name = br.ReadString();
     br.ReadInt32();
     location loc = ReadDebugInfo();
     common_namespace_function_node cnfn = new common_namespace_function_node(name, loc, cun.namespaces[0], null);
     if (br.ReadByte() == 1)
         cnfn.function_code = CreateStatement();
     return cnfn;
 }
Exemplo n.º 18
0
		private void SaveFunction(common_namespace_function_node cfn)
		{
			if (!string.IsNullOrEmpty(cfn.documentation))
			{
				if (!cfn.documentation.Trim(' ','\t').StartsWith("<summary>"))
				{
					xtw.WriteStartElement("member");
					xtw.WriteStartAttribute("name");
					xtw.WriteString("M:"+(is_assembly?unit_name+"."+unit_name+".":"")+cfn.name+GetGenericFlag(cfn)+GetParameters(cfn));
					xtw.WriteEndAttribute();
					xtw.WriteStartElement("summary");
					xtw.WriteString(cfn.documentation);
					xtw.WriteEndElement();
					xtw.WriteEndElement();
				}
				else
				{
					string doc = string.Concat("<member name=\""+"M:"+(is_assembly?unit_name+"."+unit_name+".":"")+cfn.name+GetGenericFlag(cfn)+GetParameters(cfn)+"\">",cfn.documentation,"</member>");
					StringReader sr = new StringReader(doc);
					XmlReader xr = XmlTextReader.Create(sr);
					xr.Read();
					xtw.WriteNode(xr.ReadSubtree(),false);
					sr.Close();
					xr.Close();
				}
			}
		}
Exemplo n.º 19
0
 private void add_delegate_operator(string name, compile_time_executor executor)
 {
     common_namespace_function_node cnfn = new common_namespace_function_node(name, this, null, null, null);
     cnfn.ConnectedToType = this;
     cnfn.compile_time_executor = executor;
     add_name(name, new SymbolInfo(cnfn));
     common_parameter cp1 = new common_parameter(compiler_string_consts.left_param_name, this, SemanticTree.parameter_type.value,
                                                 cnfn, concrete_parameter_type.cpt_none, null, null);
     common_parameter cp2 = new common_parameter(compiler_string_consts.right_param_name, this, SemanticTree.parameter_type.value,
                                                 cnfn, concrete_parameter_type.cpt_none, null, null);
     cnfn.parameters.AddElement(cp1);
     cnfn.parameters.AddElement(cp2);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Временный узел, который используется при выведении типов параметров
 /// </summary>
 /// <param name="def"></param>
 /// <param name="visitor"></param>
 /// <returns></returns>
 public static typed_expression GetTempFunctionNodeForTypeInference(SyntaxTree.function_lambda_definition def, syntax_tree_visitor visitor)
 {
     var res = new common_namespace_function_node(def.lambda_name, null, null, null);
     if (def.return_type != null)
         res.return_value_type = visitor.convert_strong(def.return_type);
     else
         res.return_value_type = null;
     res.parameters.clear();
     if (def.formal_parameters != null && def.formal_parameters.params_list.Count != 0)
     {
         for (int i = 0; i < def.formal_parameters.params_list.Count; i++)
             for (int j = 0; j < def.formal_parameters.params_list[i].idents.idents.Count; j++)
             {
                 var new_param = new common_parameter(null, SemanticTree.parameter_type.value, res, concrete_parameter_type.cpt_none, null);
                 new_param.type = visitor.convert_strong(def.formal_parameters.params_list[i].vars_type);
                 res.parameters.AddElement(new_param);
             }
     }
     var hhh = new delegated_methods();
     hhh.proper_methods.AddElement(new common_namespace_function_call(res, null));
     return new typed_expression(hhh, null);
 }
Exemplo n.º 21
0
 /*
 public System.Collections.Generic.List<local_variable> special_local_vars
 {
     get
     {
         return _special_local_vars;
     }
 }
 */
 public void apply_special_local_vars(common_namespace_function_node cnfn)
 {
     foreach (local_variable lv in _special_local_vars)
     {
         lv.function = cnfn;
         cnfn.var_definition_nodes_list.AddElement(lv);
     }
     clear_special_local_vars();
 }
Exemplo n.º 22
0
     public common_namespace_event(string name, type_node del_type, common_namespace_node cont_namespace, common_namespace_function_node add_function, common_namespace_function_node remove_function, common_namespace_function_node raise_function, 
 	                     location loc)
 	{
 		this._name = name;
 		this.del_type = del_type;
 		this._add_function = add_function;
 		this._remove_function = remove_function;
 		this._raise_function = raise_function;
         this._cont_namespace = cont_namespace;
 		this._loc = loc;
 	}
        //TODO: Слить как нибудь два следующих метода.
        public override void visit(SyntaxTree.program_module _program_module)
        {
            //MikhailoMMX Инициализация OpenMP
            OpenMP.InitOpenMP(_program_module.compiler_directives, this, _program_module);
            //\MikhailoMMX

            //current_document=new document(_program_module.file_name);
            string namespace_name = "";
            location loc = get_location(_program_module);
            if (_program_module.program_name != null)
            {
                namespace_name = _program_module.program_name.prog_name.name;
                loc = get_location(_program_module.program_name.prog_name);
                //if (namespace_name.ToLower() != System.IO.Path.GetFileNameWithoutExtension(_program_module.file_name).ToLower())
                //    throw new ProgramNameMustBeEqualProgramFileName(loc);
            }


            _compiled_unit = new common_unit_node();

            _compiled_unit.compiler_directives = ConvertDirectives(_program_module);
            //PrepareDirectives(_compiled_unit.compiler_directives);

            //using_list.AddRange(interface_using_list);
            //weak_node_test_and_visit(_program_module.using_namespaces);
            //weak_node_test_and_visit(_program_module.used_units);

            //compiled_main_unit=new unit_node();
            //SymbolTable.Scope[] used_units=new SymbolTable.Scope[used_assemblyes.Count+1];


            SymbolTable.Scope[] used_units = build_referenced_units(referenced_units,true);

            _compiled_unit.scope = convertion_data_and_alghoritms.symbol_table.CreateUnitInterfaceScope(used_units);

            common_namespace_node cnsn = context.create_namespace(namespace_name, _compiled_unit, _compiled_unit.scope, loc);
            cnsn.is_main = true;
            //compiled_program=new program_node();
            //compiled_program.units.Add(compiled_main_unit);

            reset_for_interface();

            UpdateUnitDefinitionItemForUnit(_compiled_unit);

            //_program_module.program_block.visit(this);
            hard_node_test_and_visit(_program_module.program_block);
            context.check_labels(context.converted_namespace.labels);

            // frninja 28/04/16 - режем мусорные методы хелперы yield
            {
                var toRemove = cnsn.functions.Where(m => m.name.StartsWith(YieldHelpers.YieldConsts.YieldHelperMethodPrefix)).ToArray();
                foreach (var m in toRemove)
                {
                    cnsn.functions.remove(m);
                }
            }
            // end frninja

            //TODO: Доделать.
            common_namespace_function_node main_function = new common_namespace_function_node(compiler_string_consts.temp_main_function_name,
                null, null, cnsn, null);
            main_function.function_code = context.code;
            context.apply_special_local_vars(main_function);
            cnsn.functions.AddElement(main_function);

            context.leave_block();

            _compiled_unit.main_function = main_function;
            //cnsn.SetNamespaceName(System.IO.Path.GetFileNameWithoutExtension(_program_module.file_name));
        }
Exemplo n.º 24
0
        public void set_raise_function(common_namespace_function_node meth)
		{
			_raise_function = meth;
		}
        //сохранение ссылки на функцию
		private void WriteFunctionReference(common_namespace_function_node fn)
		{
			generic_namespace_function_instance_node gi = fn as generic_namespace_function_instance_node;
            if (gi != null)
            {
                WriteGenericNamespaceFunctionReference(gi);
                return;
            }
			byte is_def = 0;
            int offset=0;
            if (fn.SpecialFunctionKind == SemanticTree.SpecialFunctionKind.None)
                offset = GetFunctionReference(fn, ref is_def);
            else
                is_def = 2;
			bw.Write(is_def);
            if (fn.SpecialFunctionKind == SemanticTree.SpecialFunctionKind.None)            
			    bw.Write(offset);
            else
                bw.Write((byte)fn.SpecialFunctionKind);
		}
Exemplo n.º 26
0
        public generic_namespace_function_instance_node(common_namespace_function_node original_generic_function, List<type_node> instance_parameters)
            : base(
            generic_convertions.MakePseudoInstanceName(original_generic_function.name, instance_parameters, false),
            null, original_generic_function.namespace_node, null)
        {
            _original_function = original_generic_function;
            _instance_params = instance_parameters;

            this.field_access_level = original_generic_function.field_access_level;
            this.is_final = original_generic_function.is_final;
            this.is_overload = true;
            this.polymorphic_state = original_generic_function.polymorphic_state;

            this.return_value_type = generic_convertions.determine_type(original_generic_function.return_value_type, instance_parameters, true);

            foreach (parameter par in original_generic_function.parameters)
            {
                common_parameter cpar = new common_parameter(par.name,
                    generic_convertions.determine_type(par.type, _instance_params, true),
                    par.parameter_type, this,
                    (par.parameter_type == SemanticTree.parameter_type.var) ? concrete_parameter_type.cpt_var : concrete_parameter_type.cpt_none,
                    par.default_value, null);
                cpar.inital_value = par.inital_value;
                cpar.default_value = par.default_value;
                cpar.intrenal_is_params = par.is_params;
                cpar.is_ret_value = par.is_ret_value;
                cpar.is_special_name = par.is_special_name;
                parameters.AddElement(cpar);
            }
        }
 //сохранение initialization и finalization частей
 private int VisitFunctionWithImplementation(common_namespace_function_node func)
 {
     int pos = SavePosition(func);
     bw.Write((byte)func.semantic_node_type);
     bw.Write(func.name);
     bw.Write(GetUnitReference(func.namespace_node));
     WriteDebugInfo(func.loc);
     if (func.function_code != null)
     {
         bw.Write((byte)1);
         VisitStatement(func.function_code);
     }
     else bw.Write((byte)0);
     return pos;
 }
        private common_namespace_function_node CreateInterfaceNamespaceFunction(string name, int offset)
		{
            definition_node dn = null;
            if (members.TryGetValue(offset, out dn))
                return dn as common_namespace_function_node;
            common_namespace_function_node cnfn = null;
            cnfn = new common_namespace_function_node(name,null,cun.namespaces[0],null);
            //members[offset] = cnfn;
            AddMember(cnfn, offset);

            type_node ConnectedToType = null;
            br.ReadInt32();
            if (CanReadObject())
                ConnectedToType = GetTypeReference();
            br.ReadBoolean();//пропускаем флаг - интерфейсности
			br.ReadInt32();

            ReadGenericFunctionInformation(cnfn);
            //if (CanReadObject())
            //{
            //    cnfn.generic_params = ReadGenericParams(cun.namespaces[0]);
            //    foreach (common_type_node par in cnfn.generic_params)
            //    {
            //        par.generic_function_container = cnfn;
            //        ReadTypeParameterEliminations(par);
            //    }
            //}

            if (br.ReadByte() == 1)
			{
				cnfn.return_value_type = GetTypeReference();
				cnfn.return_variable = GetLocalVariable(cnfn);
                cnfn.var_definition_nodes_list.AddElement(cnfn.return_variable);
			}
			int num_par = br.ReadInt32();
			for (int i=0; i<num_par; i++)
				cnfn.parameters.AddElement(GetParameter(cnfn));
			br.ReadInt32(); //namespace
			cnfn.attributes.AddRange(GetAttributes());
			cnfn.is_forward = br.ReadBoolean();
			cnfn.is_overload = br.ReadBoolean();
			cnfn.num_of_default_variables = br.ReadInt32();
			cnfn.num_of_for_cycles = br.ReadInt32();
			int num_var = br.ReadInt32();
			if (cnfn.return_value_type != null) num_var--;
            for (int i = 0; i < num_var; i++)
            {
                local_variable lv = GetLocalVariable(cnfn);
                if (lv != cnfn.return_variable)
                cnfn.var_definition_nodes_list.AddElement(lv);
            }
            int num_consts = br.ReadInt32();
            for (int i = 0; i < num_consts; i++)
            {
                function_constant_definition fcd = GetFunctionConstant(cnfn);
                cnfn.constants.AddElement(fcd);
            }
            int num_nest_funcs = br.ReadInt32();
			for (int i=0; i<num_nest_funcs; i++)
				cnfn.functions_nodes_list.AddElement(GetNestedFunction());
			//br.ReadInt32();//code;
			cnfn.loc = ReadDebugInfo();
            cnfn.function_code = GetCode(br.ReadInt32());
			int_members.Add(cnfn);
            cnfn.ConnectedToType = ConnectedToType;
            if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind && cnfn.ConnectedToType.element_type.is_generic_parameter)
                cnfn.ConnectedToType.base_type.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.is_generic_parameter)
                cnfn.ConnectedToType.base_type.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            else if (cnfn.ConnectedToType is compiled_generic_instance_type_node && cnfn.ConnectedToType.original_generic.Scope != null)
                cnfn.ConnectedToType.original_generic.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.IsDelegate && cnfn.ConnectedToType.base_type.IsDelegate)
                compiled_type_node.get_type_node(typeof(Delegate)).Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
            return cnfn;
		}
Exemplo n.º 29
0
 private void VisitCommonNamespaceFunctionNode(common_namespace_function_node cnfn)
 {
     if (extended_mode)
         VisitVariables(cnfn.var_definition_nodes_list);
     foreach (var_definition_node vdn in cnfn.var_definition_nodes_list)
         helper.AddVariable(vdn);
     foreach (common_parameter prm in cnfn.parameters)
         helper.AddParameter(prm);
     foreach (common_in_function_function_node nested in cnfn.functions_nodes_list)
         VisitNestedFunction(nested);
     cur_func = cnfn;
     VisitStatement(cnfn.function_code);
     foreach (var_definition_node vdn2 in cnfn.var_definition_nodes_list)
     {
     	if (vdn2 is local_variable)
     	{
     		local_variable vdn = vdn2 as local_variable;
     		VarInfo vi = helper.GetVariable(vdn);
         	if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
             else if (vi.num_ass == 0 && vdn.is_ret_value && !cnfn.name.StartsWith("<>") && cnfn.return_value_type != null && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && !cnfn.return_value_type.IsPointer && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
              && !helper.IsExternal(cnfn)) warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
         	if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
         //if (vi.num_ass == 0 && vi.act_num_use > 0) helper.AddRealWarning(vdn, warns);
     	}
     	else if (vdn2 is local_block_variable)
     	{
     		local_block_variable vdn = vdn2 as local_block_variable;
     		VarInfo vi = helper.GetVariable(vdn);
         	if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
             else if (vi.num_ass == 0 && vdn.is_ret_value && !cnfn.name.StartsWith("<>") && cnfn.return_value_type != null && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && !cnfn.return_value_type.IsPointer && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
              && !helper.IsExternal(cnfn)) warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
         	if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
         //if (vi.num_ass == 0 && vi.act_num_use > 0) helper.AddRealWarning(vdn, warns);
     	}
     	if (vdn2.inital_value != null) VisitExpression(vdn2.inital_value);
     }
     foreach (common_parameter prm in cnfn.parameters)
     {
         ParamInfo vi = helper.GetParameter(prm);
         if (prm.inital_value != null) VisitExpression(prm.inital_value);
         //if (vi.num_use == 0 && !prm.name.Contains("$")) warns.Add(new UnusedParameter(prm.name, prm.loc));
     }
     foreach (var_definition_node vdn in cnfn.var_definition_nodes_list)
     {
     	VarInfo vi = helper.GetVariable(vdn);
     	if (vdn.inital_value != null) VisitExpression(vdn.inital_value);
     }
 }
        public common_namespace_event add_namespace_event(string name, location loc, type_node tn)
        {
            namespace_variable nv = new namespace_variable(name + "$", tn, converted_namespace, loc);
            common_namespace_event cne = new common_namespace_event(name, tn, converted_namespace, null, null, null, loc);
            common_namespace_function_node add_func = new common_namespace_function_node(compiler_string_consts.GetAddHandler(name),
                null, this.converted_namespace, null);
            common_parameter cp = new common_parameter("value", tn, SemanticTree.parameter_type.value, add_func, concrete_parameter_type.cpt_none, null, null);
            add_func.parameters.AddElement(cp);
            expression_node fld_ref = null;
            fld_ref = new namespace_variable_reference(nv, null);
            expression_node en = this.syntax_tree_visitor.convertion_data_and_alghoritms.type_constructor.delegate_add_assign_compile_time_executor
                (null, new expression_node[2] { fld_ref, new common_parameter_reference(cp, 0, null) });
            //en = this.syntax_tree_visitor.convertion_data_and_alghoritms.create_simple_function_call(tn.find_in_type(compiler_string_consts.assign_name).sym_info as function_node,null,
            //                                                                                    fld_ref,en);
            add_func.function_code = new statements_list(null);
            (add_func.function_code as statements_list).statements.AddElement(en);
            //remove
            common_namespace_function_node remove_func = new common_namespace_function_node(compiler_string_consts.GetRemoveHandler(name), null, this.converted_namespace, null);

            cp = new common_parameter("value", tn, SemanticTree.parameter_type.value, add_func, concrete_parameter_type.cpt_none, null, null);
            remove_func.parameters.AddElement(cp);
            en = this.syntax_tree_visitor.convertion_data_and_alghoritms.type_constructor.delegate_sub_assign_compile_time_executor
                (null, new expression_node[2] { fld_ref, new common_parameter_reference(cp, 0, null) });
            //en = this.syntax_tree_visitor.convertion_data_and_alghoritms.create_simple_function_call(tn.find_in_type(compiler_string_consts.assign_name).sym_info as function_node,null,
            //                                                                                    fld_ref,en);
            remove_func.function_code = new statements_list(null);
            (remove_func.function_code as statements_list).statements.AddElement(en);
            this.converted_namespace.functions.AddElement(add_func);
            this.converted_namespace.functions.AddElement(remove_func);
            cne.set_add_function(add_func);
            cne.set_remove_function(remove_func);
            cne.field = nv;
            this.converted_namespace.events.AddElement(cne);
            this.converted_namespace.variables.AddElement(nv);
            CurrentScope.AddSymbol(name, new SymbolInfo(cne));
            return cne;
        }