IL logic is done

It’s about three weeks since my last blogging. Sorry for that, I know some of you pay big interest to my doings and how CoolBasic develops. That said, there’s a good reason why I’ve been so silent: I have been implementing some exciting new features and I didn’t want to write a wrap-up until all of them were fully done and things are actually working. As Pass#2 is closing to its end, every statement needs to be fully operational so that they can be transformed into IL. This also means that I had to define the missing constructors and other required methods, and implement special behaviour to where it’s needed. For example, strings and arrays tend to require some exceptional processing, mind you all of which is invisible to the user. Both arrays and strings work like a class internally, but syntax in BASIC-languages dictate simplier and cleaner standards to express them (as what comes to creating, initializing and using them). In addition, strings are fully managed, arrays are not. But more about those topics in future coming blog entries.

CoolBasic compiler now being at a stage where the IL is being generated basically means that every statement has now undergone their final parses. Remember when I talked about parsing and analyzing back in Pass#1? Well, this “parsing” continues also after the resolvers have been executed. Pass#1 merely certified that those lines were syntactically mostly correct and eliminated lots of extra work for Pass#2. Now that all possible data we need has been gathered and analyzed by earlier sub-processes of Pass#2 (and the rest of all syntax checks have been performed), all statements get their vital parts being isolated and ultimately converted into Intermediate Language. I just finished the last remaining IL logic parser which means that it’s time to focus on the actual IL. By “IL logic” I mean the way program flow control stuctures such as If…EndIf, For…Next, and Repeat…Until form their final “jump there – do that” labels and expressions. There’s still work to be done in order to finish IL creation.

Basically, expressions still need to be broken into simple instructions like stack push/pop and mathematical operator calls. And that’s the next task to do – finishing up the IL generation. This also includes the creation of class initializator and finalizator methods as well as generating the global and local variable spaces for classes. I hope that the compiler frontend is going to be finished at early summer. When that is done, I can start focusing on higher level CoolBasic language services such as linked lists of various sorts. My plan is to provide “somewhat complete” version for the closed alpha (to be announced at a later time).

So… lots of cool things have been added to the most recent development build of the compiler, lots of fixes and improvements have been made, and also lots of testing have been conducted as a side product of all these. Overall, everyting is looking bright at the moment, and no major problems have occurred so far. I’d like to conclude this blog post to the following code snippet:

Dim k As Integer = 5

If 1 + 2

	Dim i As Integer // This is a local variable that is only visible in *this* scope
	Dim k As Integer // Error! Local variable hides another local variable


If k

	Dim i As Integer // This is completely different variable "i"


i = 10 // Error! Variable "i" is not declared in this scope

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress