PreprocessString() public method

public PreprocessString ( string Text, string FileName = "<unknown>" ) : void
Text string
FileName string
return void
示例#1
0
文件: CCompiler.cs 项目: soywiz/ilcc
        public static Type CompileProgram(string CProgram, bool SaveTemp = false)
        {
            var CILConverter = new CILConverter(SaveAssembly: SaveTemp);
            CILConverter.Initialize("Program" + UniqueCounter++ + ".exe");
            var CPreprocessor = new CPreprocessor();
            CPreprocessor.PreprocessString(CProgram);
            var PreprocessedCProgram = CPreprocessor.TextWriter.ToString();

            var CCompiler = new CCompiler();
            var TranslationUnit = CParser.StaticParseTranslationUnit(PreprocessedCProgram);
            (CILConverter as ICConverter).ConvertTranslationUnit(CCompiler, TranslationUnit);
            return CILConverter.RootTypeBuilder;
        }
示例#2
0
文件: Program.cs 项目: soywiz/ilcc
        static void SandboxTest(string[] args)
        {
            #if false
            var CPreprocessor = new CPreprocessor();
            CPreprocessor.PreprocessString(@"
                //#define OF() ()
                //typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
            ");

            var Text = (CPreprocessor.TextWriter.ToString());
            Console.WriteLine(Text);
            #elif true
            //CLibTest.TestCall();

            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"c:\temp\zlib-1.2.7\adler32.c" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"c:\temp\zlib-1.2.7\trees.c" });
            new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"c:\temp\ll.c", "-run" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"c:\temp\stemmer.c", "-run", @"c:\temp\voc.txt", });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"C:\projects\@_opensource\libwebp-0.1.3\src\dec\alpha.c" });

            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"C:\temp\m.c" });

            //Console.WriteLine(CLibTest.TestStackAlloc());
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=pinvoke", @"C:\temp\comp\complib.c", @"C:\temp\comp\comptoe.c" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"C:\temp\comp\complib.c", @"C:\temp\comp\comptoe.c" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"C:\temp\z5.c" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"C:\temp\z.c" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=pinvoke", @"C:\temp\z.c" });
            //new CCompilerProgram().ProcessArgs(new string[] { "--target=cil", @"c:\temp\zlib-1.2.7\adler32.c" });
            #else
            var Node = CParser.StaticParseProgram(@"
                void test() {
                    call();
                }
            ");
            Console.WriteLine(Node.ToYaml());
            #endif
        }
示例#3
0
文件: CCompiler.cs 项目: soywiz/ilcc
 public void CompileFiles(string[] FileNames)
 {
     var CCodeWriter = new StringWriter();
     if (FileNames.Length > 0)
     {
         this.OutputName = Path.GetFileNameWithoutExtension(FileNames[0]) + ".exe";
         this.Target.SetOutputName(this.OutputName);
         //Console.WriteLine(this.OutputName);
         //Console.ReadKey();
     }
     foreach (var FileName in FileNames)
     {
         var Text = File.ReadAllText(FileName);
         var CPreprocessor = new CPreprocessor(IncludeReader, CCodeWriter);
         CPreprocessor.PreprocessString(Text, FileName);
         if (JustShowMacros)
         {
             CPreprocessor.Context.DumpMacros();
         }
     }
     if (!JustShowMacros)
     {
         if (JustPreprocess)
         {
             Console.WriteLine(CCodeWriter.ToString());
         }
         else
         {
             CompileString(CCodeWriter.ToString());
         }
     }
 }