mirror of https://github.com/tbklang/tlang.git
Class static initialization incorrect ordering #8
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Blocks
#13 Clean ups
tlang/tlang
Reference: tlang/tlang#8
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The following code:
Gives us a code queue where
ClassStaticAlloc
is at end, this should not be (probably not implemented):Class static initlaization incorrec orderingto Class static initialization incorrect orderingBug found
It is definately this code:
Which is causing the problem. Disabling it fixes stuff, (which makes sense seeing how I rushed that code). The one thing we lose then though, is the
ClassStaticAllocate
node in it. But instead of trying to re-write that code and do matching and swapping we could look at re-working it maybe? Nah, can't have multiple vardecs depend on it... 👀We should look into that or simply implementing it with swapping (ew, if not the only way - needs thinking!)
Logically speaking it doesn't make sense to make things depend on class allocate. The class allocator depends on them..
In another way it does make sense to have all class stuff depdnd on allocate - it would properly linearize then without swapping. Mmmm....
Perhaps the code (where it rears its head in one case):
Needs a similiar fix to that of
31c52c0bebeb77e36155e3c62f5fb3d7a7ed7707
on branchvardec_varass_dependency
for issue #11.In other words, the
node
(module/container) should RATHER depend on the class which THEN depends on the variable.WRONG - THIS IS WRONG - makes no sense
Two issues
A i;
A
is a class-typex.y.z
wherey
is a classSo we need to analyse those both. The current way we have things seems to make sense for point 1. As for 2 maybe that is causing issues as I haven't actually tried out
2
since the changes made on branchvardec_varass_dependency
for issue #11.For issue 1, on #11's branch we get correct output for this code:
Output:
Now also checking this code:
We get this output:
Now how would we deal with this? (We get a "NO MATCHES FIX FOR ME" eror too)
I may have found it 🤠
Mmmh, nah....
More complicated examples such as:
Generate:
What I am thinking is that we may need to just bubble class declarations up to them top or something. As everything but the allocation order is correct above (actual allocation NOT initialization (which is correct above))
Perhaps whenever we process these we should add them to their own code queue? I don't know if that makes sense but it is a possibility.
I think the problem we have now is using one single queue for those things. Dependency stuff like the vardecs are all correct.
Perhaps what we could do is idk have a
classInitQueue
, and then we combine these queus in the orderinitQueue
(static allocation of memory, no init)codeQueue
(main queue - would include init, vardecs and varassigbnments)Well well well, this may very well be working.
Closing as we will look at this only later.