-
Notifications
You must be signed in to change notification settings - Fork 388
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
fix: global var dependencies #2077
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Left some nitty comments 🙏
Overall looks good, thank you for the fix 🙏
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.
Please also add more tests to check for different cases, thanks!
c7365aa
to
813b7e1
Compare
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):No automated checks match this pull request. ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
@petar-dambovaliev I've moved this PR to draft until it's ready for review. |
Only codecov failing. Its ready. @Kouteki |
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.
LGTM! A few requests, mostly regarding comments, so we can avoid reviewing this as a brand new PR each time. :)
func getGlobalValueRef(sb BlockNode, store Store, n Name) *TypedValue { | ||
sbb := sb.GetStaticBlock() | ||
idx, ok := sb.GetLocalIndex(n) | ||
bb := &sb.GetStaticBlock().Block | ||
bp := sb.GetParentNode(store) | ||
|
||
for { | ||
if ok && sbb.Types[idx] != nil && (bp == nil || bp.GetParentNode(store) == nil) { |
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.
func getGlobalValueRef(sb BlockNode, store Store, n Name) *TypedValue { | |
sbb := sb.GetStaticBlock() | |
idx, ok := sb.GetLocalIndex(n) | |
bb := &sb.GetStaticBlock().Block | |
bp := sb.GetParentNode(store) | |
for { | |
if ok && sbb.Types[idx] != nil && (bp == nil || bp.GetParentNode(store) == nil) { | |
func getGlobalValueRef(sb BlockNode, store Store, n Name) *TypedValue { | |
sbb := sb.GetStaticBlock() | |
bb := &sb.GetStaticBlock().Block | |
bp := sb.GetParentNode(store) | |
idx, exist := sb.GetLocalIndex(n) | |
for { | |
if exist && sbb.Types[idx] != nil && (bp == nil || bp.GetParentNode(store) == nil) { |
} | ||
} | ||
|
||
func findUndefinedGlobal(store Store, last BlockNode, x Expr, t Type) (un Name) { |
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 findUndefinedFromGlobal
be more directional?
|
||
// finds the next undefined identifier and returns it if it is global | ||
func findUndefined2SkipLocals(store Store, last BlockNode, x Expr, t Type) Name { | ||
name := findUndefinedGlobal(store, last, x, t) |
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.
as the base logic of the PR, please add comments to this function. to better illustrate the searching logic
:
for my understanding: searching from initialized global -> uninitialized global decls -> local...
if _, _, ok := pkg.FileSet.GetDeclForSafe(name); !ok { | ||
return "" | ||
} |
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.
also need comments here.
return "" | ||
} | ||
|
||
isLocal := existsLocal(name, last) |
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.
and here.
bp := sb.GetParentNode(store) | ||
|
||
for { | ||
if ok && sbb.Types[idx] != nil && (bp == nil || bp.GetParentNode(store) == nil) { |
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.
sbb.Types[idx] != nil
implies it's defined
rather than predefined
, right? please add a comment here.
for { | ||
currNames := curr.GetBlockNames() | ||
|
||
for _, currName := range currNames { |
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.
searching (only)by name implies predefined(only names, no types) is good, right? please also add comment here.
and what we do with the codecov? @petar-dambovaliev @zivkovicmilos |
return "" | ||
} | ||
|
||
func getGlobalValueRef(sb BlockNode, store Store, n Name) *TypedValue { |
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.
better make it a method like the existing one:
func (sb *StaticBlock) GetValueRef(store Store, n Name, skipPredefined bool)
,
bp := sb.GetParentNode(store) | ||
|
||
for { | ||
if ok && sbb.Types[idx] != nil && (bp == nil || bp.GetParentNode(store) == nil) { |
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.
if it must reach bp == nil
to make sure it's global, then bp.GetParentNode(store) == nil
is not needed/reachable.
Perhaps the logic in |
maybe the difference won't be big, just some food for thoughts. |
At first, i tried having a single function but it became too many changes and too messy |
fixes this by adding missing logic in in
findUndefined2