EmitNewLine() public method

Emits a new line character, thus starting a new source line.
public EmitNewLine ( ) : void
return void
示例#1
0
    static void Main(string[] args) {
      if (args == null || args.Length == 0) {
        Console.WriteLine("usage: ILtoC [path]fileName.ext");
        return;
      }
      using (var host = new Host()) {
        var mscorlib = host.LoadUnitFrom("mscorlib.dll") as IAssembly;
        if (mscorlib == null || mscorlib is Dummy) {
          Console.WriteLine("mscorlib.dll must be in the same directory as "+args[0]);
          return;
        }
        var coreIdentity = host.CoreAssemblySymbolicIdentity; //Force the host to select the local mscorlib as the core assembly.
        if (coreIdentity != mscorlib.AssemblyIdentity) {
          Console.WriteLine("bug in host");
          return;
        }
        var module = host.LoadUnitFrom(args[0]) as IModule;
        if (module == null || module is Dummy) {
          Console.WriteLine(args[0]+" is not a PE file containing a CLR module or assembly.");
          return;
        }
        var moduleLocation = args[0];
        Contract.Assume(moduleLocation.Length > 0);

        PdbReader/*?*/ pdbReader = null;
        string pdbFileName = Path.ChangeExtension(moduleLocation, "pdb");
        if (File.Exists(pdbFileName)) {
          using (var pdbStream = File.OpenRead(pdbFileName)) {
            pdbReader = new PdbReader(pdbStream, host);
          }
        }
        var cfile = Path.ChangeExtension(moduleLocation, ".c");
        var hfile = Path.ChangeExtension(moduleLocation, ".h");
        var moduleFileName = Path.GetFileName(moduleLocation);
        Contract.Assume(moduleFileName != null && moduleFileName.Length > 0);
        string location = Path.GetFullPath(moduleLocation).Replace(moduleFileName, ""); ;
        using (var cStreamWriter = File.CreateText(cfile)) {
          using (var hStreamWriter = File.CreateText(hfile)) {
            var cEmitter = new SourceEmitter(cStreamWriter);
            cEmitter.EmitString("#include \"");
            cEmitter.EmitString(hfile);
            cEmitter.EmitString("\"");
            cEmitter.EmitNewLine();
            var hEmitter = new SourceEmitter(hStreamWriter);
            new Translator(host, module, mscorlib, cEmitter, hEmitter, location, pdbReader).TranslateToC();
          }
        }
      }
    }