issue #98 Start work generating linear IR

parser
Dibyendu Majumdar 4 years ago
parent 6157e9270b
commit 5cc228c663

@ -50,9 +50,13 @@ if (COMPUTED_GOTO AND MSVC)
endif ()
include_directories("${PROJECT_SOURCE_DIR}/include")
if ($ENV{CLION_IDE})
# CLion seems unable to handle include paths set on sources
include_directories("${PROJECT_SOURCE_DIR}/dmr_c/src")
endif()
# define the Lua core source files
set(RAVI_AST_SOURCES src/ravi_ast_parse.c src/ravi_ast_print.c src/ravi_ast_typecheck.c)
set(RAVI_AST_SOURCES src/ravi_ast_parse.c src/ravi_ast_print.c src/ravi_ast_typecheck.c src/ravi_ast_linearize.c)
set(LUA_CORE_SRCS src/lapi.c src/lcode.c src/lctype.c src/ldebug.c src/ldo.c src/ldump.c
src/lfunc.c src/lgc.c src/llex.c src/lmem.c src/lobject.c src/lopcodes.c
src/lparser.c src/lstate.c src/lstring.c src/ltable.c src/ltm.c src/lundump.c

@ -286,4 +286,41 @@ LUAMOD_API int raviopen_ast_library(lua_State *L);
void raviA_print_ast_node(membuff_t *buf, struct ast_node *node, int level); /* output the AST structure recusrively */
void raviA_ast_typecheck(struct ast_container *container); /* Perform type checks and assign types to AST */
/*
Linearizer
*/
struct instruction;
struct basic_block;
struct edge;
struct pseudo;
DECLARE_PTR_LIST(instruction_list, struct instruction);
DECLARE_PTR_LIST(edge_list, struct edge);
DECLARE_PTR_LIST(pseudo_list, struct pseudo);
enum opcode {
OP_NOP
};
struct instruction {
unsigned opcode:8;
};
struct basic_block {
struct edge_list *pred;
struct edge_list *succ;
struct instruction_list *insns;
};
struct linearizer {
struct allocator instruction_allocator;
struct allocator edge_allocator;
struct allocator pseudo_allocator;
struct allocator ptrlist_allocator;
struct ast_container *ast_container;
};
#endif

@ -0,0 +1,12 @@
/*
Copyright (C) 2018-2020 Dibyendu Majumdar
*/
#include <ravi_ast.h>
#include <ptrlist.h>
/* Linearizer - WIP */
void raviA_init_linearizer(struct linearizer *linearizer, struct ast_container *container) {
}

@ -11,7 +11,7 @@ Copyright (C) 2018-2020 Dibyendu Majumdar
*/
#include "ravi_ast.h"
#include <ravi_ast.h>
/* forward declarations */
static struct ast_node *parse_expression(struct parser_state *);

@ -3,7 +3,6 @@ Copyright (C) 2018-2020 Dibyendu Majumdar
*/
#include <ravi_ast.h>
#include "ravi_ast.h"
static const char *type_name(ravitype_t tt) {
switch (tt) {

@ -2,7 +2,6 @@
Copyright (C) 2018-2020 Dibyendu Majumdar
*/
#include <ravi_ast.h>
#include "ravi_ast.h"
/* Type checker - WIP */
static void typecheck_ast_node(struct ast_container *container, struct ast_node *function, struct ast_node *node);

Loading…
Cancel
Save