Skip to content
← Back

src/ir/values/sequence.ghul

1
namespace IR.Values is
2
use IO.Std
3
4
use System.NotImplementedException
5
use System.Text.StringBuilder
6
7
use TypeTyped = Semantic.Types.Typed
8
use Semantic.Types.Type
9
use SymbolBase = Semantic.Symbols.Symbol
10
11
class SEQUENCE: Value, TypeTyped is
12
type: Type
13
element_type: Type
14
15
values: Collections.List[Value]
16
17
init(
18
type: Type,
19
element_type: Type,
20
values: Collections.List[Value]
21
) is
22
super.init()
23
24
self.type = type
25
self.element_type = element_type
26
self.values = values
27
si
28
29
gen(context: IR.CONTEXT) is
30
let boxer = IoC.CONTAINER.instance.value_boxer
31
32
let body = context.current_srm_body_emitter!
33
let element = context.resolve_type_token(element_type)
34
35
body.ldc_i4(values.count)
36
body.new_array(element)
37
38
for i in 0..values.count do
39
body.op(System.Reflection.Metadata.ILOpCode.DUP)
40
body.ldc_i4(i)
41
42
gen(boxer.box_if_needed(values[i], element_type), context)
43
44
body.store_element(element)
45
od
46
si
47
48
to_string() -> string =>
49
"sequence:[{type}]({values})"
50
si
51
si