mirror of https://github.com/tbklang/tlang.git
⚡ Feature: Support for access modifiers, init scope #165
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 8 hours 15 minutes
Due Date
deavmi
8 hours 15 minutes
Dependencies
No dependencies set.
Reference: tlang/tlang#165
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?
Purpose ✍️
To add support for
public
,private
,protected
,static
etc. to the following:Parser
InitScope
s will only be valid in certain places, so we must make that a potential optional argument or something only in places where it could potentially be appliedTypeChecker
/Dependency generationDGen
Added the required functions for managing the
ModifierItem
queue. ✅Support for acecss modifiers and initscopes added for
parseClass()
✅Can now apply access modifiers (not yet initscopes) to variable and function declarations ✅
Can now apply acecss modifiers (not yet initscopes) to struct declarations ✅
Structs now have a toggalble
InitScope
allowance and if so then apply it ✅Will be doing this for variable and function definitions in a moment
Found some fixes I want to apply to
parseClass()
andparseStruct()
onvardec_varass_dependency
probably.Pushed fix for it, upstreaming now...
Merged ✅
When parsing body statements of class or struct we now allow initscopes to be set for function and variable declarations (if encountered) ✅
Enough for now, looks like unittests are what is needed next
I know what is happening, in the case of:
The ending iteration of
parseBody()
forint i
is getting the queue itemprivate
(ACC_MOD). And leaving nothing for the function. We must updateparseBody()
to have something to tweak whether or not acc mods are allowed.It's
parseFuncDef()
->parseBody(true)
->parseStatement(SymbolType.SEMICOLON, true)
.It is at the point of
parseStatement(SymbolType.SEMICOLON, true)
that any time we come across anisAccessor(tok)
orisModifier(tok)
we then check that second argument, iftrue
we go ahead andparseAccessor()
andparseInitScope()
respectively, else we throw an exception.So this is a valid fix but that wasn't it. It is within the
parseName(...)
call inparseStatement()
Been spending this time adding debugging helper methods to niknaks to make sorting this out a lot easier.
Enough for tonight. Will continue tomorrow, finalize and bring it into tlang code base for usage here and then the debugging shall continue.
Done and now in TLang, just need to use it.
Aii, hierdie technique is ass.
Not all is lost, I think.
I might need to, prior to entering sme sort of nested shit, actually pop off the modifiers as soon as they are n a valid thing (or before that valid thing is created).
By this I mean that when I am doing
parseFuncDef()
I must check if there are any modifiers available, pop them and save them and then apply them right at the end.I shouldn't be leaving anything for things which are invalid.
We shall still make use of
allowModifiers
because the generatedFunction
may be in aclass
where init scopes are allowed or in a module level (where they are not). So it is still a valid control.Holy moly, it worked 🇱🇧
Got that done, CI/CD is now passing ✅
I think I came across a good solution for this.
Added negative test cases ✅
Functions now have a default access modifier of
PRIVATE
✅Working on this now...
Sorted out the merge conflicts now ✅
Having weird issuesd compiling some stuff now thonmking
So
doThing()
isprivate
by default, so if I prepend its delcaration withpublic
then things sort out the first error. Similar story with accessingk()
from the generateda.c
Weird stuff, this:
Gives this ⏰:
Looks like variables are not having access modifications applied to them actually.
Added a forceful quit, looks like this IS the reason why! :)
Looks like I fixed it, will push later
Fixed and pushed ✅
Need to fix calls for
parsename(...)
or so, to allow init scopes for variables in certain cases.Nvm, all is fine ✅
Working on this now
Looks like it is beginning to work. done for today though
I know what is to be done and it need not use
Context
(which is something I want to deprecate anyways)This will be finished this week.