On Wednesday, 8 January 2014 at 00:21:15 UTC, Mike wrote:
I'm sorry I can't share my code at the moment; I haven't decided yet where to put it. I was studying Adam Ruppe's minimal X86 port last night and found it most useful (Thumbs Up!), but with a 2000 line object.d, it's stretching the word "minimal", at least when compared with C. But if you really want all the cool stuff D has to offer, this is probably what will be required in the end.

Sorry if I'm late to reply, I'm barely following this thread, just poking in when I see me mentioned :)

But I started with a truly minimal D: the standalone file here was my first go <http://arsdnet.net/dcode/minimal.d> but indeed, that hits limits fast. I'd be ok with it as a "better C"... and the 3KB statically linked elf executable was awesome, but not even structs work, which takes a lot of fun out of things.

So I started adding stuff. Note that about 500 lines of the object.d in there aren't strictly needed, but since I had a custom druntime, I wanted to play a bit :)

Some things are needed so the compiler doesn't complain. Some stuff, typeinfo especially, are there so the linker doesn't complain.

Then classes and exceptions were a lot of code (which I copy/pasted from druntime). About line 900 - line 2000 are these. You could cut a *lot* of that out if you didn't want to use exceptions, but I like them so I wanted that to work. But exceptions need stack unwinding (BTW gdc uses a totally different stack unwinding thing, at least on ARM/raspberry pi. This is dmd's code) and classes so it kinda ballooned the size a bit.

I just fixed this to work with newer dmd btw.
http://arsdnet.net/dcode/minimal.zip

The executable was ~30 KB statically linked, and a good majority of the language worked. So I was pretty happy with that trade off. A lot of lines, but not a huge amount of bloat.



Anywho, let me get it back to the whole "minimal" thing....

But put a single struct and it complains
Error: TypeInfo not found. object.d may be incorrectly installed or corrupt, compile with -v switch


even with -betterC :-( :-( :-(


I don't even care about typeinfo; doing my own runtime, I'd be ok with any function that needs it to simply fail to compile. I can do it myself with templates.

Basic structs should really work regardless.


Even the switch...case statement seems to be, at least partially, implemented in the runtime

Yea, for strings. My thing did a stupid loop for string cases :P

If you don't try to use a string switch though, those references aren't emitted at all.

Reply via email to