Writing a (dis-)assembler for 8-bit code in D - blog posts

Imperatorn johan_forsberg_86 at hotmail.com
Fri Apr 23 09:43:30 UTC 2021


On Tuesday, 20 April 2021 at 17:58:07 UTC, Petar Kirov 
[ZombineDev] wrote:
> On Tuesday, 20 April 2021 at 15:37:25 UTC, Brian wrote:
>> On Tuesday, 20 April 2021 at 15:26:28 UTC, Petar Kirov 
>> [ZombineDev] wrote:
>>> Not sure if that's quite what you want, but you can use 
>>> [`pragma(msg, typeOrValueKnownAtCompileTime)`][1] [²][2] to 
>>> print stuff at CT.
>>
>> I suppose what I want to do is traverse the compiler's 
>> transformation of the mixin. The mixin page suggests it 
>> performs that work at semantic evaluation time.
>>
>> ~Brian
>
> `-vcg-ast` is your friend then! See for example: 
> https://run.dlang.io/is/RlX9Ks
>
> Other than using the compiler frontend as a library (which is 
> possible, but not yet straightforward), and the above mentioned 
> switch, the typical way most people check the generated code is 
> by simply printing the string that is being mixed-in (either at 
> compile-time with `pragma(msg)`, or at run-time). Unlike some 
> languages, where macros are essentially a separate language, in 
> D, if you can call a function at compile-time you can certainly 
> call it at run-time as well. So to check that 
> `mixin(generateSomeCode())` does what you want, you can simply 
> unit test `generateSomeCode` as usual.

D rox! How do we get more ppl to know about it? Is it because it 
can do "anything" and therefore ppl get suspicious? Like "that's 
not possible" (which can be partly true ofc).

I've only known D2 for about 2 years, and recently started 
writing real stuff in it. Imo, if we continue polishing D2 it 
will be awesome. (Then for those wanting a D3, fork it so you can 
make the changes without worrying about compact, then see if it 
could be made compatible).

For example, a conversion bw D1 and D2 could be done. And if we 
got a D3, the same thing could apply. The other way around is not 
as important imo.

Anyway, D roks


More information about the Digitalmars-d mailing list