Exemplo n.º 1
0
 public CodeGenerator(TextWriter sink, Program program, GlobalSymbolTable symbols, DiagnosticsReport diagnostics, NativeDB nativeDB)
 {
     Sink             = sink;
     Program          = program;
     Symbols          = symbols;
     Diagnostics      = diagnostics;
     NativeDB         = nativeDB;
     Strings          = new();
     stmtEmitter      = new(this);
     valueEmitter     = new(this);
     addressEmitter   = new(this);
     optimizer        = new();
     funcInstructions = new();
 }
Exemplo n.º 2
0
        public bool Generate()
        {
            if (Diagnostics.HasErrors)
            {
                return(false);
            }

            Allocator.Allocate(Program, Diagnostics);
            if (Diagnostics.HasErrors)
            {
                return(false);
            }

            Strings = StringsTableBuilder.Build(Program);

            EmitDirectives();
            EmitGlobalsSegment();
            EmitStaticsSegment();
            EmitStringsSegment();
            EmitIncludeSegment();
            EmitCodeSegment();
            return(true);
        }