aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-11-19 18:41:55 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-11-19 18:41:55 +0200
commit8f754f8b13e55e4bb92d72f105c5aaaba1754b7d (patch)
treeb70b813c091691d6645f8cb82295f41f24f3be93 /include
parent5304dbcf4df1fc211b5099f4d6eb7f23dfa8c454 (diff)
downloadek-8f754f8b13e55e4bb92d72f105c5aaaba1754b7d.tar.gz
ek-8f754f8b13e55e4bb92d72f105c5aaaba1754b7d.zip
start working on instruction lowering
Diffstat (limited to 'include')
-rw-r--r--include/ek/ast.h13
-rw-r--r--include/ek/compiler.h2
-rw-r--r--include/ek/ops.h14
-rw-r--r--include/ek/scope.h3
4 files changed, 28 insertions, 4 deletions
diff --git a/include/ek/ast.h b/include/ek/ast.h
index 66acc08..d36860f 100644
--- a/include/ek/ast.h
+++ b/include/ek/ast.h
@@ -4,6 +4,8 @@
#ifndef AST_H
#define AST_H
+#include <stddef.h>
+
/**
* @file ast.h
*
@@ -11,15 +13,20 @@
*/
#define AST_ID(x) x->_id
+#define AST_AS(x) x->_as
+#define AST_DOT(x) x->_dot
+#define AST_UNOP(x) x->_unop
#define AST_IMPORT(x) x->_import
#define AST_ALIAS(x) x->_alias
#define AST_TRAIT(x) x->_trait
+#define AST_CAST(x) x->_cast
#define AST_PROC(x) x->_proc
#define AST_VAR(x) x->_var
#define AST_STRUCT(x) x->_struct
#define AST_ENUM(x) x->_enum
#define AST_CALL(x) x->_call
#define AST_CONST(x) x->_const
+#define AST_ASSIGN(x) x->_assign
#define AST_BLOCK(x) x->_block
#define AST_ARR_ACCESS(x) x->_arr_access
#define AST_MACRO_CONSTRUCT(x) x->_macro_construct
@@ -694,8 +701,6 @@ struct ast_const {
long long integer;
/** String. */
const char *str;
- /** Float. */
- double dbl;
};
};
@@ -742,6 +747,8 @@ struct ast_node {
/** Ek type. */
struct ast_node *type;
+ size_t reg;
+
/** Data relevant to kind. */
union {
struct ast_arr_access _arr_access;
@@ -1052,7 +1059,7 @@ struct ast_node *gen_lambda(struct ast_node *captures,
* @return Corresponding AST node.
*/
struct ast_node *gen_proc(struct ast_node *id, struct ast_node *type,
- struct ast_node *body);
+ struct ast_node *body, struct src_loc loc);
/**
* Generate dot operation.
diff --git a/include/ek/compiler.h b/include/ek/compiler.h
index 32fc218..95bd836 100644
--- a/include/ek/compiler.h
+++ b/include/ek/compiler.h
@@ -20,7 +20,7 @@
* @param file Root file to compile.
* @return \c 0 if compilation was succesful, otherwise some non-zero value.
*/
-int compile(const char *file);
+int compile(const char *input, const char *output);
/**
* Process a file, i.e. lex, parse and generate raw AST.
diff --git a/include/ek/ops.h b/include/ek/ops.h
new file mode 100644
index 0000000..330de0c
--- /dev/null
+++ b/include/ek/ops.h
@@ -0,0 +1,14 @@
+#ifndef EK_OPS_H
+#define EK_OPS_H
+
+#include <ek/ast.h>
+
+struct ops;
+
+struct ops *create_ops();
+void destroy_ops(struct ops *ops);
+int lower_ops(struct scope *root, struct ops *ops);
+int analyze_lifetime(struct ops *ops);
+int print_asm(struct ops *ops, const char *output);
+
+#endif /* EK_OPS_H */
diff --git a/include/ek/scope.h b/include/ek/scope.h
index 156788a..10b0aad 100644
--- a/include/ek/scope.h
+++ b/include/ek/scope.h
@@ -614,6 +614,9 @@ struct ast_node *scope_resolve_call(struct scope *scope, struct ast_node *call);
struct ast_node *file_scope_resolve_call(struct scope *scope,
struct ast_node *call);
+struct ast_node *file_scope_resolve_macro(struct scope *scope,
+ struct ast_node *macro);
+
/**
* Check if \p arg_type implements \p param_type.
*