public override void visit(PascalABCCompiler.SyntaxTree.for_node _for_node)
 {
     //throw new Exception("The method or operation is not implemented.");
     SymScope tmp = cur_scope;
     //if (_for_node.type_name != null)
     {
     	SymScope stmt_scope = new BlockScope(cur_scope);
 		cur_scope.AddName("$block_scope",stmt_scope);
 		stmt_scope.loc = get_location(_for_node);
 		returned_scope = null;
 		if (_for_node.type_name != null)
 		_for_node.type_name.visit(this);
 		if (returned_scope != null)
 		{
 			cur_scope = stmt_scope;
 			ElementScope es = new ElementScope(new SymInfo(_for_node.loop_variable.name, SymbolKind.Variable,_for_node.loop_variable.name),returned_scope,cur_scope);
 			stmt_scope.AddName(_for_node.loop_variable.name,es);
 			es.loc = get_location(_for_node.loop_variable);
 			returned_scope = null;
 		}
 		else
 		{
 			_for_node.initial_value.visit(this);
 			if (returned_scope != null)
 			{
 				cur_scope = stmt_scope;
 				if (_for_node.create_loop_variable)
 				{
 					ElementScope es = new ElementScope(new SymInfo(_for_node.loop_variable.name, SymbolKind.Variable,_for_node.loop_variable.name),returned_scope,cur_scope);
 					stmt_scope.AddName(_for_node.loop_variable.name,es);
 					es.loc = get_location(_for_node.loop_variable);
 				}
 				returned_scope = null;
 			}
 		}
     }
     if (_for_node.statements != null)
     _for_node.statements.visit(this);
     cur_scope = tmp;
 }
 public override void visit(foreach_stmt _foreach_stmt)
 {
     //throw new Exception("The method or operation is not implemented.");
     SymScope tmp = cur_scope;
     if (_foreach_stmt.type_name != null)
     {
     	SymScope stmt_scope = new BlockScope(cur_scope);
 		cur_scope.AddName("$block_scope",stmt_scope);
 		stmt_scope.loc = get_location(_foreach_stmt);
         if (_foreach_stmt.type_name is no_type_foreach)
         {
             _foreach_stmt.in_what.visit(this);
             if (returned_scope != null)
                 returned_scope = returned_scope.GetElementType();
         }
         else
         {
             _foreach_stmt.type_name.visit(this);
         }
 		if (returned_scope != null)
 		{
 			cur_scope = stmt_scope;
 			ElementScope es = new ElementScope(new SymInfo(_foreach_stmt.identifier.name, SymbolKind.Variable,_foreach_stmt.identifier.name),returned_scope,cur_scope);
 			es.loc = get_location(_foreach_stmt.identifier);
 			stmt_scope.AddName(_foreach_stmt.identifier.name,es);
 		}
     }
     if (_foreach_stmt.stmt != null)
     _foreach_stmt.stmt.visit(this);
     cur_scope = tmp;
 }
 public override void visit(unit_module _unit_module)
 {
     string path = get_assembly_path("mscorlib.dll",_unit_module.file_name);
 	Assembly _as = PascalABCCompiler.NetHelper.NetHelper.LoadAssembly(path);
     AssemblyDocCache.Load(_as, path);
     PascalABCCompiler.NetHelper.NetHelper.init_namespaces(_as);
     List<string> namespaces = new List<string>();
     namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
     InterfaceUnitScope unit_scope = null;
     cur_scope = unit_scope= new InterfaceUnitScope(new SymInfo(_unit_module.unit_name.idunit_name.name, SymbolKind.Namespace,_unit_module.unit_name.idunit_name.name),null);
     this.cur_unit_file_name = _unit_module.file_name;
     //if (XmlDoc.LookupLocalizedXmlDocForUnitWithSources(_unit_module.file_name) != null)
     if (!add_doc_from_text)
     {
     	UnitDocCache.LoadWithSources(cur_scope,_unit_module.file_name);
     	//this.add_doc_from_text = false;
     }
     //add_standart_types_simple();
     Stack<Position> regions_stack = new Stack<Position>();
     if (CodeCompletionController.comp.CompilerOptions.CurrentProject != null && CodeCompletionController.comp.CompilerOptions.CurrentProject.ContainsSourceFile(_unit_module.file_name))
     {
     	IReferenceInfo[] refs = CodeCompletionController.comp.CompilerOptions.CurrentProject.References;
     	if (_unit_module.compiler_directives == null)
     		_unit_module.compiler_directives = new List<PascalABCCompiler.SyntaxTree.compiler_directive>();
     	foreach (IReferenceInfo ri in refs)
     	{
     		_unit_module.compiler_directives.Add
     			(new PascalABCCompiler.SyntaxTree.compiler_directive(new token_info("reference"),new token_info(ri.FullAssemblyName)));
     	}
     }
     if (_unit_module.compiler_directives != null)
     foreach (PascalABCCompiler.SyntaxTree.compiler_directive dir in _unit_module.compiler_directives)
     {
     	if (dir.Name.text.ToLower() == "reference")
         {
             try
             {
         		//System.Reflection.Assembly assm = System.Reflection.Assembly.LoadFrom(get_assembly_path(dir.Directive.text,_unit_module.file_name));
         		path = get_assembly_path(dir.Directive.text,_unit_module.file_name);
             	System.Reflection.Assembly assm = PascalABCCompiler.NetHelper.NetHelper.LoadAssembly(path);
         		PascalABCCompiler.NetHelper.NetHelper.init_namespaces(assm);
             	AssemblyDocCache.Load(assm, path);
             	namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(assm));
             	unit_scope.AddReferencedAssembly(assm);
             }
             catch (Exception e)
             {
             	
             }
             //ns=new PascalABCCompiler.NetHelper.NetScope(unl,assm,tcst);
         }
         else
         if (dir.Name.text.ToLower() == "region")
         {
         	if (cur_scope.regions == null)
         		cur_scope.regions = new List<Position>();
             regions_stack.Push(new Position(dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num, dir.source_context.end_position.line_num, dir.source_context.end_position.column_num, dir.source_context.FileName, dir.Directive.text));	                   
         }
         else if (dir.Name.text.ToLower() == "endregion")
         {
         	if (regions_stack.Count > 0)
         	{
         		Position pos = regions_stack.Pop();
         		if (cur_scope.regions != null)
         		{
                     cur_scope.regions.Add(new Position(pos.line, pos.column-1, dir.source_context.end_position.line_num, dir.source_context.end_position.column_num, pos.file_name, pos.fold_text));
         		}
         	}
         }
     }
     ns_cache = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
     
     doc = new document(_unit_module.file_name);
     cur_scope.head_loc = get_location(_unit_module.unit_name); 
     cur_scope.file_name = _unit_module.file_name;
     cur_scope.loc = get_location(_unit_module);
     cur_scope.AddName(_unit_module.unit_name.idunit_name.name,cur_scope);
     if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_unit_module.unit_name))
 		cur_scope.AddDocumentation(this.converter.controller.docs[_unit_module.unit_name]);
     entry_scope = cur_scope;
     //add_standart_types();
     if (_unit_module.unit_name.idunit_name.name == this.converter.controller.Parser.LanguageInformation.SystemUnitName)
     //add_system_unit();
     {
     	is_system_unit = true;
     	add_standart_types(entry_scope);
     }
     CodeCompletionController.comp_modules[_unit_module.file_name] = this.converter;
     _unit_module.interface_part.visit(this);
     foreach (string s in namespaces)
     {
     	if (!ns_cache.ContainsKey(s))
     	{
           NamespaceScope ns_scope = new NamespaceScope(s);
           entry_scope.AddName(s,ns_scope);
           ns_cache[s] = s;
     	}
     }
     //if (parse_only_interface)
     //    return;
     if (_unit_module.implementation_part != null)
         _unit_module.implementation_part.visit(this);
     if (_unit_module.initialization_part != null)
     {
     	SymScope tmp = cur_scope;
     	SymScope stmt_scope = new BlockScope(cur_scope);
 		cur_scope.AddName("$block_scope",stmt_scope);
 		stmt_scope.loc = get_location(_unit_module.initialization_part);
 		/*if (_unit_module.implementation_part != null)
 		{
 			cur_scope.loc.end_line_num = entry_scope.loc.end_line_num;
 			cur_scope.loc.end_column_num = entry_scope.loc.end_column_num;
 		}*/
 		cur_scope = stmt_scope;
     	_unit_module.initialization_part.visit(this);
     	cur_scope = tmp;
     }
     if (_unit_module.finalization_part != null)
     {
     	SymScope tmp = cur_scope;
     	SymScope stmt_scope = new BlockScope(cur_scope);
 		cur_scope.AddName("$block_scope",stmt_scope);
 		stmt_scope.loc = get_location(_unit_module.finalization_part);
 		/*if (_unit_module.implementation_part != null)
 		{
 			cur_scope.loc.end_line_num = entry_scope.loc.end_line_num;
 			cur_scope.loc.end_column_num =entry_scope.loc.end_column_num;
 		}*/
 		cur_scope = stmt_scope;
     	_unit_module.finalization_part.visit(this);
     	cur_scope = tmp;
     }
     
 }
 public override void visit(exception_handler _exception_handler)
 {
     SymScope tmp = cur_scope;
 	SymScope stmt_scope = new BlockScope(cur_scope);
 	cur_scope.AddName("$block_scope",stmt_scope);
 	stmt_scope.loc = get_location(_exception_handler);
 	stmt_scope.loc = new location(stmt_scope.loc.begin_line_num,stmt_scope.loc.begin_column_num,
 	                              _exception_handler.statements.source_context.end_position.line_num,
 	                              _exception_handler.statements.source_context.end_position.column_num,stmt_scope.loc.doc);
 	returned_scope = null;
 	if (_exception_handler.variable == null) return;
 	if (_exception_handler.type_name != null)
 	_exception_handler.type_name.visit(this);
 	else returned_scope = cur_scope.FindName(_exception_handler.variable.name);
 	if (returned_scope != null)
 	{
 		cur_scope = stmt_scope;
 		ElementScope es = new ElementScope(new SymInfo(_exception_handler.variable.name, SymbolKind.Variable,_exception_handler.variable.name),returned_scope,cur_scope);
 		es.loc = get_location(_exception_handler.variable);
 		stmt_scope.AddName(_exception_handler.variable.name,es);
 	}
 	_exception_handler.statements.visit(this);
 	cur_scope = tmp;
 }
 public override void visit(statement_list _statement_list)
 {
 	SymScope tmp = cur_scope;
 	
 	if (HasVariablesInBlock(_statement_list))
 	{
 		SymScope stmt_scope = new BlockScope(cur_scope);
 		cur_scope.AddName("$block_scope",stmt_scope);
 		stmt_scope.loc = get_location(_statement_list);
 		cur_scope = stmt_scope;
 	}
 	//try
 	{
 		foreach (statement stmt in _statement_list.subnodes)
 			stmt.visit(this);
 	}
 	//catch(Exception e)
 	{
 		
 	}
 	cur_scope = tmp;
 }