1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// TODO_SSA reenable
//#include "g0api/g0api.h"
#include "parse/parse.h"
#include "verify/verify.h"
#include "execute/execute.h"
#include "compile/compiler.h"
using namespace goose;
using namespace goose::compile;
namespace goose::g0api
{
void SetupApiCompiler( Env& e )
{
DefineConstant( e, "TargetOSName"_sid, ValueToEIR( ToValue( string( TARGET_OS_NAME ) ) ) );
wptr< Env > pEnv = e.shared_from_this();
RegisterBuiltinFunc< Intrinsic< void ( bool ) > >( e, "#VerificationTraceMode"_sid,
[]( auto&& c, const Value& enable )
{
if( !enable.isConstant() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
"this doesn't evaluate to a constant." );
return;
|
<
|
>
>
>
>
>
>
>
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "g0api/g0api.h"
#include "parse/parse.h"
#include "verify/verify.h"
#include "execute/execute.h"
#include "compile/compiler.h"
using namespace goose;
using namespace goose::compile;
namespace goose::g0api
{
void SetupApiCompiler( Env& e )
{
DefineConstant( e, "TargetOSName"_sid, ValueToEIR( ToValue( string( TARGET_OS_NAME ) ) ) );
wptr< Env > pEnv = e.shared_from_this();
RegisterBuiltinFunc< void ( bool ) >( e, "DiagnosticsForceColors"_sid,
[]( bool enable )
{
DiagnosticsManager::GetInstance().setForceColors( enable );
} );
// TODO_SSA_VERIFICATION reenable
/*RegisterBuiltinFunc< Intrinsic< void ( bool ) > >( e, "#VerificationTraceMode"_sid,
[]( auto&& c, const Value& enable )
{
if( !enable.isConstant() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
"this doesn't evaluate to a constant." );
return;
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
{
DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
"this doesn't evaluate to a constant." );
return;
}
verify::Func::SetDumpSolverOnSuccess( *FromValue< bool >( enable ) );
} );
RegisterBuiltinFunc< Intrinsic< void ( CustomPattern< Value, FuncPattern >, string ) > >( e, "#DumpFunctionCFG"_sid,
[]( auto&& c, const Value& funcVal, const Value& filename )
{
if( !funcVal.isConstant() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( funcVal.locationId(),
|
|
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
{
DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
"this doesn't evaluate to a constant." );
return;
}
verify::Func::SetDumpSolverOnSuccess( *FromValue< bool >( enable ) );
} );*/
RegisterBuiltinFunc< Intrinsic< void ( CustomPattern< Value, FuncPattern >, string ) > >( e, "#DumpFunctionCFG"_sid,
[]( auto&& c, const Value& funcVal, const Value& filename )
{
if( !funcVal.isConstant() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( funcVal.locationId(),
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
auto f = *FromValue< builtins::Func >( func );
if( !f.cir() )
return;
ofstream out( name.c_str() );
out << *f.cir();
} );
RegisterBuiltinFunc< Intrinsic< void ( uint32_t ) > >( e, "#SetExecutionBudget"_sid,
[]( auto&& c, const Value& budget )
{
static bool used = false;
if( !budget.isConstant() )
|
>
>
>
>
>
>
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
auto f = *FromValue< builtins::Func >( func );
if( !f.cir() )
return;
ofstream out( name.c_str() );
out << *f.cir();
} );
RegisterBuiltinFunc< Eager< void > ( CustomPattern< Value, ValuePatternT > ) >( e, "#DumpValue"_sid,
[]( const auto& v )
{
G_TRACE_VAL( v );
} );
RegisterBuiltinFunc< Intrinsic< void ( uint32_t ) > >( e, "#SetExecutionBudget"_sid,
[]( auto&& c, const Value& budget )
{
static bool used = false;
if( !budget.isConstant() )
|