-
Notifications
You must be signed in to change notification settings - Fork 428
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
dyno: More progress on the typed converter #26824
base: main
Are you sure you want to change the base?
dyno: More progress on the typed converter #26824
Conversation
Signed-off-by: David Longnecker <[email protected]>
Signed-off-by: David Longnecker <[email protected]>
Signed-off-by: David Longnecker <[email protected]>
Signed-off-by: David Longnecker <[email protected]>
Signed-off-by: David Longnecker <[email protected]>
@@ -658,13 +658,68 @@ void print_view_noline(BaseAST* ast) { | |||
fflush(stdout); | |||
} | |||
|
|||
// TODO: Take a reference and decay it to avoid copying when debugging. |
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.
Since this is just a helper, how about making two different functions, one taking in a pointer, one taking in a reference? Might be possible for C++ overload resolution to handle this but I don't think fussing with that is worthwhile here. Just make two different functions with different names.
if (id.isEmpty() || !idIsMethod(context, id)) return false; | ||
for (auto up = id.parentSymbolId(context); up; | ||
up = up.parentSymbolId(context)) { | ||
if (idIsMethod(context, up)) return true; |
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.
shouldn't this be checking for any sort of function here?
We already know Id is a method. I would think that this function should return true for a method nested in a non-method function.
Presumably search up should stop at a module.
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.
I think this function has a naming problem, what I want it to do is idIsMethodContainedInMethod
. Should I rename it or just remove it from the frontend and move it to the converter? This is to catch the case of multiple conflicting receivers since we can't disambiguate those yet.
Will adjust to stop at module.
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.
Renaming it to idIsMethodContainedInMethod
is fine with me.
if (this->hasPragma(context, uast::PRAGMA_EXTERN)) return uast::Decl::EXTERN; | ||
if (this->hasPragma(context, uast::PRAGMA_EXPORT)) return uast::Decl::EXPORT; | ||
if (auto& id = this->id()) { | ||
if (auto ast = parsing::idToAst(context, id)) { |
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.
IMO we should be storing the linkage in the CompositeType here rather than using idToAst. The CompositeType constructor / build can accept the linkage.
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.
Will do.
return ret; | ||
} | ||
|
||
std::tuple<AList*, Expr*, bool>& fetchListStackEntry(bool isStmtList) { |
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.
let's rename isStmtList to getStatement or something as it's not asserting about the list it's indicating what to get
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.
How about bool fetchStmtList
? I think we have the same idea. Thanks!
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.
Sounds good
@@ -2680,9 +3001,6 @@ VarSymbol* TConverter::convertVariable(const uast::Variable* node, | |||
// Fix up the AST based on the type, if it should be known | |||
setVariableType(node, varSym, rv); | |||
|
|||
// Note the variable is converted so we can wire up SymExprs later | |||
noteConvertedSym(node, varSym); |
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.
Why remove this ? Is it handled elsewhere now?
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.
Yeah I'm trying to be a bit more consistent with the naming scheme of convert...
vs convertAndInsert
... IDK. The visitor is inserting right now. Maybe it doesn't matter.
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.
IIRC, noteConvertedSym
isn't about inserting it; it's about updating the maps from uAST things to AST things, so that if we see a mention of the variable later, we can use the dyno resolver to determine the ID it refers to, and then use the map to find the Symbol that is, and then generate a SymExpr pointing to the right thing.
This PR adds more of my contributions to the typed converter. It adds support for compiling more language features such as parenless method calls, field access, logical operator short-circuiting, default values for records, and more! We can now write fun programs like the following.
param
expressions immediately inconvertExpr
AggregateType
, mark them asRESOLVED
types::ExternType*
and attach flags to them when thetype
variable for their declaration is evaluatedextern
recordsPRAGMA_NO_INIT
(x, y)
||
and&&
with support for short-circuitingx.y
)BaseAST*
calledshouldNotMutateEarly()
TESTING
make -j && make check
make -j test-frontend
make -j test-cls
ALL
w/linux64
,standard
Reviewed by @mppf. Thanks!