mirror of https://github.com/tbklang/tlang.git
⚡ Feature: Add support for structs #118
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: 23 hours 41 minutes
Due Date
deavmi
23 hours 41 minutes
Depends on
#152 🧠️ Ideation: Loaders
tlang/tlang
You do not have permission to read 1 dependency
Reference: tlang/tlang#118
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?
What is this?
Add support for structs via the
struct
keyword.Pretty sure dependency generation for paths will be needed before deoendenecy generation can work correctly for it.
⚡ Add support for structsto ⚡ Feature: Add support for structsCan continue working now that
Struct
hasclone()
supportProgress 🚧
Given the code:
So far so good, looks like cloning helped. The queues are below:
Working on this again today, trying my new ideas out.
So far so good, cloned some stuff according to the Metaprocessor trick I am using. "Trick" is a bad word, it makes sense and is very logical considering how nice my language aims to be.
Now just symbol mapper-related things to consider. This will be epic sussy.
A little drunk now but gonna continue
Working on tis again now....
Okay, I think I just got it working. Going to have to stage the changed files now.
Todo
emit
->emit_c
StructVariableInstance
&
to work (currently gives Segmentation Fault)User* ptr = &u1;
&u1
has been added whereu1
refers to aStructVariableInstance
&u1.name
I've merged newest changes of
vardec_varass_dependency
into here and now CI/CD is all green ✅ (due to #115 being merged in)Working on this again now.
New challenge
Currently testing out
complex_structs.t
which makes use of a variable of of astruct
-based type (Cart
) as a member of a struct type:Currently it segfaults:
Seems like a post-AST replacement check issue, working on the fix now...
The problem with this approach, or from what I can see is nested
StructVariableInstance
s have the problem that when they appear inside of a struct we will affectively have the wrong things pushed to the end of the code queue for consumption.However, actually - I am not sure how much this is to blame for this solution we have chosen. This more stems from the fact we have a
Container
-type node, theStructVariableInstance
and it has members within. This would have been the case if we had done this during parse time too.So I just have to find a neat work around for it in the type checker.
Wait, no I think I am dumb. This isn't it, I can see the code queue - my method is correct. I just need to cast to the common type of
StorageDeclaration
and notVariableDeclaration
(which is derived fromVariable
-based members) and thenStructInstantiateInstruction
(which is derived fromStructInstanceVariable
-based members).I may now be onto something, successful compilation of:
To the C-emitted code:
Now that #153 is fixed the test case
complex_structs.t
now compiles.Updated with latest code from
vardec_varass_dependency
. The code coverage should be higher now. 👍Just added complex_structs.t
and
simple_structs.tto run as part of the D-based unit tests (not _just_ having them in
d.yml`).This should also increase code coverage.
I am thinking about how we have gone about this. I might want to open a similar PR that does this but differently.
I think that if we do it this way, which honestly does sound proper, we may run into issues regarding struct types with member variables of other struct types.
I believe that we may somehow, during parse time, need to build up a symbol table maybe.
If we parse a struct like so:
Mmmh, even with this we would need resolution at parse time which we do NOT have. Nor do I think it would be right to add that.
I will sit on and ponder this as within the parsing startergy there are various ways to go about this.
MMmh, is this correct? Let me check... 🧠
Update of thoughts in October
Well, actually my system does support this:
Also, we need not worry about a struct
A
which contains a member of typeB
which containsA
. That is impossible in any language with a struct, it must be a DAG.Mmh, well then. Maybe this method will then work. :)
I was thinking in the case of class-based types, in such a case we will need a similar type-init (for static inits) and then instance init, where instances can be of a type which has mutual references. Going to open thoughts for this on #158.
This should be finished prior to #157 as I want to get these changes in and upstream them into that issue's branch, rather than deal with many merge conflicts later.