示例#1
0
文件: Program.cs 项目: ajlopez/AjTalk
        public static void Main(string[] args)
        {
            StreamWriter swriter = new StreamWriter(GetOutputFileName(args));
            SourceWriter writer = new SourceWriter(swriter);
            CodeModel model = new CodeModel();
            Compilers.Javascript.Compiler compiler = null;

            string target = GetTarget(args);

            if (target == "node")
                compiler = new NodeCompiler(writer);
            else if (target == "browser")
                compiler = new BrowserCompiler(writer);
            else if (target == "vm")
                compiler = new VirtualMachineCompiler(writer);
            else
                throw new ArgumentException("Invalid target");

            foreach (string filename in GetFileNames(args))
            {
                ChunkReader chunkReader = new ChunkReader(filename);
                CodeReader reader = new CodeReader(chunkReader);

                reader.Process(model);
            }

            compiler.Visit(model);

            swriter.Close();
        }
示例#2
0
 public void Setup()
 {
     this.writer = new StringWriter();
     this.compiler = new BrowserCompiler(new SourceWriter(this.writer));
 }