38 lines
919 B
C
38 lines
919 B
C
|
|
#ifndef RAVA_IR_GEN_H
|
||
|
|
#define RAVA_IR_GEN_H
|
||
|
|
|
||
|
|
#include "../parser/parser.h"
|
||
|
|
#include "../semantic/semantic.h"
|
||
|
|
#include "ir.h"
|
||
|
|
|
||
|
|
typedef struct RavaLocalVar_t {
|
||
|
|
char *name;
|
||
|
|
size_t index;
|
||
|
|
struct RavaLocalVar_t *next;
|
||
|
|
} RavaLocalVar_t;
|
||
|
|
|
||
|
|
typedef struct RavaLoopContext_t {
|
||
|
|
int break_label;
|
||
|
|
int continue_label;
|
||
|
|
struct RavaLoopContext_t *parent;
|
||
|
|
} RavaLoopContext_t;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
RavaProgram_t *program;
|
||
|
|
RavaClass_t *current_class;
|
||
|
|
RavaMethod_t *current_method;
|
||
|
|
RavaSemanticAnalyzer_t *analyzer;
|
||
|
|
int next_local;
|
||
|
|
RavaLocalVar_t *locals;
|
||
|
|
RavaLoopContext_t *loop_context;
|
||
|
|
char *error_message;
|
||
|
|
bool had_error;
|
||
|
|
} RavaIRGenerator_t;
|
||
|
|
|
||
|
|
RavaIRGenerator_t* rava_ir_generator_create(RavaSemanticAnalyzer_t *analyzer);
|
||
|
|
void rava_ir_generator_destroy(RavaIRGenerator_t *generator);
|
||
|
|
|
||
|
|
RavaProgram_t* rava_ir_generate(RavaIRGenerator_t *generator, RavaASTNode_t *root);
|
||
|
|
|
||
|
|
#endif
|