| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #if defined(__clang__) || defined(__GNUC__) | ||
| 4 | [[gnu::format(printf, 2, 4)]] | ||
| 5 | #else | ||
| 6 | // msvc only has format string checking in enterprise edition lmao | ||
| 7 | // ehh who tf even develops on windows anyways | ||
| 8 | #endif | ||
| 9 | void error_impl(const char* error_id, const char* fmt_string, int whichpass, ...); | ||
| 10 | |||
| 11 | struct errfatal {}; | ||
| 12 | struct errline : public errfatal {}; | ||
| 13 | struct errblock : public errline {}; | ||
| 14 | struct errnull : public errblock {}; | ||
| 15 | |||
| 16 | #ifdef __clang__ | ||
| 17 | // okay so this ## thing isn't very nice of me, but it works on all compilers | ||
| 18 | // for now. good enough until we upgrade to c++20 (and can use __VA_OPT__) | ||
| 19 | #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" | ||
| 20 | #endif | ||
| 21 | #define throw_err_null(whichpass, id, ...) id(whichpass, ## __VA_ARGS__) | ||
| 22 | #define throw_err_block(whichpass, id, ...) (id(whichpass, ## __VA_ARGS__), throw errblock{}) | ||
| 23 | #define throw_err_line(whichpass, id, ...) (id(whichpass, ## __VA_ARGS__), throw errline{}) | ||
| 24 | #define throw_err_fatal(whichpass, id, ...) (id(whichpass, ## __VA_ARGS__), throw errfatal{}) | ||
| 25 | |||
| 26 | #define ERR(id, fmt_string) template<typename... Ts> inline void err_ ## id(int whichpass, Ts... args) { error_impl("E" #id, fmt_string, whichpass, args...); } | ||
| 27 | |||
| 28 | ✗ | ERR(limit_reached, "Over %d errors detected. Aborting.") | |
| 29 | ✗ | ERR(werror, "One or more warnings was detected with werror on.") | |
| 30 | ✗ | ERR(buffer_too_small, "The given buffer is too small to contain the resulting ROM.") | |
| 31 | ✗ | ERR(params_null, "params passed to asar_patch_ex() is null.") | |
| 32 | ✗ | ERR(params_invalid_size, "Size of params passed to asar_patch_ex() is invalid.") | |
| 33 | ✗ | ERR(cmdl_define_invalid, "Invalid define name in %s: '%s'.") | |
| 34 | ✗ | ERR(cmdl_define_override, "%s '%s' overrides a previous define. Did you specify the same define twice?") | |
| 35 | ✗ | ERR(create_rom_failed, "Couldn't create ROM.") | |
| 36 | ✗ | ERR(open_rom_failed, "Couldn't open ROM.") | |
| 37 | ✗ | ERR(open_rom_not_smw_extension, "Doesn't look like an SMW ROM. (Maybe its extension is wrong?)") | |
| 38 | ✗ | ERR(open_rom_not_smw_header, "Doesn't look like an SMW ROM. (Maybe it's headered?)") | |
| 39 | ✗ | ERR(stddefines_no_identifier, "stddefines.txt contains a line with a value, but no identifier.") | |
| 40 | ✗ | ERR(stddefine_after_closing_quote, "Broken std defines. (Something after closing quote)") | |
| 41 | ✗ | ERR(failed_to_open_file, "Failed to open file '%s'.") | |
| 42 | 6 | ERR(file_not_found, "File '%s' wasn't found.") | |
| 43 | 4 | ERR(file_offset_out_of_bounds, "File offset %s out of bounds for file '%s'.") | |
| 44 | ✗ | ERR(mismatched_parentheses, "Mismatched parentheses.") | |
| 45 | ✗ | ERR(invalid_hex_value, "Invalid hex value.") | |
| 46 | ✗ | ERR(invalid_binary_value, "Invalid binary value.") | |
| 47 | ✗ | ERR(invalid_character, "Invalid character.") | |
| 48 | //ERR(string_literal_not_terminated, "String literal not terminated.") | ||
| 49 | //ERR(malformed_function_call, "Malformed function call.") | ||
| 50 | 12 | ERR(invalid_number, "Invalid number.") | |
| 51 | ✗ | ERR(garbage_near_quoted_string, "Garbage near quoted string.") | |
| 52 | 10 | ERR(mismatched_quotes, "Mismatched quotes.") | |
| 53 | ✗ | ERR(rom_too_short, "ROM is too short to have a title. (Expected '%s')") | |
| 54 | ✗ | ERR(rom_title_incorrect, "ROM title is incorrect. Expected '%s', got '%s'.") | |
| 55 | 4 | ERR(bank_border_crossed, "A bank border was crossed, SNES address $%06X.") | |
| 56 | 6 | ERR(start_of_file, "This command may only be used at the start of a file.") | |
| 57 | ✗ | ERR(invalid_version_number, "Invalid version number.") | |
| 58 | ✗ | ERR(asar_too_old, "This version of Asar is too old for this patch.") | |
| 59 | ✗ | ERR(relative_branch_out_of_bounds, "Relative branch out of bounds. (Distance is %s).") | |
| 60 | ✗ | ERR(snes_address_doesnt_map_to_rom, "SNES address %s doesn't map to ROM.") | |
| 61 | 2 | ERR(snes_address_out_of_bounds, "SNES address %s out of bounds.") | |
| 62 | ✗ | ERR(invalid_tcall, "Invalid tcall.") | |
| 63 | ✗ | ERR(use_xplus, "Use (x+) instead.") | |
| 64 | ✗ | ERR(opcode_length_too_long, "Opcode length is too long.") | |
| 65 | ✗ | ERR(superfx_invalid_short_address, "Invalid short address parameter: $%s. (Must be even number and $0000-$01FE)") | |
| 66 | ✗ | ERR(superfx_invalid_register, "Invalid register for opcode; valid range is %d-%d.") | |
| 67 | 6 | ERR(invalid_opcode_length, "Invalid opcode length specification.") | |
| 68 | ✗ | ERR(invalid_mapper, "Invalid mapper.") | |
| 69 | 4 | ERR(nan, "NaN encountered.") | |
| 70 | 4 | ERR(division_by_zero, "Division by zero.") | |
| 71 | //ERR(modulo_by_zero, "Modulo by zero.") | ||
| 72 | 16 | ERR(unknown_operator, "Unknown operator.") | |
| 73 | ✗ | ERR(invalid_input, "Invalid input.") | |
| 74 | ✗ | ERR(invalid_function_name, "Invalid function name.") | |
| 75 | ✗ | ERR(function_not_found, "Function '%s' wasn't found.") | |
| 76 | ✗ | ERR(function_redefined, "Function '%s' redefined.") | |
| 77 | ✗ | ERR(broken_function_declaration, "Broken function declaration.") | |
| 78 | //ERR(wrong_num_parameters, "Wrong number of parameters to function.") | ||
| 79 | ✗ | ERR(invalid_param_name, "Invalid parameter name '%s'.") | |
| 80 | 12 | ERR(invalid_label_name, "Invalid label name.") | |
| 81 | 6 | ERR(label_not_found, "Label '%s' wasn't found.") | |
| 82 | 2 | ERR(label_redefined, "Label '%s' redefined.") | |
| 83 | 24 | ERR(broken_label_definition, "Broken label definition.") | |
| 84 | 6 | ERR(macro_label_outside_of_macro, "Macro label outside of a macro.") | |
| 85 | ✗ | ERR(invalid_namespace_name, "Invalid namespace name.") | |
| 86 | ✗ | ERR(invalid_namespace_use, "Invalid use of namespace command.") | |
| 87 | ✗ | ERR(invalid_struct_name, "Invalid struct name.") | |
| 88 | ✗ | ERR(struct_not_found, "Struct '%s' wasn't found.") | |
| 89 | ✗ | ERR(struct_redefined, "Struct '%s' redefined.") | |
| 90 | ✗ | ERR(struct_invalid_parent_name, "Invalid parent name.") | |
| 91 | ✗ | ERR(invalid_label_missing_closer, "Invalid label name, missing array closer.") | |
| 92 | //ERR(invalid_subscript, "Invalid array subscript after first scope resolution.") | ||
| 93 | ✗ | ERR(label_missing_parent, "This label has no parent.") | |
| 94 | ✗ | ERR(struct_without_endstruct, "struct without matching endstruct.") | |
| 95 | ✗ | ERR(nested_struct, "Can not nest structs.") | |
| 96 | ✗ | ERR(missing_struct_params, "Missing struct parameters.") | |
| 97 | ✗ | ERR(too_many_struct_params, "Too many struct parameters.") | |
| 98 | ✗ | ERR(missing_extends, "Missing extends keyword.") | |
| 99 | ✗ | ERR(invalid_endstruct_count, "Invalid endstruct parameter count.") | |
| 100 | ✗ | ERR(expected_align, "Expected align parameter.") | |
| 101 | 2 | ERR(endstruct_without_struct, "endstruct can only be used in combination with struct.") | |
| 102 | ✗ | ERR(alignment_too_small, "Alignment must be >= 1.") | |
| 103 | ✗ | ERR(invalid_define_name, "Invalid define name.") | |
| 104 | 7 | ERR(define_not_found, "Define '%s' wasn't found.") | |
| 105 | ERR(define_not_found2, "Define '%s' wasn't found.") | ||
| 106 | ✗ | ERR(broken_define_declaration, "Broken define declaration.") | |
| 107 | 6 | ERR(overriding_builtin_define, "Trying to set define '%s', which is the name of a built-in define and thus can't be modified.") | |
| 108 | //ERR(define_label_math, "!Define #= Label is not allowed with non-static labels.") | ||
| 109 | ✗ | ERR(mismatched_braces, "Mismatched braces.") | |
| 110 | ✗ | ERR(invalid_macro_name, "Invalid macro name.") | |
| 111 | ✗ | ERR(macro_not_found, "Macro '%s' wasn't found.") | |
| 112 | ✗ | ERR(macro_redefined, "Macro '%s' redefined. First defined at: %s:%d") | |
| 113 | ✗ | ERR(broken_macro_declaration, "Broken macro declaration.") | |
| 114 | ✗ | ERR(invalid_macro_param_name, "Invalid macro parameter name.") | |
| 115 | 36 | ERR(macro_param_not_found, "Macro parameter '%s' wasn't found.%s") | |
| 116 | ✗ | ERR(macro_param_redefined, "Macro parameter '%s' redefined") | |
| 117 | ✗ | ERR(broken_macro_usage, "Broken macro usage.") | |
| 118 | ✗ | ERR(macro_wrong_num_params, "Wrong number of parameters to macro.") | |
| 119 | ✗ | ERR(misplaced_endmacro, "Misplaced endmacro.") | |
| 120 | 12 | ERR(unclosed_macro, "Unclosed macro: '%s'.") | |
| 121 | //ERR(label_in_conditional, "Non-static label in %s command.") | ||
| 122 | ✗ | ERR(misplaced_elseif, "Misplaced elseif.") | |
| 123 | ✗ | ERR(elseif_in_while, "Can't use elseif in a while loop.") | |
| 124 | ✗ | ERR(misplaced_endif, "Misplaced endif.") | |
| 125 | ✗ | ERR(misplaced_else, "Misplaced else.") | |
| 126 | ✗ | ERR(else_in_while_loop, "Can't use else in a while loop.") | |
| 127 | ✗ | ERR(unclosed_if, "Unclosed if statement.") | |
| 128 | 15 | ERR(unknown_command, "Unknown command.") | |
| 129 | 6 | ERR(broken_incbin, "Broken incbin command.") | |
| 130 | 2 | ERR(recursion_limit, "Recursion limit reached.") | |
| 131 | 2 | ERR(cant_be_main_file, "This file may not be used as the main file.%s") | |
| 132 | 54 | ERR(no_labels_here, "Can't use non-static labels here.") | |
| 133 | ✗ | ERR(invalid_freespace_request, "Invalid freespace request.") | |
| 134 | ✗ | ERR(static_freespace_autoclean, "A static freespace must be targeted by at least one autoclean.") | |
| 135 | 2 | ERR(static_freespace_growing, "A static freespace may not grow.") | |
| 136 | ✗ | ERR(no_freespace_in_mapped_banks, "No freespace found in the mapped banks. (Requested size: %s)") | |
| 137 | ✗ | ERR(no_freespace, "No freespace found. (Requested size: %s)") | |
| 138 | ✗ | ERR(prot_not_at_freespace_start, "PROT must be used at the start of a freespace block.") | |
| 139 | ✗ | ERR(prot_too_many_entries, "Too many entries to PROT.") | |
| 140 | ✗ | ERR(autoclean_in_freespace, "autoclean used in freespace.") | |
| 141 | ✗ | ERR(autoclean_label_at_freespace_end, "Don't autoclean a label at the end of a freespace block, you'll remove some stuff you're not supposed to remove.") | |
| 142 | ✗ | ERR(broken_autoclean, "Broken autoclean command.") | |
| 143 | ✗ | ERR(pulltable_without_table, "Using pulltable when there is no table on the stack yet.") | |
| 144 | ✗ | ERR(pad_in_freespace, "pad does not make sense in a freespaced code.") | |
| 145 | //ERR(base_label_invalid, "base Label is not valid.") | ||
| 146 | ✗ | ERR(pushpc_without_pullpc, "pushpc without matching pullpc.") | |
| 147 | ✗ | ERR(pullpc_without_pushpc, "pullpc without matching pushpc.") | |
| 148 | ✗ | ERR(pullpc_different_arch, "pullpc in another architecture than the pushpc.") | |
| 149 | ✗ | ERR(pullbase_without_pushbase, "pullbase without matching pushbase.") | |
| 150 | ✗ | ERR(invalid_check, "Invalid check command.") | |
| 151 | 12 | ERR(assertion_failed, "Assertion failed%s") | |
| 152 | 21 | ERR(error_command, "error command%s") | |
| 153 | //ERR(invalid_print_function_syntax, "Invalid printable string syntax.") | ||
| 154 | ✗ | ERR(unknown_variable, "Unknown variable.") | |
| 155 | 6 | ERR(pushwarnings_without_pullwarnings, "warnings push without matching warnings pull.") | |
| 156 | 6 | ERR(pullwarnings_without_pushwarnings, "warnings pull without matching warnings push.") | |
| 157 | ✗ | ERR(failed_to_open_file_access_denied, "Failed to open file '%s'. Access denied.") | |
| 158 | 12 | ERR(failed_to_open_not_regular_file, "Failed to open file '%s'. Not a regular file (did you try to use a directory?)") | |
| 159 | ✗ | ERR(bad_dp_base, "The dp base should be page aligned (i.e. a multiple of 256), got %s") | |
| 160 | ✗ | ERR(bad_dp_optimize, "Bad dp optimize value %s, expected: [none, ram, always]") | |
| 161 | ✗ | ERR(bad_address_optimize, "Bad dp optimize value %s, expected: [default, ram, mirrors]") | |
| 162 | ✗ | ERR(bad_optimize, "Bad optimize value %s, expected: [dp, address]") | |
| 163 | //ERR(require_parameter, "Missing required function parameter") | ||
| 164 | //ERR(expected_parameter, "Not enough parameters in calling of function %s") | ||
| 165 | //ERR(unexpected_parameter, "Too many parameters in calling of function %s") | ||
| 166 | ✗ | ERR(duplicate_param_name, "Duplicated parameter name: %s in creation of function %s") | |
| 167 | ✗ | ERR(invalid_alignment, "Invalid alignment. Expected a power of 2.") | |
| 168 | ✗ | ERR(alignment_too_big, "Requested alignment too large.") | |
| 169 | 4 | ERR(negative_shift, "Bitshift amount is negative.") | |
| 170 | 10 | ERR(macro_not_varadic, "Invalid use of %s, active macro is not variadic.") | |
| 171 | 2 | ERR(vararg_sizeof_nomacro, "Invalid use of sizeof(...), no active macro.") | |
| 172 | 12 | ERR(macro_wrong_min_params, "Variadic macro call with too few parameters") | |
| 173 | 30 | ERR(vararg_out_of_bounds, "Variadic macro parameter %s is out of bounds.%s") | |
| 174 | 2 | ERR(vararg_must_be_last, "Variadic macro parameter must be the last parameter.") | |
| 175 | 12 | ERR(invalid_global_label, "Global label definition contains an invalid label [%s].") | |
| 176 | ✗ | ERR(spc700_addr_out_of_range, "Address %s out of range for instruction, valid range is 0000-1FFF") | |
| 177 | 2 | ERR(label_ambiguous, "Label (%s) location is ambiguous due to straddling optimization border.") | |
| 178 | ✗ | ERR(feature_unavaliable_in_spcblock, "This feature may not be used while an spcblock is active") | |
| 179 | ✗ | ERR(endspcblock_without_spcblock, "Use of endspcblock without matching spcblock") | |
| 180 | ✗ | ERR(missing_endspcblock, "Use of endspcblock without matching spcblock") | |
| 181 | ✗ | ERR(spcblock_inside_struct, "Can not start an spcblock while a struct is still open") | |
| 182 | ✗ | ERR(spcblock_too_few_args, "Too few args passed to spcblock") | |
| 183 | ✗ | ERR(spcblock_too_many_args, "Too many args passed to spcblock") | |
| 184 | ✗ | ERR(unknown_spcblock_type, "Unknown spcblock format") | |
| 185 | ✗ | ERR(custom_spcblock_missing_macro, "Custom spcblock types must refer to a valid macro") | |
| 186 | ✗ | ERR(spcblock_macro_doesnt_exist, "Macro specified to custom spcblock was not found") | |
| 187 | ✗ | ERR(extra_spcblock_arg_for_type, "Only custom spcblock type takes a fourth argument") | |
| 188 | ✗ | ERR(spcblock_macro_must_be_varadic, "Custom spcblock macros must be variadic") | |
| 189 | ✗ | ERR(spcblock_macro_invalid_static_args, "Custom spcblock macros must have three static arguments") | |
| 190 | ✗ | ERR(spcblock_custom_types_incomplete, "Custom spcblock types are not yet supported. One day.") | |
| 191 | ✗ | ERR(invalid_endspcblock_arg, "Invalid argument to endspcblock: \"%s\"") | |
| 192 | ✗ | ERR(unknown_endspcblock_format, "Unsupported endspcblock format. Currently supported formats are \"endspcblock\" and \"endspcblock execute [label]\"") | |
| 193 | ✗ | ERR(internal_error, "An internal error occured (%s). This is a bug in Asar, please report it at https://github.com/RPGHacker/asar/issues, along with a patch that reproduces it if possible.") | |
| 194 | ✗ | ERR(pushns_without_pullns, "pushns without matching pullns.") | |
| 195 | ✗ | ERR(pullns_without_pushns, "pullns without matching pushns.") | |
| 196 | 4 | ERR(label_forward, "The use of forward labels is not allowed in this context.") | |
| 197 | ✗ | ERR(undefined_char, "'%s' is not defined in the character table") | |
| 198 | 2 | ERR(invalid_utf8, "Invalid text encoding detected. Asar expects UTF-8-encoded text. Please re-save this file in a text editor of choice using UTF-8 encoding.") | |
| 199 | ✗ | ERR(cmdl_utf16_to_utf8_failed, "UTF-16 to UTF-8 string conversion failed: %s.") | |
| 200 | ✗ | ERR(broken_command, "Broken %s command. %s") | |
| 201 | 4 | ERR(oob, "Operation out of bounds: Requested index %d for object of size %d") | |
| 202 | 6 | ERR(unclosed_vararg, "Variadic macro parameter wasn't closed properly.") | |
| 203 | //ERR(invalid_vararg, "Trying to use variadic macro parameter syntax to resolve a non variadic argument <%s>.") | ||
| 204 | 24 | ERR(invalid_depth_resolve, "Invalid %s resolution depth: Trying to backwards-resolve a %s using %i '^', but current scope only supports up to %i '^'.") | |
| 205 | 12 | ERR(platform_paths, "Platform-specific paths aren'supported. Please use platform-independent paths (use / instead of \\).") | |
| 206 | ✗ | ERR(bad_single_line_for, "Single-line for loop not allowed here.") | |
| 207 | ✗ | ERR(broken_for_loop, "Broken for loop command: %s") | |
| 208 | ✗ | ERR(missing_org, "Missing org or freespace command.") | |
| 209 | 2 | ERR(unclosed_block_comment, "Unclosed block comment.") | |
| 210 | 6 | ERR(bad_addr_mode, "This addressing mode is not valid for this instruction.") | |
| 211 | ✗ | ERR(bad_access_width, "This addressing mode can accept %s arguments, but the provided argument is %d-bit.") | |
| 212 | ✗ | ERR(label_before_if, "Labels are not allowed before \"%s\" commands. Suggestion: move the label to a separate line.") | |
| 213 | 8 | ERR(bad_type, "Type error when evaluating math: expected %s, got %s") | |
| 214 | 6 | ERR(argument_count, "Wrong number of arguments. Expected %d, got %d") | |
| 215 | |||
| 216 |