Add basic comp ops implementations

This commit is contained in:
Abdelrahman Said 2024-01-15 22:38:30 +00:00
parent 6d7de03ae8
commit 9d438d7347
2 changed files with 38 additions and 0 deletions

28
include/ops.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef COMP_OPS_H
#define COMP_OPS_H
#include "aliases/aliases.h"
#include "nodes.h"
enum comp_ops {
COMP_OP_ADD,
COMP_OP_SUB,
COMP_OP_MUL,
COMP_OP_DIV,
COUNT_COMP_OPS,
};
i32 comp_add(i32 a, i32 b);
i32 comp_sub(i32 a, i32 b);
i32 comp_mul(i32 a, i32 b);
i32 comp_div(i32 a, i32 b);
INTERNAL node_func_t ops[COUNT_COMP_OPS] = {
[COMP_OP_ADD] = comp_add,
[COMP_OP_SUB] = comp_sub,
[COMP_OP_MUL] = comp_mul,
[COMP_OP_DIV] = comp_div,
};
#endif // !COMP_OPS_H

10
src/ops.c Normal file
View File

@ -0,0 +1,10 @@
#include "ops.h"
#include "aliases/aliases.h"
i32 comp_add(i32 a, i32 b) { return a + b; }
i32 comp_sub(i32 a, i32 b) { return a - b; }
i32 comp_mul(i32 a, i32 b) { return a * b; }
i32 comp_div(i32 a, i32 b) { return a / b; }