Fixed issue with 'this' not being present in struct bodies

This commit is contained in:
Hackerpilot 2013-10-14 00:50:27 +00:00
parent cc49cef4c7
commit f97add145d
1 changed files with 14 additions and 7 deletions

View File

@ -116,7 +116,7 @@ final class FirstPass : ASTVisitor
override void visit(FunctionDeclaration dec) override void visit(FunctionDeclaration dec)
{ {
// Log.trace(__FUNCTION__, " ", typeof(dec).stringof); // Log.trace(__FUNCTION__, " ", typeof(dec).stringof);
SemanticSymbol* symbol = new SemanticSymbol(dec.name.value.dup, SemanticSymbol* symbol = new SemanticSymbol(dec.name.value.dup,
CompletionKind.functionName, symbolFile, dec.name.startIndex); CompletionKind.functionName, symbolFile, dec.name.startIndex);
processParameters(symbol, dec.returnType, symbol.acSymbol.name, processParameters(symbol, dec.returnType, symbol.acSymbol.name,
dec.parameters); dec.parameters);
@ -261,11 +261,18 @@ final class FirstPass : ASTVisitor
s.startLocation = structBody.startLocation; s.startLocation = structBody.startLocation;
s.endLocation = structBody.endLocation; s.endLocation = structBody.endLocation;
// Log.trace("Added scope ", s.startLocation, " ", s.endLocation); // Log.trace("Added scope ", s.startLocation, " ", s.endLocation);
ACSymbol* thisSymbol = new ACSymbol("this", CompletionKind.variableName,
currentSymbol.acSymbol);
thisSymbol.location = s.startLocation;
thisSymbol.symbolFile = symbolFile;
currentSymbol.acSymbol.parts ~= thisSymbol;
s.parent = currentScope; s.parent = currentScope;
currentScope = s; currentScope = s;
foreach (dec; structBody.declarations) foreach (dec; structBody.declarations)
visit(dec); visit(dec);
currentScope = s.parent; currentScope = s.parent;
currentScope.children ~= s; currentScope.children ~= s;
} }
@ -549,7 +556,7 @@ private:
struct ThirdPass struct ThirdPass
{ {
public: public:
this(SemanticSymbol* rootSymbol, Scope* moduleScope) this(SemanticSymbol* rootSymbol, Scope* moduleScope) pure
{ {
this.rootSymbol = rootSymbol; this.rootSymbol = rootSymbol;
this.moduleScope = moduleScope; this.moduleScope = moduleScope;
@ -668,7 +675,7 @@ private:
return s; return s;
} }
static string[] expandSymbol(const IdentifierOrTemplateChain chain) static string[] expandSymbol(const IdentifierOrTemplateChain chain) pure
{ {
string[] strings = new string[chain.identifiersOrTemplateInstances.length]; string[] strings = new string[chain.identifiersOrTemplateInstances.length];
for (size_t i = 0; i != chain.identifiersOrTemplateInstances.length; ++i) for (size_t i = 0; i != chain.identifiersOrTemplateInstances.length; ++i)