LCOV - code coverage report
Current view: top level - asar - asar.h (source / functions) Coverage Total Hit
Test: asar.info Lines: 100.0 % 7 7
Test Date: 2024-01-15 16:23:49 Functions: 100.0 % 2 2
Branches: 100.0 % 2 2

             Branch data     Line data    Source code
       1                 :             : #if (defined(__sun__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)) && !defined(linux)
       2                 :             : #error Please use -Dlinux on non-Linux Unix-likes.
       3                 :             : #endif
       4                 :             : 
       5                 :             : #if defined(linux) && !defined(stricmp)
       6                 :             : #error Please use -Dstricmp=strcasecmp on Unix-like systems.
       7                 :             : #endif
       8                 :             : 
       9                 :             : #pragma once
      10                 :             : #define Asar
      11                 :             : 
      12                 :             : #include "autoarray.h"
      13                 :             : #include "assocarr.h"
      14                 :             : #include "libstr.h"
      15                 :             : #include "libsmw.h"
      16                 :             : #include "errors.h"
      17                 :             : #include "virtualfile.h"
      18                 :             : #include <cstdint>
      19                 :             : 
      20                 :             : extern unsigned const char * romdata_r;
      21                 :             : extern int romlen_r;
      22                 :             : 
      23                 :             : #define clean(string) do { string.qreplace(", ", ",", true); string.qreplace("  ", " ", true); \
      24                 :             :                                                 strip_whitespace(string); string.qreplace("\t", " ", true);} while(0)
      25                 :             : #define clean_and_trim(string) do { clean(string); string.qreplace(" ", "", true);} while(0)
      26                 :             : 
      27                 :             : int getlen(const char * str, bool optimizebankextraction=false);
      28                 :             : bool is_hex_constant(const char * str);
      29                 :             : 
      30                 :             : bool validatedefinename(const char * name);
      31                 :             : 
      32                 :             : string create_symbols_file(string format, uint32_t romCrc);
      33                 :             : 
      34                 :             : void parse_std_includes(const char* textfile, autoarray<string>& outarray);
      35                 :             : void parse_std_defines(const char* textfile);
      36                 :             : 
      37                 :             : void reseteverything();
      38                 :             : 
      39                 :             : void resolvedefines(string& out, const char * start);
      40                 :             : 
      41                 :             : int get_version_int();
      42                 :             : 
      43                 :             : bool setmapper();
      44                 :             : 
      45                 :             : void assemblefile(const char * filename, bool toplevel);
      46                 :             : void assembleline(const char * fname, int linenum, const char * line);
      47                 :             : 
      48                 :             : bool file_included_once(const char* file);
      49                 :             : 
      50                 :             : string getdecor();
      51                 :             : 
      52                 :             : asar_error_id vfile_error_to_error_id(virtual_file_error vfile_error);
      53                 :             : 
      54                 :             : virtual_file_error asar_get_last_io_error();
      55                 :             : 
      56                 :             : extern volatile int recursioncount;
      57                 :             : extern int pass;
      58                 :             : 
      59                 :             : class recurseblock {
      60                 :             : public:
      61                 :     2003000 :         recurseblock()
      62                 :             :         {
      63                 :     2003000 :                 recursioncount++;
      64         [ +  + ]:     2003000 :                 if (recursioncount > 250) asar_throw_error(pass, error_type_fatal, error_id_recursion_limit);
      65                 :     2002999 :         }
      66                 :     2002999 :         ~recurseblock()
      67                 :             :         {
      68                 :     2002999 :                 recursioncount--;
      69                 :     2002999 :         }
      70                 :             : };
      71                 :             : 
      72                 :             : extern const int asarver_maj;
      73                 :             : extern const int asarver_min;
      74                 :             : extern const int asarver_bug;
      75                 :             : extern const bool asarver_beta;
      76                 :             : extern bool default_math_pri;
      77                 :             : extern bool default_math_round_off;
      78                 :             : 
      79                 :             : extern bool asarverallowed;
      80                 :             : extern bool istoplevel;
      81                 :             : 
      82                 :             : extern bool moreonline;
      83                 :             : extern bool moreonlinecond;
      84                 :             : extern int fakeendif;
      85                 :             : 
      86                 :             : extern bool checksum_fix_enabled;
      87                 :             : extern bool force_checksum_fix;
      88                 :             : 
      89                 :             : extern string callerfilename;
      90                 :             : extern int callerline;
      91                 :             : extern string thisfilename;
      92                 :             : extern int thisline;
      93                 :             : extern const char * thisblock;
      94                 :             : 
      95                 :             : extern int incsrcdepth;
      96                 :             : 
      97                 :             : extern bool ignoretitleerrors;
      98                 :             : 
      99                 :             : extern int repeatnext;
     100                 :             : 
     101                 :             : extern int optimizeforbank;
     102                 :             : 
     103                 :             : //this is a trick to namespace an enum to avoid name collision without too much verbosity
     104                 :             : //could technically name the enum too but this is fine for now.
     105                 :             : namespace optimize_dp_flag {
     106                 :             :         enum : int {
     107                 :             :                 NONE,   //don't optimize
     108                 :             :                 RAM,    //bank 7E only (always uses dp base)
     109                 :             :                 ALWAYS  //bank 00-3F[|80] and 7E (always uses dp base)
     110                 :             :         };
     111                 :             : }
     112                 :             : 
     113                 :             : extern int optimize_dp;
     114                 :             : extern int dp_base;
     115                 :             : 
     116                 :             : namespace optimize_address_flag {
     117                 :             :         enum : int {
     118                 :             :                 DEFAULT,//simply use optimizeforbank
     119                 :             :                 RAM,    //default+bank 7E only RAM address < $2000
     120                 :             :                 MIRRORS //ram+if optimizeforbank is 00-3F[|80] and address < $8000
     121                 :             :         };
     122                 :             : }
     123                 :             : 
     124                 :             : extern int optimize_address;
     125                 :             : 
     126                 :             : extern bool errored;
     127                 :             : 
     128                 :             : extern assocarr<string> clidefines;
     129                 :             : 
     130                 :             : extern virtual_filesystem* filesystem;
     131                 :             : 
     132                 :             : extern assocarr<string> defines;
     133                 :             : 
     134                 :             : extern assocarr<string> builtindefines;
        

Generated by: LCOV version 2.0-1