update for ruby layer
This commit is contained in:
@ -11,12 +11,12 @@
|
||||
ruby. The argument is often made that
|
||||
typed languages are faster, but i don’t believe in that. I think dynamic languages
|
||||
just push more functionality into the “virtual machine” and it is in fact only the
|
||||
compiling to binaries that gives static languages their speed. This is the reason
|
||||
compilation to binaries that gives static languages their speed. This is the reason
|
||||
to compile ruby.
|
||||
%p.center
|
||||
= image_tag "layers.jpg" , alt: "Architectural layers"
|
||||
|
||||
%h3#ruby Ruby
|
||||
%h3#ruby Ast + Ruby
|
||||
%p
|
||||
To compile and run ruby, we first need to parse ruby. While parsing ruby is quite
|
||||
a difficult task, it has already been implemented in pure ruby
|
||||
@ -27,15 +27,15 @@
|
||||
%em Node
|
||||
class.
|
||||
Nodes have a type attribute (which you sometimes see in s-expressions) and a list of children.
|
||||
%p There are two basic problems when working with ruby ast: one is the a in ast, the other is ruby.
|
||||
%p
|
||||
Since an abstract syntax tree only has one base class, one needs to employ the visitor
|
||||
pattern to write a compiler. This ends up being one great class with lots of unrelated
|
||||
functions, removing much of the benefit of OO.
|
||||
The first layer in RubyX is the
|
||||
%b Ruby Layer
|
||||
that basically models the ast in a concrete syntax tree. This means there is one class
|
||||
per node type.
|
||||
%p
|
||||
The second, possibly bigger problem, is ruby itself: Ruby is full of programmer happiness,
|
||||
three ways to do this, five to do that. To simplify that, remove the duplication and
|
||||
make analyis easier, Vool was created.
|
||||
The Ruby layer is then used to transform the data into the Vool layer. Eg: Implicit
|
||||
block passing is made explicit, conditions are simplified, arguments are simplified,
|
||||
and syntactic sugar is removed.
|
||||
|
||||
%h3#virtual-object-oriented-language Virtual Object Oriented Language
|
||||
%p
|
||||
@ -45,8 +45,8 @@
|
||||
be targeted by several real languages.
|
||||
%p
|
||||
The main purpose is to simplify existing oo languages down to it’s core components: mostly
|
||||
calling, assignment, continuations and exceptions. Typed classes for each language construct
|
||||
exist and make it easier to transform a statement into a lower level representations.
|
||||
calling, assignment, continuations and exceptions. Typed classes for each language
|
||||
construct exist and are responsible to transform a statement into Mom level below.
|
||||
%p
|
||||
Examples for things that exist in ruby but are broken down in Vool are
|
||||
%em unless
|
||||
@ -67,12 +67,13 @@
|
||||
save state.
|
||||
%p
|
||||
Objects are typed, and are in fact the same objects the language operates on. Just the
|
||||
functionality is expressed through instructions. Methods are in fact defined (as vool) on classes
|
||||
and then compiled to Mom/Risc/Arm and the results stored in the method object.
|
||||
functionality is expressed through instructions. While source methods are in defined on
|
||||
classes as Vool, when they are compiled to binary, they are made type specific. These
|
||||
TypedMethods hold the binary and are stored in the Type.
|
||||
%p
|
||||
The Mom level exists to make the transition to Risc easier. It has a very abstract,
|
||||
high level instruction set, where each single instruction may resolve to many tens
|
||||
of lower level instructions. But it breaks down Vool's tree into an instruction
|
||||
high level instruction set, where each single instruction may resolve to many (even tens of)
|
||||
lower level instructions. But it breaks down Vool's tree into an instruction
|
||||
list, which is conceptually a much easier input for the next layer.
|
||||
|
||||
%h3#risc Risc
|
||||
@ -83,7 +84,7 @@
|
||||
The Risc machine has registers, indexed addressing, operators, branches and everything
|
||||
needed to implement Mom. It does not try to abstract every possible machine feature
|
||||
(like llvm), but rather “objectifies” the general risc view to provide what is needed for
|
||||
the Mom layer, the next layer up.
|
||||
the Mom layer, the next layer up (and actually Builtin functions).
|
||||
%p
|
||||
The machine has it’s own (abstract) instruction set, and the mapping to arm is quite
|
||||
straightforward. Since the instruction set is implemented as derived classes, additional
|
||||
|
Reference in New Issue
Block a user