Exemple #1
0
        private static void Generate(IEnumerable <string> extraTranslation)
        {
            Console.WriteLine("Parsing...");
            var sw = Stopwatch.StartNew();


            TranslationManager.Init(extraTranslation);

            if (!Directory.Exists(OutDir))
            {
                Directory.CreateDirectory(OutDir);
            }

            var allTypes = Compilation.SyntaxTrees
                           .SelectMany(o => o.GetRoot().DescendantNodes().OfType <BaseTypeDeclarationSyntax>())
                           .Select(o => new { Syntax = o, Symbol = GetModel(o).GetDeclaredSymbol(o), TypeName = WriteType.TypeName(GetModel(o).GetDeclaredSymbol(o)) })
                           .GroupBy(o => o.Symbol.ContainingNamespace.FullName() + "." + o.TypeName)
                           .ToList();

            Utility.Parallel(Compilation.SyntaxTrees.ToList(), tree =>
            {
                foreach (var n in TriviaProcessor.DoNotWrite(tree))
                {
                    DoNotWrite.TryAdd(n, null);
                }
            });

            Console.WriteLine("Parsed in " + sw.Elapsed + ". Writing out haxe...");
            sw.Restart();

            Compilation.SyntaxTrees.SelectMany(o => o.GetRoot().DescendantNodes().OfType <AnonymousObjectCreationExpressionSyntax>())
            .Select(o => new { Syntax = o, Name = WriteAnonymousObjectCreationExpression.TypeName(o) })
            .GroupBy(o => o.Name)
            .Parallel(o => WriteAnonymousObjectCreationExpression.WriteAnonymousType(o.First().Syntax));


            allTypes.Parallel(type =>
            {
                TypeState.Instance          = new TypeState();
                TypeState.Instance.TypeName = type.First().TypeName;
                TypeState.Instance.Partials = type.Select(o => new TypeState.SyntaxAndSymbol {
                    Symbol = o.Symbol, Syntax = o.Syntax
                })
                                              .Where(o => !DoNotWrite.ContainsKey(o.Syntax))
                                              .ToList();

                if (TypeState.Instance.Partials.Count > 0)
                {
                    WriteType.Go();
                }
            });

            WriteConstructor.WriteConstructorsHelper(allTypes.SelectMany(o => o).Where(o => !DoNotWrite.ContainsKey(o.Syntax)).Select(o => o.Symbol));

            Console.WriteLine("Haxe written out in " + sw.Elapsed);
        }
Exemple #2
0
        public static void Go(Compilation compilation, string outDir, IEnumerable <string> extraTranslation)
        {
            TranslationManager.Init(extraTranslation);

            Compilation = compilation;

            OutDir = outDir;

            Utility.Parallel(new Action[] { Build, Generate }, a => a());
        }
Exemple #3
0
        public static void Go(Compilation compilation, string outDir, IEnumerable <string> extraTranslation, string ctorHelperName, HashSet <string> whitelist, bool buildFirst = false)
        {
            TranslationManager.Init(extraTranslation);

            Compilation    = compilation.AddReferences(TranslationManager.References.Select(o => MetadataReference.CreateFromFile(o)));
            OutDir         = outDir;
            CtorHelperName = ctorHelperName;
            if (whitelist == null || whitelist.Count == 0)
            {
                Whitelist = new List <Regex>()
                {
                    new Regex(".*")
                }
            }
            ;
            else
            {
                Whitelist = whitelist.Select(o => new Regex(o)).ToList();
            }


            Utility.Parallel(new Action[] { Build, Generate }, a => a(), !buildFirst);
        }