Time for a monthly update. And what a month it's been...
The list of to-do's hasn't seen much progress, unfortunately:
Identifying iteration, selection and jump statements
Operator associativity and precedence
Type conversions
Byte code conversion to source code
Source code conversion to byte code
GUI
Setup new dev laptop (dropped current laptop last night, awaiting delivery of new one) 😢
Probably more stuff, but I don't know what I don't know, you know?
I was cursing my luck at having dropped my old laptop, but the timing couldn't have been any better. I got the new one right before deliveries started to be impacted due to COVID-19. Additionally, the laptop DOUBLED in price two weeks after I purchased mine. I won't be buying from that vendor again...
As for NCS byte code, the following progress has been made:
Identifying iteration statements (do-while, while, and for)
Identifying selection statements (if and switch)
Jump statements break and continue are still being worked on. Return is the only jump statement that is easily identified, because NWScript compiles each subroutine with only one RETN instruction. An NWScript function that has multiple returns:
Simply jumps from the basic block with the selection statement to the basic block that has the return.
In the category of "Probably more stuff", DarthParametric and I (and probably other people, fuzzy old man brain!) discovered another reason to replace DeNCS: it cannot decompile scripts that have global variables initialized by functions:
The example is perfectly valid code, but DeNCS doesn't like it. Replace GetStringByStrRef(32289) with a fixed string, e.g. "Amano's Test String", and DeNCS happily goes to work. The problem is not GetStringByStrRef() as DeNCS has no problem decompiling it inside functions. My decompiler isn't affected by this, but it's definitely something to be aware of.
A problem my current NCS analyzer does have is that I wasn't handling the STORE_STATE instruction correctly. My analyzer saw blocks of code as dead code, when in fact they were part of the STORE_STATE flow. I'll have to fix this.
I should be further along than this, but I've been sidetracked by:
A demanding client, one of the few still in business due to COVID-19 (I need the money)
My concern over weak healthcare and labor laws, which my country doesn't give a damn about (COVID-19 has made things really bad)
My family and friends, who are all older and dealing with health issues and in many cases still working face-to-face (COVID-19!!!)
My new obsession with assembly language, which I thought would help me with decompiling from NCS (it hasn't, and can't)
Learning parsing and lexing, which will allow this work in progress to compile to NCS
My new laptop, which allows me to play games that I haven't touched in months (I'm kind of stressed)
This girl I've been seeing 😘
The work continues...