String generujProgram(Struktura korenProgramu) { String program = Objekt.tabulator(1) + "always {\r\n"; /*foreach (Objekt o in objekty.Values) * { * if (o is VolanieFunkcie) * { * program += o.generujInit(); * } * }*/ if (vystupy != null) { for (int i = 0; i < vystupy.Count; i++) { program += Objekt.tabulator(2) + vystupy[i].meno + " = "; if (vystupy[i].bitSirka == 1) { program += "0"; } else { program += vystupy[i].bitSirka + "x{{" + vystupy[i].bitDlzka + "hxx}}"; } program += ";\r\n"; } } foreach (Struktura s in korenProgramu.deti) { program += s.strukturujLucidKod(this, 2); } program += Objekt.tabulator(1) + "}\r\n}"; return(program); }
public int CompareTo(object obj) { if (obj == null) { return(1); } Struktura s2 = obj as Struktura; if (s2 != null) { return(this.deti.Count.CompareTo(s2.deti.Count)); } throw new ArgumentException("Object is not a Struktura"); }
public bool pridajDieta(String otecId, Struktura dieta) { if (id == otecId) { deti.Add(dieta); return(true); } for (int i = 0; i < deti.Count; i++) { if (deti[i].pridajDieta(otecId, dieta)) { return(true); } } return(false); }
public Dictionary <String, String> generujLucidKod(String cesta) { Dictionary <String, String> moduly = new Dictionary <String, String>(); Dictionary <String, String> clkModuly = new Dictionary <String, String>(); Queue <Struktura> fronta = new Queue <Struktura>(); Struktura korenProgramu = new Struktura("KorenProgramu"); foreach (Objekt o in objekty.Values) { if (o is PouzitieModulu) { if (Projekt.DATABAZA[o.op].clkRstSignal) { clkModuly[o.id] = o.op; } } else if (o.vlastnyModul()) { moduly[o.id] = o.menoModulu(); } if (o.ifBlok == null || !(o is Register || o is IoOperacia || o is IfBlok)) { korenProgramu.deti.Add(new Struktura(o.id)); } else { fronta.Enqueue(new Struktura(o.id)); } } while (fronta.Count > 0) { Struktura s = fronta.Dequeue(); if (!korenProgramu.pridajDieta(objekty[s.id].ifBlok.id, s)) { fronta.Enqueue(s); } } System.IO.File.WriteAllText(@cesta + "\\" + meno + ".luc", generujModul() + generujIo() + generujRegistreAClkModuly(clkModuly) + generujModuly(moduly) + generujProgram(korenProgramu)); return(moduly); }