updated readme

This commit is contained in:
Torsten Ruger 2014-05-30 14:49:34 +03:00
parent 3156887a81
commit 513545f51b

View File

@ -1,10 +1,9 @@
Crystal
=======
#Crystal
Crystal is about native code generation in and of ruby. In is done.
Step 1 - Assembly
-----------------
### Step 1 - Assembly
Produce binary that represents code.
Traditionally called assembling, but there is no need for an external file representation.
@ -15,8 +14,8 @@ Most instructions are in fact assembling correctly. Meaning i have tests, and i
I even polished the dsl an so (from the tests), this is a valid hello world:
hello = "Hello World\n"
@program.main do
hello = "Hello World\n"
@program.main do
mov r7, 4 # 4 == write
mov r0 , 1 # stdout
add r1 , pc , hello # address of "hello World"
@ -24,11 +23,10 @@ I even polished the dsl an so (from the tests), this is a valid hello world:
swi 0 #software interupt, ie kernel syscall
mov r7, 1 # 1 == exit
swi 0
end
write(7 + hello.length/4 + 1 , 'hello')
end
write(7 + hello.length/4 + 1 , 'hello')
Step 2 -Link to system
----------------------
### Step 2 -Link to system
Package the code into an executable. Run that and verify it's output. But full elf support (including externs) is eluding me for now.
@ -37,13 +35,11 @@ Full rationale on the web (pages rep for now), but it means starting an extra st
Above Hello World can be linked and run. And will say its thing.
Step 2.1 -syscalls
------------------
### Step 3 - syscalls
Start implementing some syscalls and add the functionality we actually need from c (basic io only really)
Step 3 -Parse ruby
------------------
### Step 4 -Parse ruby
Parse simple code, using Parslet.
@ -52,8 +48,7 @@ expressions (including function definitions and calls) are starting to work.
I Spent some time on the parse testing framework, so it is safe to fiddle and add.
Step 4 - Vm: Compile the Ast
---------------------------
### Step 5 - Vm: Compile the Ast
Since we now have an Abstact syntax tree, it needs to be compiled to a machine Instruction format.
@ -69,8 +64,7 @@ and executed, gives the surprising output of "Hello World"
Time to add some meat.
Step 5 - Register allocation
----------------------------
### Step 6 - Register allocation
A first version of register allocation is done. I moved away from the standard c calling convention to pin a
type register and also not have passing and return overlapping.
@ -80,40 +74,52 @@ value and pass by value based.
As a side i got a return statement done now, and implicit return at the end has been working. Just making sure all
branches actually return implicitly is not done. But no rush there, as one can always write the return explicitly.
Step 6 - Basic type instructions
--------------------------------
### Step 7 - Basic type instructions
As we want to work on values, all the value methods have to be implemented to map to machine instructions.
Some are done, most are not. But they are straightforward.
Step 7 - Compound types
-----------------------
### Step 8 - Object creation
Move to objects, static memory manager, class, superclass, metaclass stuff
### Step 9 - Compound types
Arrays and Hash parse. Good. But this means The Actual datastructures should be implemented. AWIP ( a work in progress)
Step 8
------
Implement Core library of arrays/hash/string , memory definition and access
Implement classes, implement Core library of arrays/hash
### Step 10
Step 9
------
Implement Blocks, stack/external frames
Implement Blocks
### Step 11
Step 11
------
Implement Exceptions, frame walking
Implement Exceptions
Step 12
-------
### Step 12
Implement a way to call libc
Step 13
-------
### Step 13
Iterate from one:
1. more cpus (ie intel)
2. more systems (ie mac)
3. more syscalls, there are after all some hundreds
4. Ruby is full of nicities that are not done, also negative tests are non existant
5. A lot of modern cpu's functionality has to be mapped to ruby and implemented in assembler to be useful
6. Different sized machines, with different register types ?
7. on 64bit, there would be 8 bits for types and thus allow for rational, complex, and whatnot
8. Housekeeping (the superset of gc) is abundant
9. Any amount of time could be spent on a decent digital tree (see judy). Also better string/arrays would be good.
10. Inlining would be good
And generally optimize and work towards that perfect world (we never seem to be able to attain).
### Step 14
Celebrate New year 2030