Skip to content
← Back

src/semantic/lookups/innate_symbol_lookup.ghul

1
namespace Semantic.Lookups is
2
use IO.Std;
3
use TYPE = System.Type;
4
use Symbol = Symbols.Symbol;
5
use Type = Types.Type;
6
7
trait InnateSymbolLookup is
8
get_enum_type() -> Type;
9
get_tuple_type(types: Collections.List[Type], names: Collections.List[string?]?) -> Type;
10
get_function_type(types: Collections.List[Type]) -> Type;
11
12
// As above; `is_pure` true builds the `pure`-marked shape
13
// (see Types.PURE_FUNCTION). The zero-argument void form has
14
// no pure shape yet and falls back to the plain one.
15
get_function_type(types: Collections.List[Type], is_pure: bool) -> Type;
16
17
get_array_type(type: Type) -> Type;
18
19
// The value-type `T?` — NULLABLE[type] (System.Nullable[type]).
20
get_optional_type(type: Type) -> Type;
21
22
// The unconstrained-T `T?` — `Ghul.MAYBE[type]`, the
23
// runtime struct that carries either an absent or a present
24
// value of `type`. Null when the runtime is unavailable
25
// (compiling `ghul-runtime` itself), mirroring
26
// `get_unspecialized_pipe_type`: the caller
27
// reports a clearer error than the generic
28
// `Ghul.MAYBE not found` would.
29
get_maybe_type(type: Type) -> Type?;
30
31
get_pointer_type(type: Type) -> Type;
32
33
get_reference_type(type: Type) -> Type;
34
35
get_bool_type() -> Type;
36
37
get_char_type() -> Type;
38
39
get_byte_type() -> Type;
40
41
get_ubyte_type() -> Type;
42
43
get_short_type() -> Type;
44
45
get_ushort_type() -> Type;
46
47
get_int_type() -> Type;
48
49
get_uint_type() -> Type;
50
51
get_long_type() -> Type;
52
53
get_ulong_type() -> Type;
54
55
get_word_type() -> Type;
56
57
get_uword_type() -> Type;
58
59
get_single_type() -> Type;
60
61
get_double_type() -> Type;
62
63
get_decimal_type() -> Type;
64
65
get_void_type() -> Type;
66
67
get_object_type() -> Type;
68
69
get_value_type() -> Type;
70
71
get_string_type() -> Type;
72
73
get_exception_type() -> Type;
74
75
get_type_type() -> Type;
76
77
get_unspecialized_iterable_type() -> Type;
78
79
get_unspecialized_iterator_type() -> Type;
80
81
// `Ghul.Pipes.Pipe[T]` — the required return type of a
82
// generator function. Optional because the runtime assembly
83
// is not loadable while the compiler is building it. Null
84
// means "Pipe is unavailable in this compilation" and callers
85
// fall back to the bare Iterable[T] / Iterator[T] element
86
// extraction.
87
get_unspecialized_pipe_type() -> Type?;
88
89
// Async-related types are optional for the same reason. Each
90
// call site null-checks before using the result; the function path
91
// returns null up the chain to mean "absent, classify this
92
// function as non-async / skip the state-machine emission".
93
get_unspecialized_task_type() -> Type?;
94
95
get_interpolated_string_handler_type() -> Type;
96
97
get_idisposable_type() -> Type;
98
99
// Ghul.BOX[T] — the single-field mutable cell used to
100
// share mutation between a closure body and its enclosing
101
// scope. The compiler's `mark-boxed-locals` pass marks
102
// captured-and-reassigned locals; emission queries this
103
// for the slot type and frame field type.
104
get_box_type(type: Type) -> Type;
105
106
// System.Threading.Tasks.Task[T] specialised over `type`.
107
// compile-lambdas uses it to build the inferred return-type
108
// placeholder for `Expressions.FUNCTION`s whose body
109
// contains a `let await` (so the synthesised continuation
110
// lambdas inherit a `Tasks.TASK[?]` context for the
111
// existing `T → TASK[T]` auto-wrap to fire).
112
get_task_type(type: Type) -> Type?;
113
114
// The non-generic `System.Threading.Tasks.Task` — used as
115
// the inferred return type of an async lambda that has
116
// no value-returning `return X;` statements (every
117
// `return;` is bare and end-of-body fallthrough produces
118
// a completed Task). Distinct from
119
// `get_unspecialized_task_type` which returns the open
120
// generic `Task`1` used to recognise constructed
121
// `Task[T]` shapes.
122
get_void_task_type() -> Type?;
123
124
// `System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>` —
125
// the builder field type on a value-async state machine.
126
// The state machine's outer method creates the builder via
127
// `AsyncTaskMethodBuilder<T>.Create()`, calls `Start(ref this)`
128
// to begin MoveNext, then returns `.Task`. Each value-async
129
// function reaches here with its result type so the builder
130
// is instantiated correctly.
131
get_async_task_method_builder_type(type: Type) -> Type?;
132
133
// The non-generic `System.Runtime.CompilerServices.AsyncTaskMethodBuilder`
134
// for void-async (return type is the non-generic `Tasks.TASK`).
135
get_async_task_method_builder_void_type() -> Type?;
136
137
// `System.Runtime.CompilerServices.IAsyncStateMachine` —
138
// the interface the async frame implements (MoveNext +
139
// SetStateMachine).
140
get_async_state_machine_interface_type() -> Type?;
141
142
// `System.Runtime.CompilerServices.TaskAwaiter<T>` —
143
// the awaiter struct returned by `Task<T>.GetAwaiter()`.
144
// Used to type the per-await `_awaiter_N` frame field
145
// when generating IL for `let await x = e;`.
146
get_task_awaiter_type(type: Type) -> Type?;
147
148
// Non-generic `System.Runtime.CompilerServices.TaskAwaiter`
149
// returned by `Task.GetAwaiter()` for void-async awaits.
150
get_task_awaiter_void_type() -> Type?;
151
152
// Open-generic (unspecialized) forms of the async types.
153
// These render IL as `valuetype <class>`<arity><!0,!1,...>`
154
// and are needed by the methodref signature emission for
155
// calls on constructed-generic value-types — the CLR
156
// method-resolution looks up the method on the unspecialised
157
// class and uses the constructed-type owner spec at the call
158
// site to substitute. Using the constructed form everywhere
159
// (`AsyncTaskMethodBuilder<int>` in both the owner AND the
160
// return-type slot) makes the runtime fail with
161
// `MissingMethodException`.
162
get_unspecialized_async_task_method_builder_type() -> Type?;
163
164
get_unspecialized_task_awaiter_type() -> Type?;
165
si
166
si