MCPcopy Create free account
hub / github.com/Meridian59/Meridian59 / codegen

Function codegen

blakcomp/codegen.c:857–942  ·  view source on GitHub ↗

/ * codegen: Generate code for all the classes in the symbol table. */

Source from the content-addressed store, hash-verified

855 * codegen: Generate code for all the classes in the symbol table.
856 */
857void codegen(char *kod_fname, char *bof_fname)
858{
859 list_type c = NULL;
860 long endpos, stringpos, debugpos, namepos;
861
862 codegen_ok = true;
863 debug_lines = NULL;
864
865 outfile = fopen(bof_fname, "w+b");
866
867 if (outfile == nullptr)
868 {
869 simple_error("Unable to open bof file %s!", bof_fname);
870 return;
871 }
872
873 /* Write out header info */
874 codegen_header();
875
876 /* Remember position for backpatching location of kod filename, and leave room */
877 namepos = FileCurPos(outfile);
878 OutputInt(outfile, 0);
879
880 /* Remember position for backpatching location of string table, and leave room */
881 stringpos = FileCurPos(outfile);
882 OutputInt(outfile, 0);
883
884 /* Remember position for backpatching location of debugging info, and leave room */
885 debugpos = FileCurPos(outfile);
886 OutputInt(outfile, 0);
887
888 codegen_classes();
889
890 if (codegen_ok)
891 {
892 /* Backpatch location of string table */
893 endpos = FileCurPos(outfile);
894 FileGoto(outfile, stringpos);
895 OutputInt(outfile, endpos);
896
897 FileGotoEnd(outfile);
898 codegen_string_table();
899
900 /* Backpatch location of debug info */
901 endpos = FileCurPos(outfile);
902 FileGoto(outfile, debugpos);
903 if (debug_bof)
904 OutputInt(outfile, endpos);
905 else OutputInt(outfile, 0);
906
907 FileGotoEnd(outfile);
908 if (debug_bof)
909 codegen_debug_info();
910
911 /* Backpatch location of kod filename */
912 endpos = FileCurPos(outfile);
913 FileGoto(outfile, namepos);
914 OutputInt(outfile, endpos);

Callers

nothing calls this directly

Calls 10

codegen_headerFunction · 0.85
OutputIntFunction · 0.85
codegen_classesFunction · 0.85
codegen_string_tableFunction · 0.85
codegen_debug_infoFunction · 0.85
codegen_filenameFunction · 0.85
codegen_errorFunction · 0.85
write_resourcesFunction · 0.85
save_kodbaseFunction · 0.85
set_extensionFunction · 0.70

Tested by

no test coverage detected