Hello and welcome, everybody.
Some lectures ago, we created the scope based functionality.
In this lecture, we're going to make the paths of scope functionality which will use this abstract
scope functionality here.
So let's just go to parse a dot, see scroll all the way to the top.
And just above here we're going to say struct parser scope entity.
So this is in the paths of dot c file guys.
Okay, we're going to say init flags.
So these are the the entity flags of the scope entity and let's just make those flags that makes a bit
more sense to you before we continue writing the parse of scope entity.
So we make an enumeration here and then we're just going to go parse the scope entity on stack equals
zero.
B one, two, three four, one, two, three, four.
Knock off the last zero and put a one.
So that's the equivalent of zero one.
Okay.
And then we're going to go parse a scope, entity, structure, scope, and we're going to copy and
paste this number and just put a one here and a zero there.
Okay.
So that's CO two.
Okay.
Nice.
So essentially this enumeration will be set.
If the scope entity is on the stack, this bit will be set.
If the scope entity is on, it's on a structure scope.
So basically inside of a structure, right.
So every scope entity will have a stack offset.
Okay.
So if you remember on the last lecture, we explained stack offsets.
I said we'd be implementing them in the next couple of lectures.
Well, we're going to make an attempt now in the next few lectures and briefly in this lecture as well
will be setting up those stack offsets.
So they're ready.
And yeah, just by here we're going to put a comment, the stack offset of the scope entity
so that can be negative for a local scope and positive for a function argument scope.
Yeah.
Finally we have a pointer to the node variable declaration.
Okay.
So now we're going to say struck pause the scope entity pause a new scope entity that's going to accept
a node, a stack offset and some flags.
Perfect.
So we're just going to go struct parse a scope entity entity equals color one size of struck parse scope
entity entity node equals node entity flags equals flags.
This is just an initial ICM stack offset equals stack offset.
And then we return the entity.
Now there's a final thing to do, guys.
If we look at paths of scope, now you can see down here paths the scope, new paths of scope, finish.
We're going to make another function under here.
It's just going to be called parse, scope, push.
And inside our paths of scope, push, we're going to accept a node and also a size.
So that will be like the variable size.
Okay.
And that will be the variable node.
All right.
So we should probably put var node there.
I'll keep it as node for now.
And yeah, what this is going to do, it's going to go scope push.
We're going to pass in the current process, the node and the size.
Okay, nice.
So yeah, if we look in scope, Percy, remember this just adjusts the total size after pushing this
to the vector.
So obviously this is important.
And yeah, if someone wants to pass a integer variable node here then would obviously set the size to
four and then there'd be four bytes pushed to the scope.
Okay, so that should be it.
To conclude this lecture, we now have some decent functionality in the plaza for us to create new scope
entities.
And yeah, next couple of lectures will start using them now to register actual variables that we encounter
on the stack.
So yeah.
Cool.
Thanks for watching.