-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make function symbols store function parameters, needed for UFCS. #182
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,7 @@ final class FirstPass : ASTVisitor | |
pushFunctionScope(dec.functionBody, semanticAllocator, | ||
dec.name.index + dec.name.text.length); | ||
scope (exit) popScope(); | ||
includeParameterSymbols = true; | ||
processParameters(currentSymbol, dec.returnType, | ||
currentSymbol.acSymbol.name, dec.parameters, dec.templateParameters); | ||
dec.functionBody.accept(this); | ||
|
@@ -972,6 +973,7 @@ private: | |
processTemplateParameters(symbol, templateParameters); | ||
if (includeParameterSymbols && parameters !is null) | ||
{ | ||
currentSymbol.acSymbol.functionArguments.reserve(parameters.parameters.length); | ||
foreach (const Parameter p; parameters.parameters) | ||
{ | ||
SemanticSymbol* parameter = allocateSemanticSymbol( | ||
|
@@ -981,6 +983,9 @@ private: | |
addTypeToLookups(parameter.typeLookups, p.type); | ||
parameter.parent = currentSymbol; | ||
currentSymbol.acSymbol.argNames.insert(parameter.acSymbol.name); | ||
|
||
currentSymbol.acSymbol.functionArguments ~= parameter.acSymbol; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mixed tabs and spaces |
||
|
||
currentSymbol.addChild(parameter, true); | ||
currentScope.addSymbol(parameter.acSymbol, false); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,10 +375,16 @@ struct DSymbol | |
/** | ||
* Names of function arguments | ||
*/ | ||
// TODO: remove since we have function arguments | ||
UnrolledList!(istring) argNames; | ||
|
||
private uint _location; | ||
|
||
/** | ||
* Function argument symbols | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mixed tabs and spaces |
||
*/ | ||
DSymbol*[] functionArguments; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need to be an array of pointers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess so since DSymbol isn't copyable unless we change that.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. usually all the DSymbol references are done by pointers, but it might be effective to use them inline in arrays (e.g. move them into the array) We already know the count of items that get put into array before putting them there anyway, so we can already preallocate all the space and directly construct them in-place. |
||
|
||
/** | ||
* DSymbol location | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be here (it effectively now makes the constructor parameter useless, as parameters would always be included)
If it's never a problem, consider instead removing the symbol completely, deprecating the ctor and stripping all the
ifs
that checked on it