Add assertions

Closes #292
This commit is contained in:
ISSOtm
2020-03-05 02:58:48 +01:00
parent 03967bd623
commit fb58166e5d
18 changed files with 506 additions and 82 deletions

View File

@@ -20,6 +20,8 @@ extern struct Section *pSectionList, *pCurrentSection;
void out_SetFileName(char *s);
void out_CreatePatch(uint32_t type, struct Expression const *expr);
bool out_CreateAssert(enum AssertionType type, struct Expression const *expr,
char const *message);
void out_WriteObject(void);
#endif /* RGBDS_ASM_OUTPUT_H */

View File

@@ -22,6 +22,7 @@ enum WarningID {
WARNING_OBSOLETE,
WARNING_SHIFT,
WARNING_USER,
WARNING_ASSERT,
WARNING_SHIFT_AMOUNT,
WARNING_TRUNCATION,

View File

@@ -10,6 +10,28 @@
#ifndef RGBDS_LINK_PATCH_H
#define RGBDS_LINK_PATCH_H
#include <stdbool.h>
#include <stdint.h>
#include "link/section.h"
#include "linkdefs.h"
struct Assertion {
struct Patch patch;
// enum AssertionType type; The `patch`'s field is instead re-used
struct Section *section;
char *message;
struct Assertion *next;
};
/**
* Checks all assertions
* @return true if assertion failed
*/
void patch_CheckAssertions(struct Assertion *assertion);
/**
* Applies all SECTIONs' patches to them
*/

View File

@@ -14,7 +14,13 @@
#define RGBDS_OBJECT_VERSION_STRING "RGB%1hhu"
#define RGBDS_OBJECT_VERSION_NUMBER (uint8_t)9
#define RGBDS_OBJECT_REV 1
#define RGBDS_OBJECT_REV 2
enum AssertionType {
ASSERT_WARN,
ASSERT_ERROR,
ASSERT_FATAL
};
enum RPNCommand {
RPN_ADD = 0x00,