//нужно ли перекомпилировать PCU
 //проходимся по подключ. модулям и проверяем, нужно ли их перекомпилировать
 //так рекурсивно, пока не пройдем все модули. Если хотя бы один из них изменился
 //то модуль нужно перекомпилировать
 public bool NeedRecompiled()
 {
     /*if (pcu_file.UseRtlDll != comp.CompilerOptions.UseDllForSystemUnits)
     {
         need = true;
         return need;
     }*/
     if (comp.NeedRecompiled(unit_name, Path.GetDirectoryName(FileName), pcu_file.incl_modules,this))
     {
         //comp.RecompileList.Add(unit_name,unit_name);
         comp.RecompileList[unit_name] = unit_name;
         need = true; 
         return need;
     }
     
     for (int i = 0; i < pcu_file.incl_modules.Length; i++)
     {
         //if (pcu_file.incl_modules[i].Contains("$"))
         //	continue;
         string source_file_name = comp.FindSourceFileName(Path.Combine(dir, pcu_file.incl_modules[i]));
         if (source_file_name != null && comp.UnitTable[source_file_name] != null)
             return true;
         PCUReader pr = (PCUReader)units[pcu_file.incl_modules[i]];
         if (pr == null) 
             pr = new PCUReader(this);
         pr.AddAlreadyCompiledUnit(FileName);
         if (used_units[pcu_file.incl_modules[i]] == null)
         {
             used_units[pcu_file.incl_modules[i]] = used_units;
             if (already_compiled[pcu_file.incl_modules[i]] == null)
                 pr.GetCompilationUnit(comp.FindPCUFileName(pcu_file.incl_modules[i], source_file_name), this.readDebugInfo);
         }
         if (need == false) need = pr.need;
     }
     return need;
 }
 public PCUReader(PCUReader Reader)
 {
     this.comp = Reader.comp;
     AllReaders.Add(this);
     ChangeState += Reader.ChangeState;
 }
 public static bool ContainsUnit(string FileName, out PCUReader pr)
 {
     string unit_name = System.IO.Path.GetFileNameWithoutExtension(FileName);
     pr = (PCUReader)units[unit_name];
     if (pr != null) return true;
     return false;
 }
		private namespace_constant_definition ReadExtNamespaceConstant()
		{
			br.ReadByte();
			int pos = br.ReadInt32();
			string s = pcu_file.incl_modules[pos];
			PCUReader pr = (PCUReader)units[s];
			if (pr == null)
			{
				pr = new PCUReader(this);
                CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo);
                namespace_constant_definition nv = pr.GetConstantDefinition(br.ReadInt32());
				return nv;
			}
			else
			{
				namespace_constant_definition nv = pr.GetConstantDefinition(br.ReadInt32());
				return nv;
			}
		}
 private common_property_node ReadCommonExtProperty()
 {
     br.ReadByte();
     int offset = br.ReadInt32();
     int tmp = (int)br.BaseStream.Position;
     br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin);
     br.ReadByte();//DS Changed
     int pos = br.ReadInt32();
     string s = pcu_file.incl_modules[pos];
     PCUReader pr = (PCUReader)units[s];
     br.BaseStream.Seek(tmp, SeekOrigin.Begin);
     if (pr == null)
     {
         pr = new PCUReader(this);
         CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo);
         common_property_node prop = pr.GetPropertyNode(br.ReadInt32());
         return prop;
     }
     else
     {
         common_property_node prop = pr.GetPropertyNode(br.ReadInt32());
         return prop;
     }
 }
Esempio n. 6
0
 public WrappedInterfaceScope(PCUReader pr, Scope TopScope, Scope[] vTopInterfaceScopeArray)
     :
     base(pr, TopScope, null)
 {
     _TopInterfaceScopeArray = vTopInterfaceScopeArray;
 }
        //получение импортируемой функции
		private common_namespace_function_node ReadCommonExtNamespaceFunc()
		{
			br.ReadByte();
			int pos = br.ReadInt32();
			string s = pcu_file.incl_modules[pos];
			PCUReader pr = (PCUReader)units[s];
			if (pr == null)
			{
				pr = new PCUReader(this);
                CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo);
				int offset = br.ReadInt32();
				common_namespace_function_node cffn = pr.GetNamespaceFunction(offset);
				return cffn;
			}
			else
			{
				common_namespace_function_node cffn = pr.GetNamespaceFunction(br.ReadInt32());
				return cffn;
			}
		}
Esempio n. 8
0
 public WrappedUnitImplementationScope(PCUReader pr, Scope TopScope)
     : base(PascalABCCompiler.SystemLibrary.SystemLibrary.symtab, TopScope, new Scope[0] { })
 {
     this.pr = pr;
 }
		public CompilationUnit ReadPCU(string FileName)
		{
            PCUReader pr = new PCUReader(this,pr_ChangeState);
            return pr.GetCompilationUnit(FileName,CompilerOptions.Debug);
		}
