Skip to content
← Back

src/semantic/symbols/innate.ghul

1
namespace Semantic.Symbols is
2
use IO.Std
3
4
5
use IoC
6
use Logging
7
use Source
8
9
use IR.Values.Value
10
11
use Types.Type
12
13
class InnateFunction(
14
location: LOCATION,
15
owner: Scope,
16
name: string,
17
enclosing_scope: Scope,
18
innate_name: string
19
): Function abstract is
20
describe(context: DESCRIBE_CONTEXT) -> SignaturePart =>
21
_describe_function(context, true)
22
23
describe_kind(context: DESCRIBE_CONTEXT) -> string? =>
24
"innate function {innate_name}"
25
26
is_innate: bool => true
27
28
super(location, location, owner, name, enclosing_scope)
29
30
load(location: LOCATION, from: Value?, loader: SYMBOL_LOADER) -> Value is
31
assert !from? else "instance load of function"
32
33
// FIXME: this should probably error
34
return loader.load_global_function(self)
35
si
36
si
37
38
class INNATE_FUNCTION(
39
location: LOCATION,
40
owner: Scope,
41
name: string,
42
enclosing_scope: Scope,
43
innate_name: string
44
): InnateFunction is
45
super(location, owner, name, enclosing_scope, innate_name)
46
47
// A type-qualified call names the type as its receiver; a static
48
// innate has none to use, so `from` is left alone as it is for
49
// any other static method.
50
call(location: Source.LOCATION, from: Value?, arguments: Collections.List[Value], type: Type?, caller: FUNCTION_CALLER) -> Value =>
51
caller.call_innate_function(self, arguments, self.arguments, type)
52
si
53
54
class INNATE_METHOD: InnateFunction is
55
init(location: LOCATION, owner: Scope, name: string, enclosing_scope: Scope, innate_name: string) is
56
super.init(location, owner, name, enclosing_scope, innate_name)
57
si
58
59
call(location: Source.LOCATION, from: Value?, arguments: Collections.List[Value], type: Type?, caller: FUNCTION_CALLER) -> Value => caller.call_innate_function(self, from, arguments, self.arguments, type)
60
si
61
si