Implementing function prototypes in compiler intermediate representations requires creating a separate MIR construct that captures function signatures (name, parameters, return type) without body information, which involves careful plumbing across the compiler's data structures and passes to ensure proper handling during tree generation and code emission.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
studying compilers every day until i land a compiler role (day 191)Added:
And we're live. Okay.
Um hello all, hello world. This is day 191 of studying compilers every day until I land a compiler role.
Um sorry about yesterday. I I might have forgotten to do homework. So, I got that done and yeah, life is good. But yeah, that's why I didn't stream yesterday.
Um the day before that we started adding function prototypes and it turned out that was a little more difficult than we thought it would be. Um it actually takes a decent amount of plumbing. So, we ended up only doing like about half of the work maybe or maybe like a third of it.
Um this time hopefully we can get a larger portion done.
I'm not sure how much because I'm a little bit tired. So, I might have to take a later nap. So, we'll we'll see what happens, but yeah.
It's going to be a good time.
So, yeah. Let's let's get it right into right into tapping away.
Also, I have food. I have a bagel in front of me. So, I will be munching on that in the meantime as well cuz I'm also a little bit hungry.
Yeah, I'm I'm a little big and greedy.
So, yeah.
Uh get log. What were we working on?
Mhm.
We did ST to HR. We need to do HR to MR in some capacity now.
Um okay.
Mhm.
We did a lot of it already, I think.
Um the big problem is once again we don't have an MIR construct for uh for a prototype.
So, that's going to cause some problems, but we'll we'll re work Yeah.
We'll worry about that in a second.
Um mhm.
Just because I'm curious, I'm going to look at the back end real quick cuz I'm going to try and figure out what we need for MR to LR first.
Um if we need a lot for this then I will scope um I'll scope today's stream to be a little bit shorter, but um if it turns out to be pretty simple, um then I'll probably I'll probably try to get everything done in one sitting.
Uh what even goes in here?
We do those passes.
I guess mhm.
What is generate trees again?
Uh Okay, so we're we're going for function.
Mhm.
I guess we don't really need to do anything.
We might have to like change what a function is in MIR and then deal with the downstream effects, but I don't think we like really care a lot beyond that point.
Yeah, like as long as there's something for like a call to point to, um I think that should be fine.
So, I'm I think that like that actually cuts out a decent amount of the work that we need to do.
Um at least in the back end.
Mhm.
I don't even think we need to make these functions here because we're like re we're like de-control flow graphing the IR, right?
So, if we look in here in our tree gen, if we look at the calls that we have, it's like instruction call wherever that lives.
Please, hello.
There we are.
Yeah, so this just like this literally um I I I.
Uh this just takes like a this takes a name, which is a string.
Oh, bruh.
Oh my god.
The name is a new one.
Um yeah. So, since it just takes a name, I think we can kind of we can kind of just like dissolve the whole function prototype thing in the back end and we should be fine.
Uh we still need it in like MIR and we need to figure out HR to MR, but I think that's about it.
Um that's a pretty good state to be in, I think.
So, let's let's do MR first and then MR to um Yeah, let's do MR and then HR to MR should slide into place pretty easily.
Um and then from there, I think MR to LR should be pretty quick and then we're good to go.
Also, this bagel is this bagel is possibly good.
I'm kind of big and greedy right now.
Okay.
So, have the header on the right, the body on the left.
This whole thing is kind of messy. We're going to need to extend function again.
Uh what's going to cause us?
Yeah, I'm I'm eating. Hopefully you're doing all right.
All right. So, we go back to Godbolt for reference.
Uh let's see what LLVM calls its function prototype again.
I declare. That's what we want to do.
I opened my first live. Nice. Um how'd it go?
Okay, enough of me eating.
Um I'm going to lock in now. That That was that was a pretty funny experience.
Okay.
Um so, we have function definition.
It should extend public function.
Class function.
We want to do something with that.
Let's rename that.
Um and then we also want function declaration, I think, is what we call it. Declare.
Let's actually just yank that.
We just do that.
Okay.
So, we can kind of keep most of this.
Uh we definitely want a name regardless.
I think Yeah, the name is probably the only Actually, what happens if I get rid of the parameter?
I guess that also works.
I don't think we need much else than that here. So, we could probably I'm in live right now on this account.
Dumb. Well, um it it that's that is a choice.
Um yeah, I mean if you're if you're live, I would implore you to maybe not re-stream my stuff. I don't I don't know if that's what you're saying, but yeah.
Um okay. Let's let's lock in.
Um what what what is wrong with this? We need to make a virtual.
I guess this also means we have to like mess with a lot of our uh we have to mess with a lot of our other passes as well cuz they'll use function and we have something that's different from function now, which is going to be messy.
Um this is fine. This is fine.
I think they probably all have a type at least.
Mhm.
I guess not necessarily, huh? Or just to keep things consistent, I think we should do it like this.
And then we should do like that.
We can do that.
And this needs to override.
And we should yank that. We can probably just steal most of this.
Yeah, so type, name, parameters. Let's get rid of basic block stuff cuz we don't have basic blocks in this.
This is kind of just a name placeholder.
Um so we can keep all of that. I think we can just do ink that as well.
Okay.
So that's all good. Now let's throw this slop in here as well.
Uh we also need virtual.
Just uh we need a destructor.
Uh what language is this? This is C++.
I don't know. Do that.
Wait, what?
What do you mean override? We're not overriding anything. Right?
Public. Whoops. There we go. Much better.
Um all right. Let's Let's keep Let's keep throwing stuff at the wall here.
Um Let's make this declaration.
And here we need to fix those up again.
Do that.
Uh what Uh do you need to get Uh do you need to be really good at competitive programming to get into compilers? I have never done competitive programming.
Um if that's any consonance.
Uh what happened here?
Why is that Wait, why is this broken?
Wait, what?
Oh.
I see.
Okay, that That does make a mess. Okay.
Um hmm.
This is a function declaration, so that should be fine. Right?
Oh, wait.
Let's change that.
Um okay. Here we need to We need to make a mess, but we'll do it. Math blocks in C++ will suffice. Like Yes, insofar as like that will do for everything, right?
Like I don't know. I don't really think the question is particularly great cuz like I don't know. I don't I don't think it's something you can like really reduce to like a sec like a list of like qualities, right? Like There There is more to it than just like do you know XYZ things?
Uh but what do I know? I'm >> [snorts] >> I'm not the one with a job here, so like Yeah.
Uh let's let's yank all of that.
Uh we can probably just steal some of these slowly.
Um get name.
We can just yank that as well. We can yank that even.
There we go.
Okay, the two string we can kind of yank from above as well, to be honest. We just have to We can just like be a little bit looser with it, I'm fairly sure.
Uh we don't need that, I'm fairly sure.
Or actually no, we do kind of need that.
Wait, no we don't.
Yeah, we don't We definitely don't need the numbers.
Right? Cuz we can just do I32 I32. Okay, yeah.
We can do it like that then.
We can get rid of that.
Um oh, I guess we might want that anyway, huh? Or hmm.
The visitor doesn't make sense here, so we That's kind of fine, actually.
Uh we can change this up real quick. So this should be declare.
And get type and then we want to assemble that.
Uh we can do iter All right, how do we do this?
Iter get and then we want like get type.
Right, what's wrong with this? Oh, yeah, yeah.
And then we can do We can do this ugly thing again.
I don't know why.
I feel like there's a real I feel like there's a reason that I need to do it this ugly way.
What type is this again? Value of unique pointer.
So we want iter, we want arrow forget.
Okay, yeah. I guess that makes sense.
We could also just like do deref iter arrow get type, but I don't know. It's kind of It's kind of just doomed at least in that regard.
Um here I believe we can just call it at that.
We don't need the body at all.
Uh We can do that.
Okay.
Uh let's change surrounding quotes to single quotes for character.
Um now what else do we need to change?
We need to do this. Oh, man.
Um Hmm.
Yeah, maybe we should put type as a Hmm.
That might be smart, huh?
I guess we could also like move name around as well. Uh ger.
This is really dumb.
I'm not sure why I separated out like this. I might I might flatten it down in the future, but that will We'll worry about that in the future, I I guess.
I think that's It's a very regrettable choice, but we will We will figure it out why it's regrettable later.
Um Hmm.
Yeah, let's just let's just move this up.
Let's just paste that there. Let's paste that there.
We can do that.
This is not a regrettable choice at all.
Okay.
So that kind of should fix all of the MIR stuff, I think.
Uh we can find out when something breaks that it breaks.
I don't think instruction is really affected. Maybe like call will change.
I guess not really. It still takes a Uh wait.
No, it just takes a function pointer, so that should be fine.
Um two string had to change. I think the rest of this is also fine.
We might have to change some things here and there. Yeah.
Um oh, man.
So let's do Oh, no.
Okay, we're going to fix the We're going to fix the passes later cuz this is I fear this is going to be very annoying to deal with.
Actually, this one should probably be easy.
Uh so we want function or fun def or function declaration or I don't know.
definition So we can just do All right.
We can dynamic cast to MIR function.
Oh, yeah, yeah.
We'll do that.
And then uh And then we can just replace this with definition.
I guess.
What's wrong with that?
Whoops. Okay, can do that.
Okay, nice.
Oh man, we >> [sighs] >> we might have opened Pandora's Box with this.
This is kind of hell.
Um Okay.
Let's do that kind of thing here as well, I think.
You can just yank this as well.
Then we want after I get here instead.
We can just continue if it's not a definition.
Um Oh man.
I guess we could probably split this up by like function as well, right?
Yeah, actually that might be smart. Sort of like what we had here.
Yeah, let's let's refactor it to do that while we're at it. I think that would be smart.
Uh what's good is this?
Uh Okay, that's that's a I think I want to handle that refactor at a future time along with a lot of other things. So, we'll just leave that as is. Let's just continue with this.
Um and then instead of that, we can just do uh definition I guess.
Yeah, we can do it like that.
Um okay.
All right, that's all good. I'm sure there will be no problems in here whatsoever.
Oh man.
Um parallel copies Let's just Let's just go back here and yank what we had once again.
Um okay.
And that's all fine, I guess.
Any problems here? Yes, many problems.
Yeah, this we can yank from here again.
Yeah, this is just a lot of actually just a lot of boilerplate.
Okay.
What's wrong with this now?
Wait, what?
that we need to fix Oh no.
I'm so scared.
Um we might just have to narrow We might have to do a little bit of narrowing.
Um Oh man.
>> [sighs] >> Okay.
I'm I'm really starting to regret my choices about now.
Uh what is wrong with this though? This should be fine.
Uh this should be continue instead.
Okay, so we did need ranges.
What?
We did it We did need What was it?
Yeah, okay. I was just being pranked.
That's evil.
What did I need here as well?
I guess insert parallel has instruction, right?
No, wait, what?
This Wait, what?
Surely this needs it.
Yeah, we're just not going to mess with headers when there's errors, I guess.
Oh mem to reg. Oh, that's not going to be fun.
Uh let's do Let's do function definition.
Uh what's good?
Uh let's throw in the usual boilerplate again.
Yeah, I wish there was a better way to Maybe a macro to define that would be helpful, but oh well.
Um then here And do that. Everything's good.
We are happy until we aren't happy. Then we'll worry about it later.
Is this fine? This is not fine.
We're going to do the same thing again.
We're going to take the Yeah, I'm I'm like already going insane.
It was kind of dumb for me to not just like support this sooner, I think.
We can do that.
Okay.
Uh what's good, Grizzly?
Uh we need to do the same thing again.
Okay.
Um Man, okay.
Or maybe we could What even is get functions return?
It's a ref to that. We could just like make a list.
But I feel like that might that might suck a little bit. Or like a custom iterator.
Hm.
Yeah, maybe that Maybe that could be interesting.
But I don't know. We'll We'll worry about that once we get there.
For now, let's just make all this work.
Okay, that's all changed.
I think all of this should be fine.
There's something wrong here.
Oh yeah, okay. Um Yeah, these we might need to change from function to like the other type function that we have.
Do that as well.
Surely this does not cause issues whatsoever.
Right?
Uh what's good, Panda?
Uh how long have you been doing this?
What do you mean by doing?
I guess like I don't know.
>> [laughter] >> It's a little hard to define clearly, at least.
Um okay, so we want definition again.
Okay, nice.
What else do we need? I think I think that cleans up most of this. The passes are fine.
Um Hmm.
We should make like a pass register thing.
191 days obviously that's that's so real actually.
I I imagine that's not the answer that we wanted, but I guess that is an answer.
Um Yeah, there's stuff that's broken here.
This is the only place where that happens.
We'll worry about that in a second. For now let's let's take a step back.
Except that.
Uh update MIR to include prototype.
Let's call it declare.
Right?
Yeah, we're we're working off of what what LLVM called it.
Uh can you tell us why you don't code in Java cuz I don't want to use Java.
I would very much rather use a lot of other things that are not Java.
So yeah.
Let's Yeah, I will not be doing that.
Okay.
Um okay, let's let's see. So HR to MIR is now where we're at.
Um a lot of things have changed here now.
Oh man.
>> [sighs and gasps] >> This is this was such a bad idea. I don't know why I did this.
Um Okay, let's I think we did a dynamic casting somewhere here as well. We can youink.
We can do that maybe or we can even just do that.
No, okay. I guess I guess we need the HR name space there.
Um So then if prototype we can do something.
Just in case we'll wrap another dynamic cast.
Um let's youink all of that.
Um add both. That is a good idea. I'll do that in a second. Uh let me get let me get a little bit more of this done first.
What's wrong here? Oh, this needs to be arrow now.
Um let's continue let's continue doing this.
Oh my god, I cannot I cannot type right now.
Um let's see.
>> [sighs] >> What is wrong with this? Oh, function def definition.
Okay, and then we can we can kind of just youink all of this and then we can go from there.
So let's paste that up there like that.
Uh we want that still.
We do not care about that I'm fairly sure.
Right?
Oh, actually we do kind of care.
Yeah, we still care about this.
Uh this we do not care about though.
Yeah.
Um this should be prototype.
Uh can I connect on LinkedIn? Go for it.
Um I haven't checked LinkedIn in a second though. So I mean Oh, wait. I need to make the constructor. Okay, I'll do that in a second. Um Yeah, so that will have type name, params and then it will not have these two.
Like that I think.
Uh I don't think we need to do this.
Yeah, cuz we don't have basic blocks that we need to resolve.
Uh we need to update the HIR stuff real quick though.
Um I don't think a lot else needs to change though. This is this has been surprisingly peaceful.
Uh let's go back to middle end MIR.
What am I missing?
Constructor. Too peaceful? No, not really. I'm I'm quite content with how peaceful it is actually.
I'm very happy that it's not more aggressive right now.
Uh did I forget to Yeah, okay. I just completely forgot to add a constructor.
That's really funny.
Um We do that. Type name, parameters and then we don't need that.
And we don't need that.
Um Yeah, okay. So now we can youink that.
Where Where the the hell am I here?
Um Where is declaration?
Down here. There we go.
Give me his name and then parameters.
Stud move parameters.
Right?
Oh.
Like that. There we go.
Okay.
Wait, what?
Oh, I forgot to format. Um simplify CFG.
Let's re-commit that.
How would I forget the constructor? Lol.
Okay.
Um all right. So now prototypes.
Okay. So now we get to keep Let's make builds. Let's see what's broken right now.
Uh what?
My what?
Um okay, so HIR somewhere here.
Oh.
Uh this should have that unless I encoded it incorrectly.
It appears it should be correct cuz it has that.
Unless I forgot to implement it in prototype.
What?
>> Wait, what?
They might have just forgotten to implement it, I think.
Oh, I cannot search like that. Okay. Um Function prototype to string, hello?
Like it's it's right there.
What?
Are we blind or like what?
Oh, that doesn't make sense.
It's right here, like I don't understand why this is worked.
Oh, wait. Uh I need to deref it. So, I need to do like get and then arrow or arrow get.
Yeah, there we go. Um do you think being a tutor helps with being a CS student? I think it does.
Um I think it helps you better understand what's happening and I also think it helps you better explain what's happening.
Um both of which are very important in any industry setting cuz generally speaking you'll be working with people.
And part of the benefit of that is you will be like sharing ideas with each other, right? So, yeah, that's that's my initial thought at least.
Um that's not to say strictly necessary, but I think it at least gives you a very good opportunity um to do a little bit more of that internalization.
Um okay, so now we get to get to look at the back end.
So, let's actually something we should do.
More indirection.
Except I can't type, so there's a typo.
Which is fine.
Um Okay.
I'll play tomorrow. Yep, that sounds like a good plan.
Um okay, so this is in tree gen, which makes sense. This was the thing that we left as a to-do.
Um how old are you? I am I am younger than 30 years and I'm older than 20 years.
I will I will let you make your assumptions off of that.
Um okay, let's just make this function deck definition.
Oh, what's good, hacker? Good to see you.
Or pack or momo momo, I I think you I think you go by momo, right?
Oh, yeah. Good to see you.
Um okay, let's Where am I? Start function.
This should be deck definition, I think.
Yeah, okay.
Uh that fixes that problem.
And then where do we call that on?
We just not call that?
Uh okay, that makes sense.
Now, it's it's been a second.
Uh 25? No.
Yeah, you could you could probably put all the numbers in chat, but that's a little bit boring, so.
Um okay, what we want to do here, I think we want to we should split this up between definitions and declarations.
Um declarations, we just we don't really need to do anything for actually, I think.
Um older or younger than 25? Yes.
Something Not not really. It's just like why?
Like all all of the things you could possibly ask me about and like the the one that we land on is like age.
It's like I don't know. May maybe I'm like a little bit entitled to that opinion, but it's like I I don't know. That's like one of the things that like I think is generally better to not let float around, so like eh, I don't know.
Um Okay, so then if I'll just do definition.
Let's just dynamic cast to function Oh, we need we need more name spaces.
Do that. Let's give it.
This is or this should be dot. Whoops.
No worries, momo.
Uh what's good, friend of a gamer?
Uh also uh welcome, spy.
Uh what's wrong with this? Am I Oh, this needs to be a pointer.
Uh and then if not definition, then then you can continue.
No, it seems they found the Tampermonkey scripts. I mean, you got to like advertise it, right? Like it's not something that I think people generally um I don't think that's something that like people generally have spend time like searching for, right?
Like Like just because it's on a public site doesn't mean that like people will be looking it up.
Right? Like I could I could make a website that's public about like rolling an orange competitively or something and it would probably get zero traffic.
Or it would get plenty of traffic from bots, but like the main Tampermonkey site. Well, even still, right? Like who's like looking for the code specifically on that, right?
I feel like if you really want something to be visible or if that's something you care about, you probably need to put effort into like advertising it more explicitly.
Uh so, I want to know how much time you had to be in uh this advance in C++. I see. Um Well, to answer that question, uh it's less than 4 years. I technically took a like C++ intro class in my I think it's like 3 years ago now.
Um a little bit over 3 years ago, but I didn't like start properly writing like substantive C++ until like a little bit under a year ago, actually.
So, um I think a lot of this is is just like built up over time, at least. And just through I guess this project mostly, actually.
Um if we count lines of code in source, um yeah, like we're close to like we're approaching 10K lines of code, which is terrifying to think about.
Uh okay, let's change this up real quick.
And give it definition.
Let's give it that again.
Uh what's good, Nuresh?
It's been a second. Hopefully you've been doing all right.
Um Oh, yeah. Uh what is Rust good or should I avoid it? I think Rust is great. Uh if you have like a reason to use it, like I think it's I think it's great. If you don't have a reason to use it, I still think it's great and you should use it. Um I think it's just really powerful to be able to bracket out like memory related errors in general.
And the borrow checker is just very good.
Um How do you debug all that 10K lines? I don't.
When a when a bug comes up, there's a lot of digging around that occurs.
Uh what is clock? It's count lines of code.
20K lines. I guess I guess it's kind of like the Java experience.
Um let's see how to std vector in.
I'm not sure what you're asking. If you're talking about like using the stand the std namespace, I think it's fine to like have std prepended. I generally it's like something you want to do so you don't pollute the std namespace.
Um but I think like um readability-wise, I don't particularly care. I think the verbosity is not bad to have at least.
Um okay, that's not ideal.
What the hell?
What did we break?
Specify what you're using.
No, uh using stood necessarily says that like the current name space is the stood name space. So, polluting that is bad.
Uh why is your code just fold? If you're talking about these like line breaks, um it's the I my formatter enforces uh horizontal spacing. So, everything is less than 80 characters of width.
Which I believe is counted down here in the it's hidden by my camera.
It's counted down here in this corner.
Um it's generally good practice to not have your code like drift off too far. Um and it's also very useful if I have it like split screen, for instance.
Um cuz then if it gets like past this, then you have a horizontal scroll bar, and nobody likes that.
Okay. Um let's go debugging.
Lines of code is a terrible measure, yeah. Uh it is definitely not a great um I don't think it's a great metric, but um it's at least a metric.
100 characters? I think 80 is a good number at least. It if it's well on my screen.
It it works on my computer.
Wouldn't adding the using stood two pull, etc. be easier? Um possibly, but like I don't know. I don't think it's enough of a difference to really matter. I think it's good to specify that some that things come from the standard library.
Um there are some things where I like make an exception, cuz like back end is like truly miserable.
I'm going to do my homework that's due three weeks ago. Holy [ __ ] go do that.
Yeah, you should you should be like booted from the stream. You should You should just like do your homework. I I have booted myself from stream to do homework. I did that yesterday, so. Go do your homework.
Uh is carbon fox? Nah. I'm not in a very I'm not a very color scheme mood today.
Um okay, let's let's go debugging. Let's figure out where this is breaking.
I think I have an idea where.
This is in the parser proper.
I think.
Um So, all the preprocessor stuff is fine.
Um is your repo public now? It's been public for a bit. It's been public forever, actually. Um it should just be on my GitHub profile, which is in the description.
Um where is this breaking? Let's just Let's just Let's give it Let's give it call chain C.
And so, vertically, but like I don't know. It's I feel like it's generally more accepted to like keep the stood stuff on, at least.
Um also like I think using also like using just like generally makes a mess, and you should use it as conservatively as possible.
Um I'm not sure if it like I'm not sure if using stood two pull necessarily like makes the entire name space stood or not, but I would be concerned about that, at least.
I don't know. I feel like people care a lot about like what type of formatting looks the best, or like people care a lot about that in terms of like verbosity.
I don't really get it, personally.
I think just like as long as you have some semblance of like a format that like doesn't completely irritate you, it's fine. Like it's always going to irritate someone. You're eventually going to get irritated by it. As long as it's consistent, it's fine.
Um like there were some things that annoyed me, so I like I have like some changes in my like clang format. Like I can't live without like four space indent {slash} no tab indent.
Um and then like some small things here and there, but like aside from that, like LLVM formatter is like fine for me.
Um okay, we're going to do this.
Okay, let's first Valgrind.
Get irritated with clang warnings.
Um well, the warnings are a good thing. So, they they exist for a reason. Oh, no.
Oh man, okay.
Um pop scope.
So, this is in the parser, which I guess we could have figured out, but like still.
Uh this is in function, actually.
Uh what's wrong with this?
Uh what's Valgrind? It's actually the thing literally the thing tells you. Um by default, it's I think generally Valgrind is just like a memory error detector.
Um I'm just using it to print the stack trace.
Um but there's a bunch of other tools included in Valgrind.
Ah, full blind. Sorry.
Um tool suites.
Okay. So, this website is very poorly written, obviously.
Um but it has like cachegrind, which profiles your cache.
Um it has like callgrind, which also includes call graphs, so on and so forth. It's just like a bunch of like useful tools. Memcheck is the big one that people care about.
Congrats on 5K. Thank you. Yeah, you've you've been here for a while, so it's it's pretty cool to it's pretty cool to see that you've been here, at least.
Uh a lot of other people have like entered my life and exited my life since.
Um but you've you've been here for this entire duration, at least, which is pretty neat, if I do say so.
Uh what is wrong here?
Why is pop scope causing problems?
Is it an instruction, maybe?
That shouldn't be causing problems.
Maybe it's parsing it incorrectly, actually.
As I think about it.
Um hm Maybe our rule for it is incorrect.
Time to add Valgrind. That would be crazy.
Uh what's going to do? We're going to look in function again.
Uh this looks about correct.
Yeah, I don't really know what to do with this, at least.
Header should be fine. That shouldn't cause problems.
These should be fine.
You have an action for function. We have an action for prototype.
We have an action for param.
That should That should solve everything there.
I'm a merge clock. Uh yeah, I that's fair. I don't I don't think it's like particularly important. I only have it because like people have asked me how many lines of code I've written.
So, like it it's like truly just like a utility that I have because I got annoyed of like figure out other ways to solve the problem.
Um there's a way to check in Git, I think, but I don't think that's really that interesting.
Uh maybe it's at the top of the rule here.
Hm Um There might be something funky happening with the headers, now that I think about it. I don't think so, but there is a chance.
Oh, so we do the pectal try. So, that should be fine.
Maybe we could hm Maybe if we flip these around, it might be better.
And do this. That Ay ay ay.
What the hell did I do?
Do that, maybe.
Oh god, that looks so much uglier.
All right, let's see what happens when we do that.
Okay, that still quits.
When you're stuck in one line Uh that's that's really wide.
I don't really like that.
All right, so this order I think was fine to be honest.
Um okay, well, let's let's try to figure out what else could be breaking this.
All right, let's look at the test itself. What happens if we try this on a different test that isn't just call chain? Let's give it like uh parsing the parsing test.
Oh, that still fails. Okay.
Hmm.
Try to name things inside generic by using a type def. I see.
Um if you're asking about like this slush, um it's because the parser generator is a template only like uh is a template header only library.
So, this is kind of just how it's going to look for better or for worse.
Um Hmm.
What was I going to look at again?
Yeah, I guess where did I even go here?
Yeah, metaprogramming in C++ is insane.
I I'm kind of scared of it.
Um I've always been like trying to stray away from templates for that reason, but I should probably learn about them sooner than later cuz I'm going to run into some metaprogramming hell eventually.
Clang is a powerful, really? That's crazy.
Uh what's going on? Good to see you.
I've been doing all right.
Um hopefully you're doing well as well.
Man, I keep looking at every directory other than front end.
Um Hmm.
What is breaking?
I guess we can look at the preprocessed output as well. That could be interesting.
Although, that shouldn't cause any problems cuz it was working fine before.
Yeah, like that was that was perfectly fine.
Should make a note on your right side.
Um Yeah, maybe, but I'll select yeah.
I have I have like this neat little thing on this side, which is like very very more like broad, but yeah. I think it's like I don't know. It's It's like fine. I don't care enough.
Like some sometime wasting is fine. Like the fact I use Neovim automatically cancels out any possible time savings I could have gained.
So, um yeah, that's that's kind of an unfortunate fate.
Um So, we're trying to parse the function, but we're just not matching a scope somewhere, which means we're missing the Wait, what? No.
Hmm.
We're matching something wrong.
Function param active params, okay, that should be fine.
This all should be working at least.
Okay, let's Hmm.
Let's let's look at call chain. Let's uh question input call chain What if we just comment that out?
Then we try this again.
Still fails. Okay. So, that is like the smallest program that we can make and that fails.
Um Yeah, why why doesn't this work?
Hmm.
Do I have a double namespace guard?
Um I don't have a workspace.
I guess I have like some I have like some someone's to the guard like um all of my IRs have a second have an intermediate namespace, but like I don't really have like >> [snorts] >> I don't have like a full project workspace at least.
I don't know. I'm not making this at least with the intent of reuse for the most part. If if it comes to the point where I do need that then like we will we will handle that accordingly, but for the time being I haven't really planned on doing that.
Uh what is wrong with this?
This should be fine. I don't understand what could be going wrong here.
And the parser we wrapped it with this.
So, that should be fine.
We try to match the function before we do it and we try to match the prototype before we do it.
Can we just auto log it? What do you mean?
All right, so scope is empty.
So, this side Wait.
Wait, what?
Wait, so this this includes instruction, yes.
What?
Hmm.
I might have to pull out the forbidden LLM actually.
It might It might have to be done.
Oh, man.
I Hmm.
That might be a little Uh that might be a little easy, but I mean I'm I'm running out of ideas.
Okay, let's Claude.
Uh yoink.
Ideas ideas on how to debug this.
Why do you use code extension card within your workspace? Cuz I don't use it enough to justify it. I I prefer generally writing stuff by hand, but sometimes I'm a little bit in super hell, so this is kind of I don't I don't really have context.
Use AI to reflect.
Reflect your code into specs as markdown. What do you mean?
I'm I'm very LLM terse. Terse? Is that the word?
Whatever the whatever dense is close to.
Oh wait, so we are we are applying function.
So, you can check I don't I still don't really know what you're saying, to be honest.
I don't know. Like I just have not been a very big LLM guy in general.
But, sometimes I will I will be willing to like pull it out for uh certain debugging tasks, at least.
Like, maybe I'm just like completely misunderstanding what you're saying, but like you're going to have to like you might have to explain it to me like I'm a toddler.
Oh.
Wait, that should be fine then.
What the f- Okay, we we are just like we are just slop we're just generating slop now.
Ring markdown you check for objective. I see.
Like, I don't know. I'm not like very granular with it. I generally don't really plan things out a lot beyond just like this big picture stuff.
So, like I don't think that'd be really helpful for my workflow.
It also just seems like annoying and like one more dependency. So, like eh.
All right. Like, that just that sounds like a lot of work. Like, I like, why?
I I just like truly do not understand the the need for it, at least.
Like, am I insane for that take? Like I don't know.
Uh we'll just do that, and then like we'll go here.
Why isn't using namespace outside of namespace? Because I don't want to I don't want to stick pectol in front of everything.
Or I don't want to stick towel pectol in front of everything.
So uh where was this again? This is in utils.
So, we we redefine that, and then we just use the namespace here.
Oh my god, this this LLM [ __ ] is awful.
So, won't pollute? Yeah, but like eh.
This I don't know. I I feel like I had a reason for this. I don't remember what it was anymore.
What if I get rid of it?
I should I should just get rid of it, actually. Yeah.
I think it's because when I originally wrote my parser, I tried to deep I tried to like skip as much like random pectol slop as possible.
Um let's see if this builds.
If you need the the context where blah blah Like, I truly I don't know.
Like, it's it's slop regardless.
Yeah.
I don't know. I'm lazy. We're going to leave this here for now. We're going to kick the can down the road.
Um okay.
This should be fine.
Unless unless I just like mess something up here.
Welcome back, Momo.
Um I am I'm debugging template hell, which means I am I've given up, and I've just thrown it into an LLM.
This is this is the this is the point we've hit.
Now I can see the full picture. No, you can't.
Wait, what? What are we What?
That's all that's there.
Actually, what happens if we just nuke the rest of this?
Why not run cloud code? I'm too lazy to install it.
And I do not use it enough to really justify.
Does this work?
No, it's not. It's still cooked.
>> [sighs] >> Like, god for god forbid I try to be a Luddite. Like it can't like surely it's acceptable in some capacity.
Um hm.
Like, this should theoretically be fine.
What happens if I just get rid of this?
Don't tell me you have no static assert and assert spam? Nope.
Okay, so this is still broken.
Okay, wait. This is this is interesting now.
I think it is the list that's causing things to break.
Yeah, that's still breaking.
I think it is the list.
Hm.
We had like we had something that worked before. I forgot what it was.
We're just going to look at the history in GitHub.
Getting too rusty with it. That's so real. We love rust here.
Uh where does this live? Parser.
Oh, yeah. This is what the parser looked like before. It was one giant file of hell.
And now I split it up into like seven different files of hell.
Let's actually look in here.
Um it's in parser.
Uh uh Oh, this is too far.
Um Maybe we look here.
We just like rest files.
>> [sighs] >> I'm tired, guys.
Yeah, we just did packed all star function before.
Type service of viruses, that is unfortunate.
All right, my condolences.
And the way we defined function before was like really dumb as well, right?
Cuz we had to we had to appended ignorable.
Uh ignorable's already optional.
So, we could just do I would have actually packed all list. I think there's some really stupid uh some really stupid rule about lists that I'm missing somewhere.
Uh I guess not. I should be fine.
It's an actual sequence of R and then star of that. So, I should be fine.
All right, wait.
What?
Like this should be fine in theory.
How do we handle instruction again?
There's another big S or.
Uh what the hell?
That should be fine. I don't I don't know why this is barked.
Mm, this should be fine then.
Let's make this not optional.
This will break like the empty file, but I don't think we care about that right now.
Okay.
Okay, then it's probably not this then.
Mm, maybe Okay, so let's go So, we're just having an empty scope.
Which doesn't make sense.
Yeah, cuz we handle left brace and right brace rules here.
So, that should be fine.
Okay, we're just going to print debug this.
And I I can hear Spy already rolling over in his grave, but like Let's do that.
Do do do.
Let's do that.
Let's do that.
Uh this is this is fun.
Are you all enjoying this?
I'm enjoying this a lot less than I was half an hour ago.
Okay.
Um We're just not firing this rule at all.
What the hell?
Wait, what?
That should be working.
Maybe they need to be defined in the same place. That might be it actually.
Um Mm.
We might have to yank it from here.
But no, that should be fine.
We have my Discord alternative. Ooh.
That seems fun.
What happens if I just include core here?
All right, let's yank that.
Some type script. I mean like I guess it's a kind of fair though. There are like worse fates.
Uh what was I going to do? Valgrind.
Will this give us more interesting print output? I guess it will not.
Mm.
So, we're just not even calling it somehow.
We're matching a function without having triggered the rules.
Uh what's that error?
Uh what the hell?
That makes very little sense actually.
Oh, I lied. This makes This makes complete sense. I know why now. It's It's something so stupid.
Oh my god, I'm actually I'm so irritated.
Um Yeah, okay.
Um so, if we go back over to instruction, if we look at these rules, I think our rules are just wrong.
Um in function, we changed we changed this to um vector of unique pointer of function.
We have not changed it anywhere else.
So, we need to change that real quick.
Yeah, I I figured out what was wrong.
Yeah, we're going to need to need to do more clean up.
Uh what I missed? I I found the bug. I just forgot to change more things.
Uh let's do that.
Um none of this needs to change.
Yeah, I just had the rule wrong, which is very unfortunate.
Here I already changed it, I think.
Yeah.
Yeah, that's where I just changed it.
Here we need to do that. I think we also already changed it. Yeah, this we changed before.
Oh my god, that's so stupid.
I just forgot to change this when I updated my data structures, which is like fine.
Okay, so now if we save that and we try that, let's rebuild.
Supposedly this will work now.
And what a what an unfortunate way for that to have gone.
>> Yeah. So, now if we do this Okay, it works perfectly now.
Ah, that's so dumb. Okay, so let me make test now.
Let's see if this all works.
What do you mean supposedly?
Um If I If If that was the bug, then everything will work perfectly fine.
I'm like pretty confident that that was That was the issue.
Just some other template shenanigans that did not get caught by tooling.
Cuz templates make a mess for tooling.
It appears to have passed everything.
Okay. So, now we can add a prototype to the mix mix, I believe.
Um yeah, we don't have a prototype test.
So, let's add that.
Or actually, let's commit.
Um update MIR to LAR plus back-end data structures to use to support prototypes, I think. Question mark.
I could have just done get commit {dash} A {dash} AM, but that's fine.
Um What do we say?
Fix the damn action nested templates function signature.
FMCL.
Oh, more formatting.
Uh wait. What?
What file was it?
It was this one. Yeah, there we go.
Okay. [snorts] So, now let's write a test.
When I write a test, I mean we're just going to have a tiny shitty test.
Uh let's call this um What do I call it?
Hm.
Let's call it prototype.
We'll just do that. Let's see what happens.
Okay, that actually worked, it looks like.
Or emit AS2, whoops.
Okay, that's fine.
Okay, let's Let's give it HRR.
When will you use something that's more than prototype?
Um I mean, the fact that I have like a compiler that looks at or it compiles like some semblance of like reasonable programs.
Um Okay, the programs are like really boring that it supports. But like we have like basic Oh, it's a joke. I see. Okay.
I I'll get.
>> [laughter] >> I I might be a little bit dense. Um Oh, wait, this is Wait. Wait. Wait. Wait. That's not good.
Um Yeah, we can't be doing that. Wait.
Wait, there's there's an issue with this then.
Cuz this changes the name of the parameters. Like Does that matter?
I guess it doesn't really as long as it's consistent downwards.
Wait.
I guess nowhere in no like function signature ask definition does it require like the name the parameter names to be the same, right?
Just like the number and order, I think usually.
Does C require this?
Wait.
Surely that's fine, though.
Okay, this is what I'm interested in.
MIR.
Okay, well, I mean this is kind of boring, but like yeah, that works.
Um okay, so then it does go all the way.
So, that should be fine.
Okay, so then we can go to uh So, we can just test regression generate regression tests. We can update that.
I think that will just add test for prototype, if I had to guess.
Let's actually Let's actually kill that.
Let's Let's add more stuff to this.
We can just do that.
Um And then here we can also like include proto type.c.
Um This means we can also theoretically like make an actual interesting program now. We just need to like link the runtime library in some way.
Um I think I will just have to add it to like the build directories in some way, and then we can figure out what to do with that. But it is really cool that we're like so close to actually having a runtime library that works as well.
Um Uh let's Let's Let's like actually regenerate the regression tests now.
Um after this, let's commit, and then we will call it a day, I think.
We've We've done a lot. I think we've done a lot.
Many regs is always very slow.
Hm, wait.
Okay, nice.
Um new uh prototype test plus regenerate regression tests.
Okay.
I think this is a reasonable I guess hm We We have a second. We may as well try to Do you want to try to link it today, or do you want to just do that tomorrow?
Um Yeah, [ __ ] it. Let's Let's try it now.
Let's try to figure out what we would need to do, and then we'll actually do it next time.
So, we have this like runtime.c, which is a very stupid file, but this will do.
Um Yeah.
So, I think we need to add it specifically down here somewhere.
We need to add it to our CC stuff.
Um Wait, does linking happen before assembling, or does it go the other way?
Uh what's your Discord? Um It's My My username is like the same everywhere. Uh my Discord server is in the description, though.
Uh the invite's in the description, you should join.
Um everyone else should also join the Discord, if you haven't. Um because YouTube's notice suck, and that's like the best place to actually get pinged when I go live, compared to maybe YouTube doing it. So, I think I think that would be a good thing for y'all to do, if you haven't joined.
Uh what was I going to look up?
Linking or assembling first.
Hey, we link it We link it last. Okay.
Uh so, we We only include the runtime library in linking, I think, then.
Yeah, we want to do that.
Um okay, let's let's reorganize this a little bit.
See you there then? Yeah.
Yeah, we'll just do this next time. I think I think I'll call it a day then.
Um so next time so this is done.
We can like worry about the rest of this.
For now let's just like We'll we'll increment this for next time and then let's do get runtime library working plus linked.
Okay.
Yeah, I think I'm going to call it here then. Um thank you all so much for showing up today. If you haven't already like the stream and subscribe to the channel.
Um while you're down there check out the description. Uh my Discord is down there. I've already explained why you should join that. Um but also like it's surprisingly active for a small Discord.
Um everyone there is pretty chill.
Um while you're down there also uh my LinkedIn and GitHub are in the description. Feel free to add me on those and my GitHub sponsors is also there if you wish to give me money.
Um yeah, I'm going to go make more food now because I'm big and greedy today I guess for some reason. Um take care y'all.
Take it easy.
And I will see you all next time and we will we will get this we will get this done. It it will finish up.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











