Inheritance: IEmitTarget
Ejemplo n.º 1
0
 public EmitTypeCPP(
     EmitTargetCPP target,
     string name,
     UInt32 size,
     UInt32 alignment)
     : this(target, string.Format("{0} {{0}}", name), size, alignment, null)
 {
 }
Ejemplo n.º 2
0
 public EmitStructCPP(
     EmitTargetCPP target,
     string name,
     Span headerSpan,
     Span sourceSpan)
 {
     _target     = target;
     _name       = name;
     _headerSpan = headerSpan;
     _sourceSpan = sourceSpan;
 }
Ejemplo n.º 3
0
 public EmitValCPP(
     EmitTargetCPP target,
     string name,
     IEmitType type,
     bool isOwnAddress = false)
 {
     _target       = target;
     _name         = name;
     _type         = type;
     _isOwnAddress = isOwnAddress;
 }
Ejemplo n.º 4
0
 public EmitTypeCPP(
     EmitTargetCPP target,
     string format,
     UInt32 size,
     UInt32 alignment,
     IEmitTypeCPP baseType)
 {
     _target    = target;
     _format    = format;
     _size      = size;
     _alignment = alignment;
     _baseType  = baseType;
 }
Ejemplo n.º 5
0
        public EmitModuleCPP(
            EmitTargetCPP target,
            string name,
            Span headerSpan,
            Span sourceSpan)
        {
            _target     = target;
            _name       = name;
            _headerSpan = headerSpan;
            _sourceSpan = sourceSpan;

            _headerSpan.WriteLine("// Automatically generated code. Do not edit.");
            _headerSpan.WriteLine("#pragma once");
            _headerSpan.WriteLine("#include <d3d11.h>");
            _headerSpan.WriteLine("#include <spark/spark.h>");
            _headerSpan.WriteLine("#include <spark/context.h>");

            _sourceSpan.WriteLine("// Automatically generated code. Do not edit.");
            _sourceSpan.WriteLine("#include \"{0}.h\"", _name);
            _sourceSpan.WriteLine("#pragma warning(disable: 4100)");
            _sourceSpan.WriteLine();
        }
Ejemplo n.º 6
0
 public EmitStructCPP(
     EmitTargetCPP target,
     string name,
     Span headerSpan,
     Span sourceSpan)
 {
     _target = target;
     _name = name;
     _headerSpan = headerSpan;
     _sourceSpan = sourceSpan;
 }
Ejemplo n.º 7
0
        public EmitModuleCPP(
            EmitTargetCPP target,
            string name,
            Span headerSpan,
            Span sourceSpan)
        {
            _target = target;
            _name = name;
            _headerSpan = headerSpan;
            _sourceSpan = sourceSpan;

            _headerSpan.WriteLine("// Automatically generated code. Do not edit.");
            _headerSpan.WriteLine( "#pragma once" );
            _headerSpan.WriteLine( "#include <d3d11.h>" );
            _headerSpan.WriteLine("#include <spark/spark.h>");
            _headerSpan.WriteLine("#include <spark/context.h>");

            _sourceSpan.WriteLine("// Automatically generated code. Do not edit.");
            _sourceSpan.WriteLine("#include \"{0}.h\"", _name);
            _sourceSpan.WriteLine("#pragma warning(disable: 4100)");
            _sourceSpan.WriteLine();
        }
Ejemplo n.º 8
0
 public EmitValCPP(
     EmitTargetCPP target,
     string name,
     IEmitType type,
     bool isOwnAddress = false )
 {
     _target = target;
     _name = name;
     _type = type;
     _isOwnAddress = isOwnAddress;
 }
Ejemplo n.º 9
0
 public EmitTypeCPP(
     EmitTargetCPP target,
     string format,
     UInt32 size,
     UInt32 alignment,
     IEmitTypeCPP baseType )
 {
     _target = target;
     _format = format;
     _size = size;
     _alignment = alignment;
     _baseType = baseType;
 }
Ejemplo n.º 10
0
 public EmitTypeCPP(
     EmitTargetCPP target,
     string name,
     UInt32 size,
     UInt32 alignment)
     : this(target, string.Format("{0} {{0}}", name), size, alignment, null)
 {
 }
Ejemplo n.º 11
0
        public int Compile()
        {
            int errorCount = 0;

            errorCount += Parse();
            if (errorCount != 0)
                return errorCount;

            errorCount += Resolve();
            if (errorCount != 0)
                return errorCount;

            errorCount += Lower();
            if (errorCount != 0)
                return errorCount;

            var outputHeaderName = string.Format("{0}.h", OutputPrefix);
            var outputSourceName = string.Format("{0}.cpp", OutputPrefix);

            var emitTarget = new EmitTargetCPP();
            var emitContext = new EmitContext {
                OutputName = OutputPrefix,
                Target = emitTarget,
                Identifiers = Identifiers,
                Diagnostics = Diagnostics, };

            var emitModule = (EmitModuleCPP) emitContext.EmitModule(_midModule);

            errorCount += Diagnostics.Flush(System.Console.Error);
            if( errorCount != 0 )
                return errorCount;

            using (var headerWriter = new System.IO.StreamWriter(
                outputHeaderName, false, Encoding.ASCII))
            {
                emitModule.HeaderSpan.Dump(headerWriter);
            }
            using (var sourceWriter = new System.IO.StreamWriter(
                outputSourceName, false, Encoding.ASCII))
            {
                emitModule.SourceSpan.Dump(sourceWriter);
            }

            errorCount += Diagnostics.Flush(System.Console.Error);
            return errorCount;
        }