update for ruby layer
This commit is contained in:
parent
07fcbc0a72
commit
4982710ac1
Binary file not shown.
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 109 KiB |
@ -24,7 +24,7 @@ Concrete Tree</panel_attributes>
|
|||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes><Ruby>
|
<panel_attributes><Ruby>
|
||||||
--
|
--
|
||||||
Abstract Tree</panel_attributes>
|
Concrete Tree</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
@ -37,8 +37,7 @@ Abstract Tree</panel_attributes>
|
|||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes><Mom>
|
<panel_attributes><Mom>
|
||||||
--
|
--
|
||||||
Concrete Tree
|
Linked List</panel_attributes>
|
||||||
+ Linked List</panel_attributes>
|
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
@ -47,7 +46,7 @@ Concrete Tree
|
|||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>250</y>
|
<y>250</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes><Risc>
|
<panel_attributes><Risc>
|
||||||
--
|
--
|
||||||
@ -58,7 +57,7 @@ Linked List</panel_attributes>
|
|||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>300</y>
|
<y>310</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
@ -71,13 +70,13 @@ Linked List</panel_attributes>
|
|||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>350</y>
|
<y>360</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes><Elf>
|
<panel_attributes><Elf>
|
||||||
--
|
--
|
||||||
Binary / Array</panel_attributes>
|
Parfait + Binary </panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
@ -85,11 +84,11 @@ Binary / Array</panel_attributes>
|
|||||||
<coordinates>
|
<coordinates>
|
||||||
<x>220</x>
|
<x>220</x>
|
||||||
<y>70</y>
|
<y>70</y>
|
||||||
<w>670</w>
|
<w>730</w>
|
||||||
<h>60</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>Ruby is parsed into and abstract syntax tree. "Abstract" means all nodes are
|
<panel_attributes>A Ruby layer modelled after the ast. This layer transforms ruby into the lower Vool
|
||||||
represented by one class. Compiling to Vool happens by visitor pattern.</panel_attributes>
|
layer, to simplify the input.</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
@ -97,12 +96,12 @@ represented by one class. Compiling to Vool happens by visitor pattern.</panel_a
|
|||||||
<coordinates>
|
<coordinates>
|
||||||
<x>220</x>
|
<x>220</x>
|
||||||
<y>130</y>
|
<y>130</y>
|
||||||
<w>670</w>
|
<w>730</w>
|
||||||
<h>60</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>Vool (Virtual object oriented Language) is ruby without the fluff. Just simple oo.
|
<panel_attributes>Vool (Virtual object oriented Language) is ruby without the fluff. Just simple oo.
|
||||||
Vool uses a concrete syntax tree, meaning one class per kind of statement.
|
Vool also uses a concrete syntax tree, meaning one class per kind of statement.
|
||||||
Code to compile to Mom is in the statement classes.
|
Vool is tranforms into Mom Instructions.
|
||||||
</panel_attributes>
|
</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
@ -111,12 +110,12 @@ Code to compile to Mom is in the statement classes.
|
|||||||
<coordinates>
|
<coordinates>
|
||||||
<x>220</x>
|
<x>220</x>
|
||||||
<y>190</y>
|
<y>190</y>
|
||||||
<w>670</w>
|
<w>730</w>
|
||||||
<h>60</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>Mom (Minimal object machine) is a very simple object oriented machine. It only deals in objects,
|
<panel_attributes>Mom (Minimal object machine) is a very simple object oriented machine. This means it has Instructions
|
||||||
incuding the calling convention. A first pass still uses a tree structure to represent control.
|
that get executed, and form a Linked List. It only deals in objects, incuding the calling convention.
|
||||||
The final representation is a list of instructions.</panel_attributes>
|
It transforms into Risc in a simple 1 to n manner.</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
@ -124,19 +123,20 @@ The final representation is a list of instructions.</panel_attributes>
|
|||||||
<coordinates>
|
<coordinates>
|
||||||
<x>220</x>
|
<x>220</x>
|
||||||
<y>250</y>
|
<y>250</y>
|
||||||
<w>670</w>
|
<w>730</w>
|
||||||
<h>50</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>The Risc (reduced intruction set computer) layer is an (sane) subset of ARM. It models only those
|
<panel_attributes>The Risc (reduced intruction set computer) layer is a (sane) subset of ARM. It models only those
|
||||||
instructions needed to implement Mom, about 20. It deals in memory, logic and jumps.</panel_attributes>
|
instructions needed to implement Mom, about 20. It deals in memory, logic and jumps, and has registers.
|
||||||
|
Transformation into ARM is mostly one to one.</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>220</x>
|
<x>220</x>
|
||||||
<y>300</y>
|
<y>310</y>
|
||||||
<w>670</w>
|
<w>730</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>The arm chip is the most sold/used in the world, so it is our first "target". Arm has a simple
|
<panel_attributes>The arm chip is the most sold/used in the world, so it is our first "target". Arm has a simple
|
||||||
@ -147,12 +147,38 @@ instruction set and we only use the part to implement what is used in Risc.</pan
|
|||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>220</x>
|
<x>220</x>
|
||||||
<y>350</y>
|
<y>360</y>
|
||||||
<w>670</w>
|
<w>730</w>
|
||||||
<h>50</h>
|
<h>60</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>The lowest level, achieved by assembling arm instructions, is binary code that a cpu can execute.
|
<panel_attributes>The lowest level, achieved by assembling arm instructions, is binary code that a cpu can execute.
|
||||||
Elf is used to wrap it into a file so Linux can start it. Elf includes debug info too.</panel_attributes>
|
The Binary is stored as Parfait objects that are then wrapped into Elf.
|
||||||
|
A simple (non-c) Elf file is created so Linux can start it.</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<id>UMLClass</id>
|
||||||
|
<coordinates>
|
||||||
|
<x>60</x>
|
||||||
|
<y>10</y>
|
||||||
|
<w>120</w>
|
||||||
|
<h>60</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes><Parser>
|
||||||
|
--
|
||||||
|
Abstract Tree</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<id>UMLClass</id>
|
||||||
|
<coordinates>
|
||||||
|
<x>220</x>
|
||||||
|
<y>10</y>
|
||||||
|
<w>730</w>
|
||||||
|
<h>60</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Ruby is parsed into and abstract syntax tree. "Abstract" means all nodes are
|
||||||
|
represented by one class. This is implemented by the parser gem.</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
</diagram>
|
</diagram>
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
ruby. The argument is often made that
|
ruby. The argument is often made that
|
||||||
typed languages are faster, but i don’t believe in that. I think dynamic languages
|
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
|
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.
|
to compile ruby.
|
||||||
%p.center
|
%p.center
|
||||||
= image_tag "layers.jpg" , alt: "Architectural layers"
|
= image_tag "layers.jpg" , alt: "Architectural layers"
|
||||||
|
|
||||||
%h3#ruby Ruby
|
%h3#ruby Ast + Ruby
|
||||||
%p
|
%p
|
||||||
To compile and run ruby, we first need to parse ruby. While parsing ruby is quite
|
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
|
a difficult task, it has already been implemented in pure ruby
|
||||||
@ -27,15 +27,15 @@
|
|||||||
%em Node
|
%em Node
|
||||||
class.
|
class.
|
||||||
Nodes have a type attribute (which you sometimes see in s-expressions) and a list of children.
|
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
|
%p
|
||||||
Since an abstract syntax tree only has one base class, one needs to employ the visitor
|
The first layer in RubyX is the
|
||||||
pattern to write a compiler. This ends up being one great class with lots of unrelated
|
%b Ruby Layer
|
||||||
functions, removing much of the benefit of OO.
|
that basically models the ast in a concrete syntax tree. This means there is one class
|
||||||
|
per node type.
|
||||||
%p
|
%p
|
||||||
The second, possibly bigger problem, is ruby itself: Ruby is full of programmer happiness,
|
The Ruby layer is then used to transform the data into the Vool layer. Eg: Implicit
|
||||||
three ways to do this, five to do that. To simplify that, remove the duplication and
|
block passing is made explicit, conditions are simplified, arguments are simplified,
|
||||||
make analyis easier, Vool was created.
|
and syntactic sugar is removed.
|
||||||
|
|
||||||
%h3#virtual-object-oriented-language Virtual Object Oriented Language
|
%h3#virtual-object-oriented-language Virtual Object Oriented Language
|
||||||
%p
|
%p
|
||||||
@ -45,8 +45,8 @@
|
|||||||
be targeted by several real languages.
|
be targeted by several real languages.
|
||||||
%p
|
%p
|
||||||
The main purpose is to simplify existing oo languages down to it’s core components: mostly
|
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
|
calling, assignment, continuations and exceptions. Typed classes for each language
|
||||||
exist and make it easier to transform a statement into a lower level representations.
|
construct exist and are responsible to transform a statement into Mom level below.
|
||||||
%p
|
%p
|
||||||
Examples for things that exist in ruby but are broken down in Vool are
|
Examples for things that exist in ruby but are broken down in Vool are
|
||||||
%em unless
|
%em unless
|
||||||
@ -67,12 +67,13 @@
|
|||||||
save state.
|
save state.
|
||||||
%p
|
%p
|
||||||
Objects are typed, and are in fact the same objects the language operates on. Just the
|
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
|
functionality is expressed through instructions. While source methods are in defined on
|
||||||
and then compiled to Mom/Risc/Arm and the results stored in the method object.
|
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
|
%p
|
||||||
The Mom level exists to make the transition to Risc easier. It has a very abstract,
|
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
|
high level instruction set, where each single instruction may resolve to many (even tens of)
|
||||||
of lower level instructions. But it breaks down Vool's tree into an instruction
|
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.
|
list, which is conceptually a much easier input for the next layer.
|
||||||
|
|
||||||
%h3#risc Risc
|
%h3#risc Risc
|
||||||
@ -83,7 +84,7 @@
|
|||||||
The Risc machine has registers, indexed addressing, operators, branches and everything
|
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
|
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
|
(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
|
%p
|
||||||
The machine has it’s own (abstract) instruction set, and the mapping to arm is quite
|
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
|
straightforward. Since the instruction set is implemented as derived classes, additional
|
||||||
|
Loading…
x
Reference in New Issue
Block a user