Retrieving the Scope of a statement

Basile B. b2.temp at gmx.com
Tue Apr 21 06:58:47 UTC 2020


On Tuesday, 21 April 2020 at 01:52:49 UTC, Basile B. wrote:
> On Monday, 20 April 2020 at 16:56:51 UTC, Cristian Creteanu 
> wrote:
>> Hi!
>>
>> I am trying to implement autocomplete in DCD using DMD as a 
>> library.
>> [...]
> [...]
> to an `AstNode` you CANT use a custom visitor.

Sorry maybe I've been too opiniated.

in DMD, because of the lazy compilation model, visitors usually 
don't process a whole module so:

- the scope for a statement is the scope that's passed to the 
`StatementSemanticVisitor` class created when 
`statementSemantic()` is called for this statement.
- the scope for an expression is the scope that's passed to the 
`ExpressionSemanticVisitor` class created when 
`expressionSemantic()` is called for this expression.
- the scope for a type is the scope that's passed to the 
`TypeSemanticVisitor` class created when `typeSemantic()` is 
called for this type.

 From your original message I have the impression that you want to 
retrieve a scope by a node, and you noticed that this is not 
always possible. The time where a scope is always linked to a 
node is when its semantic is run, and it's a class member. So 
maybe (and only maybe) there's something to do with that fact but 
as said at first glance I don't see how, without a kind of 
callback system.




More information about the Digitalmars-d mailing list