24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
const auto* name = get_if< StringId >( &nameTerm->first );
if( !name )
{
dm.emitSyntaxErrorMessage( nameTerm->second, "expected an identifier.", 0 );
return false;
}
auto& context = p.context();
// Create an identity to contain the visibility of any symbol defined inside of the using statement.
// Since the current identity is that of the local variables of the current function and those
// shouldn't be visible inside of the using statement, we simply replace the last element of the identity
// by the name of the using definition, so that its parent becomes the current function's identity.
//
// TODO: we'll probably need a more sophisticated scheme to be able to deal with lambda captures
// where localvars from the parent(s) functions should be visible, but still not visible inside of
// using statements. But one mess of a feature at a time.
auto localIdentity = TakeVectorTerm( context.identity(), VecSize( context.identity() ) - 1 );
get< pvec >( localIdentity )->terms().back() = nameTerm->first;
context.env()->addVisibilityRule( context.identity(), localIdentity );
auto eqTerm = p.resolver()->consumeUnresolved();
if( !eqTerm )
{
dm.emitSyntaxErrorMessage( p.resolver()->currentLocation(), "expected '='.", 0 );
context.env()->storeValue( localIdentity, ANYTERM( _ ), ValueToEIR( PoisonValue() ) );
return true;
|
>
>
>
>
>
>
>
>
>
>
>
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
const auto* name = get_if< StringId >( &nameTerm->first );
if( !name )
{
dm.emitSyntaxErrorMessage( nameTerm->second, "expected an identifier.", 0 );
return false;
}
Parser::CurrentContextGuard ccg( p );
auto& context = p.context();
// we don't have a builder to parse using expresions. It disables
// a number of things, in particular, the ability to overload functions.
// This avoids unfortunate parsing ambiguiousness in some cases
// (cf test g0/statements/e-using-2.g0)
context.setBuilder( ToValue< void >() );
// Create an identity to contain the visibility of any symbol defined inside of the using statement.
// Since the current identity is that of the local variables of the current function and those
// shouldn't be visible inside of the using statement, we simply replace the last element of the identity
// by the name of the using definition, so that its parent becomes the current function's identity.
//
// TODO: we'll probably need a more sophisticated scheme to be able to deal with lambda captures
// where localvars from the parent(s) functions should be visible, but still not visible inside of
// using statements. But one mess of a feature at a time.
auto localIdentity = TakeVectorTerm( context.identity(), VecSize( context.identity() ) - 1 );
get< pvec >( localIdentity )->terms().back() = nameTerm->first;
context.env()->addVisibilityRule( context.identity(), localIdentity );
context.setIdentity( localIdentity );
auto eqTerm = p.resolver()->consumeUnresolved();
if( !eqTerm )
{
dm.emitSyntaxErrorMessage( p.resolver()->currentLocation(), "expected '='.", 0 );
context.env()->storeValue( localIdentity, ANYTERM( _ ), ValueToEIR( PoisonValue() ) );
return true;
|