15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
const Term& LocalVar::PatternAnyOfTypeT::GetPattern()
{
static auto pattern = GetValueType< LocalVar >( HOLE( "T"_sid ) );
return pattern;
}
Value DeclareLocalVar( const Context& c, const Term& type, StringId name, const optional< Value >& initializer )
Value DeclareLocalVar( const Context& c, const Term& type, StringId name, const optional< Value >& initializer, uint32_t locId )
{
const auto& cb = c.codeBuilder();
assert( cb );
const auto& cfg = cb->cfg();
auto index = cfg->getNewTemporaryIndex();
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
-
+
-
+
-
+
|
{
DiagnosticsContext dc( 0, "When invoking Initialize." );
if( initializer )
{
initResult = InvokeOverloadSet( c,
c.env()->extInitialize(),
MakeTuple( ToValue( lv ), *initializer ) );
MakeTuple( ToValue( lv ).setLocationId( locId ), *initializer ) );
}
else
{
initResult = InvokeOverloadSet( c,
c.env()->extInitialize(),
MakeTuple( ToValue( lv ) ) );
MakeTuple( ToValue( lv ).setLocationId( locId ) ) );
}
}
if( !initResult.isPoison() )
{
DiagnosticsContext dc2( initResult.locationId(), "When invoking DropValue." );
InvokeOverloadSet( c, c.env()->extDropValue(),
MakeTuple( move( initResult ) ) );
}
auto locVar = ToValue( lv );
auto identity = AppendToVectorTerm( c.identity(), name );
c.env()->storeValue( identity, ANYTERM( _ ),
ValueToEIR( locVar ) );
cb->pushLiveValue( locVar, lv.index() );
return locVar;
}
Value DeclareLocalVarWithTypeInference( Context& c, const Term& typeTExpr, StringId name, const Value& initVal )
Value DeclareLocalVarWithTypeInference( Context& c, const Term& typeTExpr, StringId name, const Value& initVal, uint32_t locId )
{
const auto& cb = c.codeBuilder();
assert( cb );
const auto& cfg = cb->cfg();
auto bb = cfg->currentBB();
if( !bb )
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
-
+
|
bb->emplace_back( AllocVar( ValueFromEIR( lv.type() )->setLocationId( typeLoc ), index ) );
DiagnosticsContext dc( 0, "When invoking Initialize." );
auto initResult = InvokeOverloadSet( c,
c.env()->extInitialize(),
MakeTuple( ToValue( lv ), initVal ) );
MakeTuple( ToValue( lv ).setLocationId( locId ), initVal ) );
if( !initResult.isPoison() )
{
DiagnosticsContext dc2( initResult.locationId(), "When invoking DropValue." );
InvokeOverloadSet( c, c.env()->extDropValue(),
MakeTuple( move( initResult ) ) );
}
|