Hello and welcome, everybody.
And in this lecture we are going to implement the upward stack offset.
Okay.
So if we just head to our past, see file paths of scope offset for stack function and we can start
implementing that.
So let's get rid of this and we're going to say size to stack addition equals zero.
And now we're going to head over to Node C because we need to create a function.
So just to the bottom of the file, we're going to say size T.
Function node argument stack addition.
That's going to take a node.
And we're going to assert that the node type is equal to a node type function.
And then we're going to return node func dogs, dot, stack addition and a copy and paste that in the
header file.
Just like that.
And now back to parse it out.
See, we can continue with our upward stack.
So we're just going to get rid of this.
And I'm going to say function node, argument, stack, addition, pause the current function.
And then we're going to say offset equals stack addition.
And then we're going to say if last entity offset equals data type size, variable node, last entity
node var type OC.
So that is for upward stack OC.
So essentially if we're in function arguments, for example, we'll get the stack addition from the
current function which will basically just return the argument stack addition, which is the minimum
it needs to add before it reaches the function arguments.
Right.
And then we set that as the starting offset as the default offset OC.
Now if there's no last entity, this means the offset is pointing to the first function variable on
the stack.
If there is a last empty, then we are further up than the first function argument.
So what we do is we get the data type size of the last entity type OC, which might be four, maybe
eight, and then that becomes the new offset.
And you can see here, this is equals, not a plus equals our.
Why is that?
Because down here in the last entity that will become true, which will grab the last entity absolute
offset OC.
So if we can imagine that the function node stack addition is eight OC, then obviously this is the
first let's pretend it's the first function argument.
Now that offset will be set to eight.
OC last bin also won't be run.
Yeah.
And then obviously when we come back around we get the last entity.
Let's pretend the function argument is in is an integer.
So that's four bytes.
So the offset is four.
We come in here last entity and then we plus on the eight taking us to the correct variable OC.
So that is the upward stack implemented.
Thanks for watching.