bitwise
This commit is contained in:
parent
2d0c39cd85
commit
0021ce04ac
12 changed files with 134 additions and 15 deletions
BIN
tests/arrays.o
BIN
tests/arrays.o
Binary file not shown.
54
tests/bitwise.c
Normal file
54
tests/bitwise.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "libsuicmez/libsuicmez.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
void* gc_alloc(const TypeInfo* type, size_t size);
|
||||
void gc_init(void);
|
||||
void gc_shutdown(void);
|
||||
|
||||
// Helper for allocating arrays
|
||||
static void* suic_alloc_array(const TypeInfo* type, size_t elem_size, size_t len, void* init_data) {
|
||||
void* ptr = gc_alloc(type, elem_size * len);
|
||||
if (init_data) memcpy(ptr, init_data, elem_size * len);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Helper for allocating structs
|
||||
static void* suic_alloc_struct(const TypeInfo* type, size_t size, void* init_data) {
|
||||
void* ptr = gc_alloc(type, size);
|
||||
if (init_data) memcpy(ptr, init_data, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int test_bitwise(void);
|
||||
int suic_main(void);
|
||||
|
||||
|
||||
int test_bitwise(void) {
|
||||
int a = 5;
|
||||
int b = 3;
|
||||
int and_result = (a & b);
|
||||
int or_result = (a | b);
|
||||
return (and_result + or_result);
|
||||
}
|
||||
|
||||
int suic_main(void) {
|
||||
return test_bitwise();
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Initialize GC
|
||||
gc_init();
|
||||
// init globals
|
||||
// init event loop
|
||||
int result = suic_main();
|
||||
// Shutdown GC
|
||||
gc_shutdown();
|
||||
return result;
|
||||
}
|
||||
|
||||
14
tests/bitwise.sui
Normal file
14
tests/bitwise.sui
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Test bitwise operations
|
||||
fn test_bitwise() -> int do
|
||||
let a = 5; # 0b0101
|
||||
let b = 3; # 0b0011
|
||||
|
||||
let and_result = a bitand b; # Should be 1 (0b0001)
|
||||
let or_result = a bitor b; # Should be 7 (0b0111)
|
||||
|
||||
and_result + or_result # Should be 8
|
||||
end
|
||||
|
||||
fn main() -> int do
|
||||
test_bitwise()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue