Skip to content
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

⚡ Feature: Support for access modifiers, init scope #35

Open
wants to merge 30 commits into
base: vardec_varass_dependency
Choose a base branch
from

Conversation

deavmi
Copy link
Contributor

@deavmi deavmi commented Feb 29, 2024

Pleas see this.

- We now have a stack for access modifiers and init scope
- Handle `static` now and place on stack
- Added the required functions for managing the `ModifierItem` queue
- Fixed `hasModifierItems()`
- Added methods `getAccessModifier()` and `getInitScope()`

Parser

- Renamed the `ModifierItem` methods
- `parseClass()` now expects an optional access modifier followed by an optional BUT only init scope
- Can now set access modifiers on `Variable` and `Function` (so variable and function definitions)
- Can now apply access modifiers (not yet initscopes) to struct declarations
- `parseStruct()` now can toggle whether ot not an `InitScope` modifier is allowed and IF SO we now handle it
- When parsing a class's body, if there is a struct then let the `struct` have initscopes be applied to it
- `parseTypedDeclaration(...)` made it nicer format
- When parsing variable function definitions we now allow initscopes (only if the variable to allow it is set)
- When parsing body statements of class or struct we now allow initscopes to be set for function and variable declarations (if encountered)
@deavmi deavmi self-assigned this Feb 29, 2024
@deavmi deavmi changed the title Feature/modifiers ⚡ Feature: Support for access modifiers, init scope Feb 29, 2024
@deavmi deavmi added the enhancement New feature or request label Feb 29, 2024
deavmi added 16 commits March 3, 2024 11:57
- Added `niknaks` dependency at version `>=0.9.0`
- Added note about whether or not the default `AccessModifier` should be set here

Parser

- `parseName(...)` now accepts `allowModifiers` and `allowqInitScopesOnDec`
- `parseName(...)` using `FuncDebug`
- `parseName(...)` now explicitly passes arguments to `parseTypedDeclaration(...)`
- Added `funcDebugPrint(string)`for use as our custom writer start when using `FuncDebug`
- `parseBody(...)` now takes in `allowModifiers`
- `parseBody(...)` now is using `FuncDebug`
- `parseBody(...)` now explicitly passes parameters t `parseStatement(...)`
- `popModifierFront()` nw has debug prints
- Added a debug-only method for dumping the modifiers queue
- `parseFuncDef(...)` now passes `false` t `parseBody(allowModifiers)` because within a function no statements may have modifiers
- `parseTypedDeclaration(...)` haw `allowModifiers` nw
- `parseTypedDeclaation(...)` now pops any valid acc mods and init scopes off when allowed and when it is a `Function` being built; at the end, if specified, these are then applied to said `Entity`
- Disabled the old code in `parseTypedDeclaration(...)`
- Disabled the old code in `parseClass(...)`
- `parseStatement(...)` now takes in `allowModifiers` and will pass it into `parseName(...)` when called
- `parseStatement(...)` now also supports modifiers such as ACC_MOD and INIT_SCOPEs but only is allowed to be specified
- `parse()` now calls `parseName()` allowing access modifiers but NOT init scopes

Parser (unittests)

- Added a test for access modifiers

Dub

- Upgraded `niknaks` version
- Added negative test cases
- Upgraded to latest version (`niknaks`)
- Start off with `accessorType` set to its type's `.init` value

AccessorType

- Make the `.init` `UNKNOWN`

InitScope

- Make the `.init` `UNKNOWN`
- Function definition now have a default access modifier of `PRIVATE`
- Fixed up the unittests in the `Parser` (and disabled some thing we can't access due to not have access to it via a given `Parser`)
- Fixed imports in dependency.d and parser.d
- Updated `b.t` and `c.t` in hopes of fixing them for the new access-modifier based testing
- Both variable declarations AND variable-declarations-with-assignments now have access modifier and init scope support

Test cases

- Fixed the `a.t`
- Cleaned up commented-out code
- `parse()` now handles init scopes (modifiers)
- Added `accessCheck(Container yourContainer, Entity toCheck)`
- Removed this print out
- Added more recursive painting of various dofferent AST nodes
- Added new exception type
- Added initial access checking method
- Added access checks for `VariableExpression` and `FunctionCall`
deavmi added 3 commits May 6, 2024 14:33
- Updated `a.t`
- Typo fix
- `accessCheck(...)` cleaned up
- Documented `accessCheckAuto(...)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant