Add support for mixin templates

This commit is contained in:
Hackerpilot 2014-08-08 02:41:19 +00:00
parent d1b6b09c59
commit 223c70ea8d
4 changed files with 33 additions and 5 deletions

View File

@ -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 If it exists, each line of the file is interpreted as a path that should be
searched when looking for module imports. searched when looking for module imports.
Keep in mind that DCD treats import paths the same way that the compiler does. 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: For example, a configuration file like this will not work as expected:

View File

@ -405,6 +405,15 @@ final class FirstPass : ASTVisitor
versionCondition.accept(this); 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; alias visit = ASTVisitor.visit;
/// Module scope /// Module scope

View File

@ -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) ACSymbol* resolveInitializerType(I)(ref const I initializer, size_t location)

View File

@ -77,7 +77,7 @@ public:
UnrolledList!(string) aliasThis; UnrolledList!(string) aliasThis;
/// MixinTemplates /// MixinTemplates
UnrolledList!(string) mixinTemplates; UnrolledList!(string[]) mixinTemplates;
/// Protection level for this symobol /// Protection level for this symobol
IdType protection; IdType protection;