public string EmitCode(CSharpAbstractSyntaxTree abstractSyntaxTree)
    {
        var builder = ImmutableArray.CreateBuilder <MemberDeclarationSyntax>();

        FunctionExterns(builder, abstractSyntaxTree.FunctionExterns);
        FunctionPointers(builder, abstractSyntaxTree.FunctionPointers);
        Structs(builder, abstractSyntaxTree.Structs);
        OpaqueDataTypes(builder, abstractSyntaxTree.OpaqueDataTypes);
        Typedefs(builder, abstractSyntaxTree.Typedefs);
        Enums(builder, abstractSyntaxTree.Enums);
        PseudoEnums(builder, abstractSyntaxTree.PseudoEnums);
        Constants(builder, abstractSyntaxTree.Constants);

        var members = builder.ToArray();

        var compilationUnit = CompilationUnit(
            _className,
            _libraryName,
            _namespaceName,
            _headerCodeRegion,
            _footerCodeRegion,
            members);

        return(compilationUnit.ToFullString());
    }
Exemple #2
0
    private string GenerateCSharpCode(
        CSharpAbstractSyntaxTree abstractSyntaxTree,
        string className,
        string libraryName,
        string namespaceName,
        string headerCodeRegion,
        string footerCodeRegion)
    {
        BeginStep();
        var codeGenerator = new CSharpCodeGenerator(
            className, libraryName, namespaceName, headerCodeRegion, footerCodeRegion);
        var result = codeGenerator.EmitCode(abstractSyntaxTree);

        EndStep();

        return(result);
    }