#ifndef CODEGEN_H
#define CODEGEN_H
#include "ast.h"

typedef struct {
    unsigned char *data;
    int size;
    int capacity;
} CodeBuffer;

CodeBuffer* codebuf_new(void);
void codebuf_free(CodeBuffer *buf);
void codebuf_write_byte(CodeBuffer *buf, unsigned char byte);
void codebuf_write_uint32(CodeBuffer *buf, unsigned int val);
void codebuf_write_uint64(CodeBuffer *buf, unsigned long long val);

typedef struct {
    int var_count;
    char *var_names[256];
    int var_types[256];
    long long var_init[256];
    char *var_str_init[256];
} VarInfo;

#define VARTYPE_INT 0
#define VARTYPE_STR 1

int codegen_arm64(Stmt *ast, CodeBuffer *text, CodeBuffer *rodata,
                   CodeBuffer *data, VarInfo *vinfo, int opt_level);

#endif
