Cthulhu
0.2.10
Cthulhu compiler collection
main.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-only
2
3
#include "
cthulhu/broker/broker.h
"
4
5
#include "
cthulhu/tree/tree.h
"
6
7
#include "
base/log.h
"
8
9
#include "
driver/driver.h
"
10
11
static
void
ex_create(
language_runtime_t
*runtime,
tree_t
*root)
12
{
13
ctu_log
(
"ex_create(runtime = 0x%p, root = 0x%p)"
, (
void
*)runtime, (
void
*)root);
14
}
15
16
static
void
ex_destroy(
language_runtime_t
*handle)
17
{
18
ctu_log
(
"ex_destroy(handle = 0x%p)"
, (
void
*)handle);
19
}
20
21
static
void
ex_forward_symbols(
language_runtime_t
*context,
compile_unit_t
*unit)
22
{
23
ctu_log
(
"ex_forward(context = 0x%p, unit = 0x%p)"
, (
void
*)context, (
void
*)unit);
24
}
25
26
static
void
ex_compile_imports(
language_runtime_t
*context,
compile_unit_t
*unit)
27
{
28
ctu_log
(
"ex_compile_imports(context = 0x%p, unit = 0x%p)"
, (
void
*)context, (
void
*)unit);
29
}
30
31
static
void
ex_compile_types(
language_runtime_t
*context,
compile_unit_t
*unit)
32
{
33
ctu_log
(
"ex_compile_types(context = 0x%p, unit = 0x%p)"
, (
void
*)context, (
void
*)unit);
34
}
35
36
static
void
ex_compile_symbols(
language_runtime_t
*context,
compile_unit_t
*unit)
37
{
38
ctu_log
(
"ex_compile_symbols(context = 0x%p, unit = 0x%p)"
, (
void
*)context, (
void
*)unit);
39
}
40
41
static
const
char
*
const
kLangNames[] =
CT_LANG_EXTS
(
"e"
,
"example"
);
42
43
static
const
size_t
kDeclSizes[
eSemaCount
] = {
44
[
eSemaValues
] = 1,
45
[
eSemaTypes
] = 1,
46
[
eSemaProcs
] = 1,
47
[
eSemaModules
] = 1,
48
};
49
50
CT_DRIVER_API
const
language_t
kExampleModule
= {
51
.
info
= {
52
.
id
=
"lang/example"
,
53
.name =
"Example"
,
54
.version = {
55
.license =
"GPLv3"
,
56
.desc =
"Example language driver"
,
57
.author =
"Elliot Haisley"
,
58
.version =
CT_NEW_VERSION
(1, 0, 2)
59
},
60
},
61
62
.builtin = {
63
.name =
CT_TEXT_VIEW
(
"example\0lang"
),
64
.decls = kDeclSizes,
65
.length =
eSemaCount
,
66
},
67
68
.exts = kLangNames,
69
70
.fn_create = ex_create,
71
.fn_destroy = ex_destroy,
72
73
.fn_passes = {
74
[ePassForwardDecls] = ex_forward_symbols,
75
[ePassImportModules] = ex_compile_imports,
76
[ePassCompileTypes] = ex_compile_types,
77
[ePassCompileDecls] = ex_compile_symbols
78
}
79
};
80
81
CT_LANG_EXPORT
(
kExampleModule
)
broker.h
CT_TEXT_VIEW
#define CT_TEXT_VIEW(str)
create a text view from a string literal
Definition:
text.h:39
CT_LANG_EXTS
#define CT_LANG_EXTS(...)
Definition:
broker.h:49
CT_NEW_VERSION
#define CT_NEW_VERSION(major, minor, patch)
creates a new ctu_version_t from major, minor and patch
Definition:
version_def.h:20
CT_LANG_EXPORT
#define CT_LANG_EXPORT(mod)
declares the entry point for a language driver module
ctu_log
CT_BASE_API void ctu_log(STA_FORMAT_STRING const char *fmt,...)
log a message
eSemaCount
@ eSemaCount
Definition:
tree.h:47
eSemaValues
@ eSemaValues
Definition:
tree.h:36
eSemaProcs
@ eSemaProcs
Definition:
tree.h:42
eSemaModules
@ eSemaModules
Definition:
tree.h:45
eSemaTypes
@ eSemaTypes
Definition:
tree.h:39
kExampleModule
CT_DRIVER_API const language_t kExampleModule
Definition:
main.c:50
log.h
compile_unit_t
Definition:
broker.h:279
language_runtime_t
Definition:
broker.h:261
language_t
a language driver support capabilities
Definition:
broker.h:143
language_t::info
module_info_t info
common information about the language
Definition:
broker.h:145
module_info_t::id
const char * id
unique id for the module
Definition:
broker.h:101
tree_t
Definition:
tree.h:67
driver.h
tree.h
language
example
src
main.c
Generated by
1.9.1