We are now on implementing structures pop for.
What I want you to do is I want you to go to your parse the data type in its size in a type and size
function.
And we're going to create some functions above that.
So just above parse data, type in it, type and size, we're going to say in it size of struct, const
char struct name.
So this function is obviously going to return the size of a structure and we're even going to change
this to size DT rather than integer.
So we're going to start by getting the symbol
and we don't actually have that function exported yet.
So just go to symbols of see we're going to search for get symbol.
We're going to copy and paste this in dot h just above build for node.
And let's see if there's anything more in there that's important.
No, that should be okay.
So back to positive dot C in the get symbol, we're going to pass in the process and we're going to
pass in the struc name.
Now, if the symbol is null, then there's no structure of this name and we're just going to return
the zero.
We're now going to assert that this symbol is actually representing a node.
Okay.
Make sure it's two equals there, guys.
Well, then going to say struck node.
Node equals SIM data because we know the data for a symbol type node is a struc node and now going to
assert that the node type is a node type of struct.
So our only structures should be passed to this function, only structure names.
But I'm going to return node struct dot body and body dot size just like that.
So that will return the size of any structure we pass in there.
Okay.
We're now going to head over to node C.
And we're going to create a new function by here.
We're going to say struck node, struck node for name.
And we're going to go const char name.
And we're also going to say struct compile process, current process and get rid of the semicolon here
because we're obviously going to declare it.
And when you finish declaring that function, we're just going to make a new function.
We're going to say struck node node from symbol struct compile process can process const char name.
So this function will return the node that has the given symbol name.
And now just above here we're going to say struct node node from sim and it's going to accept a symbol
and all this makes sense in a moment.
So if the symbol type does not equal symbol type node, then we're just going to return null because
this is not a symbol that is a symbol type of node.
So we can't work with it.
Otherwise we're going to return the symbol data, simple as that, because we know the symbol data is
a node.
If the symbol type is node, symbol type node, right?
So now we're just going to say struct symbol CIM equals CIM resolver, cat symbol, current process
and we're going to pass in the name if the sim is null or return null.
Otherwise we'll return no from sim and we'll pass in the symbol, simple as that.
So yeah, this will basically go into the symbol resolver will grab the symbol and then it will call
no from SIM, which will basically ensure that it's a symbol node.
And if it is a symbol node, the actual node data will be extracted.
So now we need to finish us know for name.
So just in here we're going to say struck node node equals node from symbol.
And passing the current process we're going to pass in the name.
And if the node is null, we're going to return null.
If the node type does not equal node type struct again, we're going to return null because this is
trying to get structure nodes not not function nodes, not union nodes, structure nodes.
So what we care about.
So if it's passed all the tests so far, we can just return the node because we know the node is a structure
node.
That's perfect.
Just copy and paste these into the header file now.
I'm just going to search for no create.
There we go.
And I paste them in there and again, you know, just get rid of the bodies.
So only interested in the prototypes.
Now if we go back to parcel dot C, we can continue what we were doing.
So just search for init type and size.
We can sit by there.
Perfect.
We can get rid of this compiler error now for structure and union because we're about to implement them.
We'll actually keep the one for union because we haven't yet implemented unions yet.
Just change that to union types code not supported at a break under the spec struct and we're going
to start building from expect struct now.
So we're going to go data type out type equals data type struct data type out size equals size of struct.
And we're going to pass in the struct name, which is the data type token as file.
So that will basically call size of struct, which will extract the size from the body.
So now we need to go data type out struct node equals struct node for name.
Com process data type token.
S file.
So that should initialize our structure correctly.
So if it expects a structure, we'll go in here.
We'll set the type to data type struck, we'll grab the size and we'll grab the struct node.
Yeah, that's not bad.
So if we just look at the init type and size, we can see that that is called by day type in it.
If we look at what calls that, we can see that that is called by pause day type type OC.
And we can see we extract the expected type from here.
So just refresh your memory a bit, because obviously we we create this initial core functionality a
good couple years ago now we can see, you know, the date type spread if a type string basically looks
for a structure or union and then that's how it calculates the expected type.
So what we're going to do, we're going to open up the terminal, we're going to make clean, make,
and we can see that compiles just fine.
We run main everything, compile, file everything.
Everything was fine, perfect.
So that concludes this lecture.
We still can't use the actual structure functionality just yet because the symbol resolver, if we scroll
up, it hasn't yet been initialized.
No one's calling this function and we're also not calling new table functions either.
So.
We are done with the structural functionality for the most part, but we we can't test it yet until
we finish configuring our symbol resolver.
Thank you for watching.