feat: add initial plot.py module with beast visualization logic

This commit introduces the core plotting module for the beast project, including
the initial implementation of data visualization functions and chart generation
utilities. The module provides the foundational structure for rendering beast-related
metrics and graphical outputs.
This commit is contained in:
2025-12-02 05:54:32 +00:00
commit f9c7a0fa78
58 changed files with 9092 additions and 0 deletions
+197
View File
@@ -0,0 +1,197 @@
#ifndef RAVA_IR_H
#define RAVA_IR_H
#include "../types/types.h"
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
typedef enum {
RAVA_OP_NOP,
RAVA_OP_LOAD_CONST,
RAVA_OP_LOAD_LONG,
RAVA_OP_LOAD_DOUBLE,
RAVA_OP_LOAD_STRING,
RAVA_OP_LOAD_LOCAL,
RAVA_OP_LOAD_FIELD,
RAVA_OP_LOAD_STATIC,
RAVA_OP_LOAD_ARRAY,
RAVA_OP_STORE_LOCAL,
RAVA_OP_STORE_FIELD,
RAVA_OP_STORE_STATIC,
RAVA_OP_STORE_ARRAY,
RAVA_OP_ADD,
RAVA_OP_SUB,
RAVA_OP_MUL,
RAVA_OP_DIV,
RAVA_OP_MOD,
RAVA_OP_NEG,
RAVA_OP_AND,
RAVA_OP_OR,
RAVA_OP_XOR,
RAVA_OP_NOT,
RAVA_OP_SHL,
RAVA_OP_SHR,
RAVA_OP_USHR,
RAVA_OP_EQ,
RAVA_OP_NE,
RAVA_OP_LT,
RAVA_OP_LE,
RAVA_OP_GT,
RAVA_OP_GE,
RAVA_OP_JUMP,
RAVA_OP_JUMP_IF_TRUE,
RAVA_OP_JUMP_IF_FALSE,
RAVA_OP_LABEL,
RAVA_OP_CALL,
RAVA_OP_CALL_STATIC,
RAVA_OP_CALL_VIRTUAL,
RAVA_OP_CALL_NATIVE,
RAVA_OP_RETURN,
RAVA_OP_RETURN_VOID,
RAVA_OP_NEW,
RAVA_OP_NEW_ARRAY,
RAVA_OP_ARRAY_LENGTH,
RAVA_OP_GET_FIELD,
RAVA_OP_PUT_FIELD,
RAVA_OP_CAST,
RAVA_OP_INSTANCEOF,
RAVA_OP_THROW,
RAVA_OP_POP,
RAVA_OP_DUP,
RAVA_OP_PRINT,
RAVA_OP_PRINTLN,
RAVA_OP_STRING_LENGTH,
RAVA_OP_STRING_CHARAT,
RAVA_OP_STRING_SUBSTRING,
RAVA_OP_STRING_EQUALS,
RAVA_OP_STRING_COMPARETO,
RAVA_OP_LOAD_THIS,
RAVA_OP_FILE_READ,
RAVA_OP_FILE_WRITE,
RAVA_OP_FILE_EXISTS,
RAVA_OP_FILE_DELETE,
RAVA_OP_CURRENT_TIME_MILLIS,
RAVA_OP_NANO_TIME,
RAVA_OP_INC_LOCAL,
RAVA_OP_DEC_LOCAL,
RAVA_OP_LOAD_LOCAL_CONST_ADD,
RAVA_OP_LOAD_LOCAL_CONST_LT_JUMPFALSE,
RAVA_OP_LOAD_LOCAL_CONST_LE_JUMPFALSE,
RAVA_OP_LOAD_TWO_LOCALS,
RAVA_OP_ADD_LOCAL_TO_LOCAL,
RAVA_OP_LOAD_LOCAL_LT_LOCAL_JUMPFALSE
} RavaOpCode_e;
typedef union {
int64_t int_value;
double float_value;
char *string_value;
int label_id;
struct {
int index;
RavaType_t *type;
} var;
struct {
char *class_name;
char *method_name;
int arg_count;
} call;
struct {
char *class_name;
char *field_name;
} field;
struct {
int local_index;
int64_t const_value;
int label_id;
} super;
struct {
int index1;
int index2;
} two_locals;
struct {
int dest_index;
int src_index;
} add_locals;
struct {
int local1;
int local2;
int label_id;
} cmp_locals;
} RavaOperand_u;
typedef struct {
RavaOpCode_e opcode;
RavaOperand_u operand;
int line;
} RavaInstruction_t;
typedef struct {
RavaInstruction_t *instructions;
size_t count;
size_t capacity;
int next_label_id;
} RavaInstructionList_t;
struct LabelTable_s;
typedef struct {
char *name;
RavaType_t *return_type;
RavaType_t **param_types;
size_t param_count;
int local_count;
RavaInstructionList_t *instructions;
struct LabelTable_s *label_table;
} RavaMethod_t;
typedef struct {
char *name;
char *superclass;
RavaMethod_t **methods;
size_t method_count;
size_t method_capacity;
} RavaClass_t;
typedef struct {
RavaClass_t **classes;
size_t class_count;
size_t class_capacity;
} RavaProgram_t;
RavaInstructionList_t* rava_instruction_list_create();
void rava_instruction_list_destroy(RavaInstructionList_t *list);
void rava_instruction_list_add(RavaInstructionList_t *list, RavaInstruction_t instr);
int rava_instruction_list_new_label(RavaInstructionList_t *list);
RavaMethod_t* rava_method_create(const char *name, RavaType_t *return_type);
void rava_method_destroy(RavaMethod_t *method);
RavaClass_t* rava_class_create(const char *name);
void rava_class_destroy(RavaClass_t *class);
void rava_class_add_method(RavaClass_t *class, RavaMethod_t *method);
RavaProgram_t* rava_program_create();
void rava_program_destroy(RavaProgram_t *program);
void rava_program_add_class(RavaProgram_t *program, RavaClass_t *class);
void rava_ir_print(RavaProgram_t *program);
#endif