Exemplo n.º 1
0
 public void Setup()
 {
     sw = new StringWriter();
     formatter = new TextFormatter(sw);
     cf = new CodeFormatter(formatter);
     m = new ExpressionEmitter();
 }
Exemplo n.º 2
0
		public override string ToString()
		{
			StringWriter sw = new StringWriter();
            TextFormatter fmt = new TextFormatter(sw);
            CodeFormatter cf = new CodeFormatter(fmt);
            TypeFormatter tf = new TypeFormatter(fmt, false);
			Signature.Emit(Name, ProcedureSignature.EmitFlags.ArgumentKind, fmt, cf, tf);
			return sw.ToString();
		}
Exemplo n.º 3
0
		public void Write(TextWriter writer)
		{
            var sl = new SortedList<string, ProcedureSignature>(
                Signatures,
                StringComparer.InvariantCulture);
            TextFormatter f = new TextFormatter(writer);
			foreach (KeyValuePair<string,ProcedureSignature> de in sl)
			{
				string name = (string) de.Key;
				de.Value.Emit(de.Key, ProcedureSignature.EmitFlags.ArgumentKind, f);
				writer.WriteLine();
			}
		}
Exemplo n.º 4
0
 public void CopyAll()
 {
     if (this.proc == null)
         return;
     var sw = new StringWriter();
     var writer = new TextFormatter(sw);
     var fmt = new CodeFormatter(writer);
     fmt.Write(proc);
     sw.Flush();
     Clipboard.SetText(sw.ToString());
 }
Exemplo n.º 5
0
		public void DumpProgram()
		{
			foreach (Procedure proc in program.Procedures.Values)
			{
				StringWriter output = new StringWriter();
				ProcedureFlow pf= this.flow[proc];
                TextFormatter f = new TextFormatter(output);
				if (pf.Signature != null)
					pf.Signature.Emit(proc.Name, ProcedureSignature.EmitFlags.None, f);
				else if (proc.Signature != null)
					proc.Signature.Emit(proc.Name, ProcedureSignature.EmitFlags.None, f);
				else
					output.Write("Warning: no signature found for {0}", proc.Name);
				output.WriteLine();
				pf.Emit(program.Architecture, output);

				output.WriteLine("// {0}", proc.Name);
				proc.Signature.Emit(proc.Name, ProcedureSignature.EmitFlags.None, f);
				output.WriteLine();
				foreach (Block block in proc.ControlGraph.Blocks)
				{
					if (block != null)
					{
						BlockFlow bf = this.flow[block];
						bf.Emit(program.Architecture, output);
						output.WriteLine();
						block.Write(output);
					}
				}
				Debug.WriteLine(output.ToString());
			}
		}
Exemplo n.º 6
0
		public void WriteStatements(TextWriter writer)
		{
            TextFormatter f = new TextFormatter(writer);
            f.UseTabs = true;
            f.TabSize = 4;
            CodeFormatter cf = new CodeFormatter(f);
			int i = 0;
			foreach (Statement s in Statements)
			{
				s.Instruction.Accept(cf);
				++i;
			}
		}
Exemplo n.º 7
0
        public void Write(TextWriter w)
        {
            var writer = new TextFormatter(w);
            writer.WriteLine("// Equivalence classes ////////////");
            foreach (TypeVariable tv in TypeVariables)
            {
                if (tv.Class.Representative == tv && tv.Class.DataType != null)
                {
                    writer.WriteLine("{0}: {1}", tv.Class, tv.Class.DataType);
                    foreach (TypeVariable tvMember in tv.Class.ClassMembers)
                    {
                        writer.Write("\t{0}", tvMember);
                        WriteExpressionOf(tvMember, writer);
                        writer.WriteLine();
                    }
                }
            }

            writer.WriteLine("// Type Variables ////////////");
            foreach (TypeVariable tv in TypeVariables)
            {
                WriteEntry(tv, writer);
            }
        }
Exemplo n.º 8
0
 public string ToString(string name)
 {
     StringWriter sw = new StringWriter();
     TextFormatter f = new TextFormatter(sw);
     CodeFormatter cf = new CodeFormatter(f);
     TypeFormatter tf = new TypeFormatter(f, false);
     Emit(name, EmitFlags.ArgumentKind, f, cf, tf);
     return sw.ToString();
 }
Exemplo n.º 9
0
 public override string ToString()
 {
     StringWriter w = new StringWriter();
     TextFormatter f = new TextFormatter(w);
     CodeFormatter cf = new CodeFormatter(f);
     TypeFormatter tf = new TypeFormatter(f, false);
     Emit("()", EmitFlags.ArgumentKind | EmitFlags.LowLevelInfo, f, cf, tf);
     return w.ToString();
 }