NULLABLE annotation

This commit is contained in:
Timerix 2024-11-16 17:55:07 +05:00
parent 9da8732d93
commit b8296a45a7
6 changed files with 9 additions and 6 deletions

View File

@ -45,7 +45,7 @@ typedef struct VM {
};
VMState state;
char* error_message;
NULLABLE(char* error_message);
u8* data;
size_t data_size;

View File

@ -1,6 +1,6 @@
#include "impl_macros.h"
FILE* fileFromN(VM* vm, size_t pos, u32 file_n){
NULLABLE(FILE* fileFromN(VM* vm, size_t pos, u32 file_n)){
FILE* f = NULL;
switch(file_n){
case 0: f = stdin; break;

View File

@ -16,7 +16,7 @@ const Instruction instructions[] = {
};
const size_t instructions_count = sizeof(instructions)/sizeof(instructions[0]);
const Instruction* Instruction_getFromOpcode(u8 opcode){
NULLABLE(const Instruction* Instruction_getFromOpcode(u8 opcode)){
if(opcode >= instructions_count)
return NULL;

View File

@ -18,7 +18,7 @@ typedef struct Instruction {
/// @brief get instruction info from table
/// @param opcode any byte
/// @return ptr to struct or NULL
const Instruction* Instruction_getFromOpcode(u8 opcode);
NULLABLE(const Instruction* Instruction_getFromOpcode(u8 opcode));
i32 NOP_impl(VM* vm, size_t pos);
i32 PUSH_impl(VM* vm, size_t pos);

View File

@ -4,7 +4,7 @@
#define arg_is(STR) (strcmp(argv[argi], STR) == 0)
i32 main(const i32 argc, const char** argv){
const char* filename = NULL;
const char* NULLABLE(filename) = NULL;
for(i32 argi = 1; argi < argc; argi++){
if(arg_is("-h") || arg_is("--help")){

View File

@ -24,4 +24,7 @@ typedef u8 bool;
#define true 1
#define false 0
#define printfe(FORMAT, ...) fprintf(stderr, FORMAT ,##__VA_ARGS__)
#define printfe(FORMAT, ...) fprintf(stderr, FORMAT ,##__VA_ARGS__)
/// @warning pointer can be null
#define NULLABLE(DECLARATION) DECLARATION