Skip to content
← Back

src/syntax/process/il_pragmas.ghul

1
namespace Syntax.Process is
2
// The pragmas the compiler acts on itself, all named `IL.`: they name
3
// a fact about the emitted assembly rather than a .NET attribute, so
4
// the compiler reads them where the declaration is walked and passes
5
// the answer to emission. What each one does is said where it is read.
6
class IL_PRAGMAS is
7
// The family every one of them is named in.
8
PREFIX: string static => "IL."
9
10
// The .NET name a member is emitted under.
11
NAME: string static => "IL.name"
12
NAME_READ: string static => "IL.name.read"
13
NAME_ASSIGN: string static => "IL.name.assign"
14
15
// Names the file a region of emitted IL is written to, marked on
16
// the statements the region runs between.
17
OUTPUT: string static => "IL.output"
18
19
// Names the function a program starts at.
20
ENTRYPOINT: string static => "IL.entrypoint"
21
22
// Whether a pragma name is in this family at all, known or not.
23
is_il_pragma(name: string) -> bool static => name.starts_with(PREFIX)
24
25
// Whether the compiler acts on it.
26
is_known(name: string) -> bool static =>
27
name =~ NAME \/
28
name =~ NAME_READ \/
29
name =~ NAME_ASSIGN \/
30
name =~ OUTPUT \/
31
name =~ ENTRYPOINT
32
33
// Whether it renames a member, which the three `IL.name` forms do
34
// between them and the other two do not.
35
is_name_pragma(name: string) -> bool static =>
36
name =~ NAME \/
37
name =~ NAME_READ \/
38
name =~ NAME_ASSIGN
39
si
40
si