99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
DefineConstant( e, "TermTypeAnyTerm"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::AnyTerm ) ) ) );
DefineConstant( e, "TermTypeVecOfLength"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::VecOfLength ) ) ) );
DefineConstant( e, "TermTypeVec"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Vec ) ) ) );
DefineConstant( e, "TermTypeBigInt"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::BigInt ) ) ) );
DefineConstant( e, "TermTypeFixedInt"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::FixedInt ) ) ) );
DefineConstant( e, "TermTypeInternal"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Internal ) ) ) );
// Functions
RegisterBuiltinFunc< BigInt ( TypeWrapper< Term > ) >( e, "GetTermType"_sid,
[]( const auto& t )
{
return BigInt::FromU32( min< uint8_t >( t.get().index(), static_cast< uint8_t >( TermType::Internal ) ) );
} );
|
>
>
>
>
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
DefineConstant( e, "TermTypeAnyTerm"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::AnyTerm ) ) ) );
DefineConstant( e, "TermTypeVecOfLength"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::VecOfLength ) ) ) );
DefineConstant( e, "TermTypeVec"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Vec ) ) ) );
DefineConstant( e, "TermTypeBigInt"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::BigInt ) ) ) );
DefineConstant( e, "TermTypeFixedInt"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::FixedInt ) ) ) );
DefineConstant( e, "TermTypeInternal"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Internal ) ) ) );
DefineConstant( e, "HoleBhvStandard"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Hole::Behavior::Standard ) ) ) );
DefineConstant( e, "HoleBhvPack"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Hole::Behavior::Pack ) ) ) );
DefineConstant( e, "HoleBhvAny"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Hole::Behavior::Any ) ) ) );
// Functions
RegisterBuiltinFunc< BigInt ( TypeWrapper< Term > ) >( e, "GetTermType"_sid,
[]( const auto& t )
{
return BigInt::FromU32( min< uint8_t >( t.get().index(), static_cast< uint8_t >( TermType::Internal ) ) );
} );
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
{
return s;
} );
////////////////////////////
// Hole
////////////////////////////
RegisterBuiltinFunc< TypeWrapper< Hole > ( TypeWrapper< StringId >, TypeWrapper< StringId >, uint32_t ) >( e, "MkHole"_sid,
[]( const auto& name, const auto& kind, uint32_t repetitionDepth ) -> TypeWrapper< Hole >
{
return Hole( name, kind, repetitionDepth );
} );
RegisterBuiltinFunc< TypeWrapper< Hole > ( TypeWrapper< StringId >, TypeWrapper< StringId > ) >( e, "MkHole"_sid,
[]( const auto& name, const auto& kind ) -> TypeWrapper< Hole >
{
return Hole( name, kind );
} );
RegisterBuiltinFunc< TypeWrapper< StringId > ( TypeWrapper< Hole > ) >( e, "GetHoleName"_sid,
[]( const auto& h ) -> TypeWrapper< StringId >
{
return h.get().name();
} );
RegisterBuiltinFunc< TypeWrapper< Term > ( TypeWrapper< Hole > ) >( e, "GetHoleKind"_sid,
[]( const auto& h ) -> TypeWrapper< Term >
{
return h.get().kind();
} );
RegisterBuiltinFunc< TypeWrapper< Term > ( TypeWrapper< Hole > ) >( e, "GetHoleRepetitionDepth"_sid,
[]( const auto& h ) -> uint32_t
{
return h.get().repetitionDepth();
} );
////////////////////////////
// AnyTerm
////////////////////////////
RegisterBuiltinFunc< TypeWrapper< StringId > ( TypeWrapper< AnyTerm > ) >( e, "GetAnyTermVarName"_sid,
[]( const auto& at ) -> TypeWrapper< StringId >
|
|
>
>
>
>
>
|
>
|
>
>
>
>
|
>
|
|
|
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
{
return s;
} );
////////////////////////////
// Hole
////////////////////////////
RegisterBuiltinFunc< Intrinsic< TypeWrapper< Hole > ( TypeWrapper< StringId >, TypeWrapper< StringId >, uint8_t ) > >( e, "MkHole"_sid,
[]( const auto& c, const Value& nameVal, const Value& kindVal, const Value& bhvVal ) -> Value
{
auto name = *FromValue< TypeWrapper< StringId > >( nameVal );
auto kind = *FromValue< TypeWrapper< StringId > >( kindVal );
auto bhv = *FromValue< uint8_t >( bhvVal );
if( bhv > static_cast< uint8_t >( Hole::Behavior::Any ) )
{
DiagnosticsManager::GetInstance().emitErrorMessage( bhvVal.locationId(),
"invalid hole behavior." );
return PoisonValue();
}
return ToValue( TypeWrapper< Hole >( Hole( name, kind, static_cast< Hole::Behavior >( bhv ) ) ) );
} );
RegisterBuiltinFunc< TypeWrapper< Hole > ( TypeWrapper< StringId >, TypeWrapper< StringId > ) >( e, "MkHole"_sid,
[]( const auto& name, const auto& kind ) -> TypeWrapper< Hole >
{
return Hole( name, kind );
} );
RegisterBuiltinFunc< TypeWrapper< StringId > ( TypeWrapper< Hole > ) >( e, "GetHoleName"_sid,
[]( const auto& h ) -> TypeWrapper< StringId >
{
return h.get().name();
} );
RegisterBuiltinFunc< TypeWrapper< Term > ( TypeWrapper< Hole > ) >( e, "GetHoleKind"_sid,
[]( const auto& h ) -> TypeWrapper< Term >
{
return h.get().kind();
} );
RegisterBuiltinFunc< uint8_t ( TypeWrapper< Hole > ) >( e, "GetHoleBehavior"_sid,
[]( const auto& h )
{
return static_cast< uint8_t>( h.get().behavior() );
} );
////////////////////////////
// AnyTerm
////////////////////////////
RegisterBuiltinFunc< TypeWrapper< StringId > ( TypeWrapper< AnyTerm > ) >( e, "GetAnyTermVarName"_sid,
[]( const auto& at ) -> TypeWrapper< StringId >
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
auto s = *FromValue< bool >( sVal );
if( !s && bi.isNegative() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( biVal.locationId(),
"this is negative and can't be converted to an unsigned int." );
return PoisonValue();
}
auto ai = bi.getAPSInt();
if( !s )
ai.setIsSigned( false );
return ToValue( TypeWrapper< APSInt >( s ) );
|
<
|
370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
auto s = *FromValue< bool >( sVal );
if( !s && bi.isNegative() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( biVal.locationId(),
"this is negative and can't be converted to an unsigned int." );
return PoisonValue();
}
auto ai = bi.getAPSInt();
if( !s )
ai.setIsSigned( false );
return ToValue( TypeWrapper< APSInt >( s ) );
|