Esempio n. 10
0
 public wrapped_common_type_node(PCUReader pr, type_node base_type, string name, SemanticTree.type_access_level type_access_level,
     common_namespace_node comprehensive_namespace, SymbolTable.ClassScope cs, location loc,int offset):
     base(base_type, name, type_access_level, comprehensive_namespace,cs,loc) 
 {
     this.pr = pr;
     this.offset = offset;
 }
Esempio n. 11
0
 public WrappedUnitInterfaceScope(PCUReader pr)
     : base(PascalABCCompiler.SystemLibrary.SystemLibrary.symtab, null, new Scope[0] { })
 {
     this.pr = pr;
 }
Esempio n. 12
0
 public wrapped_function_body(PCUReader pr, int offset):base(null)
 {
     this.pr = pr;
     this.offset = offset;
 }
Esempio n. 13
0
 public wrapped_type_synonym(PCUReader pr, string name, int offset):base(offset,pr)
 {
 	this.name = name;
 	is_synonim = true;
 }
Esempio n. 14
0
 public WrappedInterfaceScope(PCUReader pr, Scope TopScope, Scope BaseClassScope, Scope[] vTopInterfaceScopeArray)
     :
     base(pr, TopScope, BaseClassScope)
 {
     _TopInterfaceScopeArray = vTopInterfaceScopeArray;
 }
 //(ssyy) Получение шаблонного класса
 private template_class ReadTemplateExtClass()
 {
     int pos = br.ReadInt32();
     string s = pcu_file.incl_modules[pos];
     PCUReader pr = (PCUReader)units[s];//вдруг этот модуль уже читается
     if (pr == null)//это по моему чёс, так как все модули уже добавлены 
     {
         pr = new PCUReader(this);//если нет, то создаем ридер
         CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo);
         template_class tc = pr.GetTemplateClass(br.ReadInt32());
         units[s] = pr;//добавляем в таблицу ридеров
         return tc;
     }
     else
     {
         template_class tc = pr.GetTemplateClass(br.ReadInt32());
         return tc;
     }
 }
 /*public CompilationUnit RecompileUnit(string unit_name)
 {
     Console.WriteLine("recompile {0}", unit_name);
     CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(new SyntaxTree.string_const(program_folder + "\\" + unit_name+".pas"));
     CompileUnit(Units, CurrentSyntaxUnit);
     CompilationUnit cu = new CompilationUnit();
     if (Units.Count != 0)
         cu.SemanticTree = Units[Units.Count - 1];
     else
         return null;
     return cu;
 }*/
 public bool NeedRecompiled(string name, string dir, string[] included, PCUReader pr)
 {
     string pas_name = FindSourceFileName(Path.Combine(dir,name));
     string pcu_name = FindPCUFileName(name,pas_name);
     if (UnitTable[pas_name] != null)
         return true;
     bool need = false;
     for (int i = 0; i < included.Length; i++)
     {
         //if (included[i].Contains("$"))
     	//	continue;
     	string pas_name2 = FindSourceFileName(Path.Combine(dir,included[i]));
         string pcu_name2 = FindPCUFileName(included[i],pas_name2);
         if (UnitTable[pas_name2] != null)
             return true;
         if (!File.Exists(pcu_name2))
         {
             need = true; RecompileList[name] = name;
             RecompileList[included[i]] = included[i];
         }
         else
             if (SourceFileExists(pas_name2) && File.GetLastWriteTime(pcu_name2) <= SourceFileGetLastWriteTime(pas_name2))
             {
                 need = true; CycleUnits[name] = name; RecompileList[name] = name;
                 RecompileList[included[i]] = included[i];
             }
     }
     if (need) return true;
     if (!SourceFileExists(pas_name)) return false;
     if (!File.Exists(pcu_name)) return true;
     if (File.GetLastWriteTime(pcu_name) < SourceFileGetLastWriteTime(pas_name)) return true;
     //Console.WriteLine("{0} {1}",name,RecompileList.Count);
     for (int i = 0; i < included.Length; i++)
     {
         string pcu_name2 = FindPCUFileName(included[i]);
         //TODO: Спросить у Сащи насчет < и <=.
         
         if ((File.Exists(pcu_name2) && File.GetLastWriteTime(pcu_name) < File.GetLastWriteTime(pcu_name2) && !pr.AlreadyCompiled(pcu_name2)))
         {
             pr.AddAlreadyCompiledUnit(included[i]);
             return true;
         }
         if (RecompileList.ContainsKey(included[i]))
         {
             return true;
         }
     }
     return false;
 }
 public void AddPCUToOpen(PCUReader pr)
 {
     pcu_reader = pr;
 }
Esempio n. 18
0
 public WrappedClassScope(PCUReader pr, Scope top_scope, Scope up_scope)
     : base(PascalABCCompiler.SystemLibrary.SystemLibrary.symtab, top_scope, up_scope)
 {
     this.pr = pr;
 }