Add support for mixin templates
This commit is contained in:
parent
d1b6b09c59
commit
223c70ea8d
|
@ -151,8 +151,6 @@ The server will attempt to read the file ```~/.config/dcd``` on Posix systems, o
|
|||
If it exists, each line of the file is interpreted as a path that should be
|
||||
searched when looking for module imports.
|
||||
|
||||
|
||||
|
||||
Keep in mind that DCD treats import paths the same way that the compiler does.
|
||||
For example, a configuration file like this will not work as expected:
|
||||
|
||||
|
|
|
@ -405,6 +405,15 @@ final class FirstPass : ASTVisitor
|
|||
versionCondition.accept(this);
|
||||
}
|
||||
|
||||
override void visit(const TemplateMixinExpression tme)
|
||||
{
|
||||
// TODO: support typeof here
|
||||
if (tme.mixinTemplateName.symbol is null)
|
||||
return;
|
||||
currentSymbol.mixinTemplates.insert(iotcToStringArray(symbolAllocator,
|
||||
tme.mixinTemplateName.symbol.identifierOrTemplateChain));
|
||||
}
|
||||
|
||||
alias visit = ASTVisitor.visit;
|
||||
|
||||
/// Module scope
|
||||
|
|
|
@ -149,9 +149,30 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void resolveMixinTemplates(SemanticSymbol*)
|
||||
void resolveMixinTemplates(SemanticSymbol* currentSymbol)
|
||||
{
|
||||
// TODO:
|
||||
foreach (mix; currentSymbol.mixinTemplates[])
|
||||
{
|
||||
import stupidlog;
|
||||
Log.trace(mix);
|
||||
auto symbols = moduleScope.getSymbolsByNameAndCursor(mix[0],
|
||||
currentSymbol.acSymbol.location);
|
||||
if (symbols.length == 0)
|
||||
continue;
|
||||
auto symbol = symbols[0];
|
||||
foreach (m; mix[1 .. $])
|
||||
{
|
||||
auto s = symbol.getPartsByName(m);
|
||||
if (s.length == 0)
|
||||
{
|
||||
symbol = null;
|
||||
break;
|
||||
}
|
||||
else
|
||||
symbol = s[0];
|
||||
}
|
||||
currentSymbol.acSymbol.parts.insert(symbol.parts[]);
|
||||
}
|
||||
}
|
||||
|
||||
ACSymbol* resolveInitializerType(I)(ref const I initializer, size_t location)
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
UnrolledList!(string) aliasThis;
|
||||
|
||||
/// MixinTemplates
|
||||
UnrolledList!(string) mixinTemplates;
|
||||
UnrolledList!(string[]) mixinTemplates;
|
||||
|
||||
/// Protection level for this symobol
|
||||
IdType protection;
|
||||
|
|
Loading…
Reference in New Issue