private void VisitLocalBlockVariable(local_block_variable lv)
 {
     SavePosition(lv);			
     bw.Write(lv.name);
     WriteTypeReference(lv.type);
     if(CanWriteObject(lv.inital_value))
     {
     	SaveExpressionAndOffset(lv.inital_value);
     	bw.Write(0);
     	//VisitExpression(lv.inital_value);
     }
     WriteDebugInfo(lv.loc);
 }
 private local_block_variable CreateLocalBlockVariable(statements_list stmt)
 {
     int offset = (int)br.BaseStream.Position - start_pos;
     string name = br.ReadString();
     type_node tn = GetTypeReference();
     expression_node initv = null;
     local_block_variable lv = new local_block_variable(name, tn, stmt, null);
     AddMember(lv, offset);
     if (CanReadObject())
         initv = CreateExpressionWithOffset();
     lv.loc = ReadDebugInfo();
     lv.inital_value = initv;
     return lv;
     
 }
 public SymbolInfo(local_block_variable value)
 {
     //_name_information_type=name_information_type.nit_local_variable;
     _sym_info = value;
     _access_level = access_level.al_public;
     _symbol_kind = symbol_kind.sk_none;
 }
 public local_block_variable_reference(local_block_variable var, location loc)
     : base(var.type, loc)
 {
     _var = var;
 }
 public local_block_variable_reference(local_block_variable var, location loc)
     : base(var.type, loc)
 {
     _var = var;
 }
		public var_definition_node add_var_definition(string name, location loc, type_node tn, SemanticTree.polymorphic_state ps)
		{
			check_name_free(name,loc);
			var_definition_node vdn=null;
            if (CurrentScope is SymbolTable.BlockScope)
            {
                if (SemanticRules.DisabledDefinitionBlockVariablesWithSameNameThatInAboveScope)
                {
                    SymbolTable.Scope cs = CurrentScope;
                    while (cs.TopScope != null /*(cs.TopScope is SymbolTable.BlockScope || cs.TopScope is SymbolTable.UnitPartScope)*/)
                    {
                    	if (cs.TopScope is SymbolTable.BlockScope)//projdemsja po blokam koda
                    	{
                    		if (cs.TopScope.FindOnlyInScope(name) != null)
                                syntax_tree_visitor.AddError(loc, "BLOCK_VARIABLES_CANNOT_HAVE_NAMES_UPPER_SCOPE");
                    		cs = cs.TopScope;
                    	}
                    	else // a zdes proverjaem v verhnem bloke i vse, to chto eshe vyshe, tam ne proverjaem, tak dejstvuet princip blochnosti
                    	{
                    		if (cs.TopScope.FindOnlyInScope(name) != null)
                                syntax_tree_visitor.AddError(loc, "BLOCK_VARIABLES_CANNOT_HAVE_NAMES_UPPER_SCOPE");
                    		break;
                    	}
                        
                    }
                }
            	local_block_variable lv = new local_block_variable(name, tn, CurrentStatementList, loc);
                CurrentScope.AddSymbol(name, new SymbolInfo(lv));
                lv.block.local_variables.Add(lv);
                if (tn == null) //Тип еще неизвестен, будем закрывать.
                    var_defs.Add(lv);
                return lv;
            }
            switch (converting_block())
			{
				case block_type.function_block:
				{
                    common_function_node top_func = _func_stack.top();
					local_variable lv=new local_variable(name,tn,top_func,loc);
					vdn=lv;
					top_func.var_definition_nodes_list.AddElement(lv);
                    CurrentScope.AddSymbol(name, new SymbolInfo(lv));
					//top_func.scope.AddSymbol(name,new SymbolInfo(lv));
					break;
				}
				case block_type.type_block:
				{
                    //TODO:сделать static и virtual.
                    class_field cf = new class_field(name,tn, _ctn, ps,_fal,loc);
					vdn=cf;
					//_ctn.Scope.AddSymbol(name,new SymbolInfo(cf));
                    CurrentScope.AddSymbol(name, new SymbolInfo(cf));
					_ctn.fields.AddElement(cf);
					break;
				}
				case block_type.namespace_block:
				{
					namespace_variable nsv=new namespace_variable(name,tn,_cmn,loc);
					vdn=nsv;
					//_cmn.scope.AddSymbol(name,new SymbolInfo(nsv));
                    CurrentScope.AddSymbol(name, new SymbolInfo(nsv));
					_cmn.variables.AddElement(nsv);
					break;
				}
			}
            if (tn == null) //Тип еще неизвестен, будем закрывать.
                var_defs.Add(vdn);
            return vdn;
		}