121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
RegisterBuiltinFunc< Intrinsic< uint32_t ( string ) > >( e, "#Include"_sid,
[pEnv]( auto&& c, const Value& fnameval ) -> Value
{
auto filename = *FromValue< string >( fnameval );
auto identity = InjectDomainIntoIdentity( RootIdentity(), DomainCompileTime() );
auto result = Compiler::LoadAndExecuteFile( pEnv.lock(), filename, identity, GetValueType< uint32_t >() );
if( !result )
return ToValue< uint32_t >( 1 );
return *result;
} );
RegisterBuiltinFunc< uint32_t ( string ) >( e, "ExecuteFile"_sid,
[pEnv]( const string& filename ) -> Value
{
auto identity = InjectDomainIntoIdentity( RootIdentity(), DomainCompileTime() );
auto result = Compiler::LoadAndExecuteFile( pEnv.lock(), filename, identity, GetValueType< uint32_t >() );
if( !result )
return ToValue< uint32_t >( 1 );
return *result;
} );
RegisterBuiltinFunc< Intrinsic< Value ( string, Value, Value ) > >( e, "#CompileFileToFunction"_sid,
[pEnv]( auto&& c, const Value& filenameVal, const Value& rt, const Value& params ) -> Value
{
if( !filenameVal.isConstant() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( filenameVal.locationId(),
"#CompileFileToFunction: the expression doesn't evaluate to a constant." );
return PoisonValue();
}
|
|
>
|
|
>
|
|
|
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
RegisterBuiltinFunc< Intrinsic< uint32_t ( string ) > >( e, "#Include"_sid,
[pEnv]( auto&& c, const Value& fnameval ) -> Value
{
auto filename = *FromValue< string >( fnameval );
auto identity = InjectDomainIntoIdentity( RootIdentity(), DomainCompileTime() );
auto result = Compiler::LoadAndExecuteFile( pEnv.lock(), filename, identity,
GetValueType< uint32_t >(), ToValue< uint32_t >( 0 ) );
if( !result )
return ToValue< uint32_t >( 0 );
return *result;
} );
RegisterBuiltinFunc< uint32_t ( string ) >( e, "ExecuteFile"_sid,
[pEnv]( const string& filename ) -> Value
{
auto identity = InjectDomainIntoIdentity( RootIdentity(), DomainCompileTime() );
auto result = Compiler::LoadAndExecuteFile( pEnv.lock(), filename, identity,
GetValueType< uint32_t >(), ToValue< uint32_t >( 0 ) );
if( !result )
return ToValue< uint32_t >( 0 );
return *result;
} );
RegisterBuiltinFunc< Intrinsic< Value ( string, Value, Value, Value ) > >( e, "#CompileFileToFunction"_sid,
[pEnv]( auto&& c, const Value& filenameVal, const Value& rt, const Value& defReturnValue, const Value& params ) -> Value
{
if( !filenameVal.isConstant() )
{
DiagnosticsManager::GetInstance().emitErrorMessage( filenameVal.locationId(),
"#CompileFileToFunction: the expression doesn't evaluate to a constant." );
return PoisonValue();
}
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
c.env()->addVisibilityRule(
InjectDomainIntoIdentity( identity, ANYTERM( _ ) ),
InjectDomainIntoIdentity( funcIdentity, ANYTERM( _ ) ) );
auto func = BuildFunc( localC, ftype, identity, params, nullptr, c );
const auto& pFuncLLR = func.llr();
auto cfg = Compiler::LoadAndParseFile( pEnv.lock(), filename, funcIdentity, ftype.returnType() );
if( !cfg )
return PoisonValue();
if( cfg->isPoisoned() )
return PoisonValue();
pFuncLLR->body() = cfg;
return ToValue( func );
} );
}
}
|
|
>
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
c.env()->addVisibilityRule(
InjectDomainIntoIdentity( identity, ANYTERM( _ ) ),
InjectDomainIntoIdentity( funcIdentity, ANYTERM( _ ) ) );
auto func = BuildFunc( localC, ftype, identity, params, nullptr, c );
const auto& pFuncLLR = func.llr();
auto cfg = Compiler::LoadAndParseFile( pEnv.lock(), filename, funcIdentity,
ftype.returnType(), defReturnValue );
if( !cfg )
return PoisonValue();
if( cfg->isPoisoned() )
return PoisonValue();
pFuncLLR->body() = cfg;
return ToValue( func );
} );
}
}
|