moved the whole parfait into its namespace/module

This commit is contained in:
Torsten Ruger 2015-05-11 18:55:49 +03:00
parent a552e3fbce
commit ab870e3323
13 changed files with 245 additions and 208 deletions

View File

@ -1,6 +1,6 @@
### Parfait: a thin layer ### Parfait: a thin layer
Parfait is the run-time of the vm. Parfait is the run-time of the **vm**.
To be more precise, it is that part of the run-time that can be expressed in ruby. To be more precise, it is that part of the run-time that can be expressed in ruby.
The run-time needs to contain quite a lot of functionality for a dynamic system. The run-time needs to contain quite a lot of functionality for a dynamic system.
@ -19,7 +19,7 @@ And thus parfait can be used at run-time.
It's too simple: just slips off the mind like a fish into water. It's too simple: just slips off the mind like a fish into water.
Parfait has a brother, the Builtin module. Builtin contains everything that can not be coded in ruby, Parfait has a brother, the Builtin module. Builtin contains everything that can not be coded in ruby,
but we stil need (things like array access). but we still need (things like array access).
#### Example: Message send #### Example: Message send
@ -42,3 +42,16 @@ Part of those are some that we just don't allow to be overridden.
Also what in ruby is object.send is Message.send in salama, as it is the message we are sending and Also what in ruby is object.send is Message.send in salama, as it is the message we are sending and
which defines all the data we need (not the object). The object receives, it does not send. which defines all the data we need (not the object). The object receives, it does not send.
### Vm vs language- core
Parfait is not the language (ie ruby) core library. Core library functionality differs between
languages and so the language core lib must be on top of the vm parfait.
Also Parfait is meant to be as thin as humanly possibly, so extra (nice to have) functionality
will be in future modules.
So the Namespace of the Runtime is actually Parfait (not nothing as in ruby).
Only in the require does one later have to be clever and see which vm one is running in and either
require or not. Maybe one doesn't even have to be so celver, we'll see (as requiring an existing
module should result in noop)

View File

@ -1,5 +1,7 @@
class Array < Object
module Parfait
class Array < Object
#many basic array functions can not be defined in ruby, such as #many basic array functions can not be defined in ruby, such as
# get/set/length/add/delete # get/set/length/add/delete
# so they must be defined as CompiledMethods in Builtin::Kernel # so they must be defined as CompiledMethods in Builtin::Kernel
@ -17,4 +19,5 @@ class Array < Object
# :min, :max, :minmax, :min_by, :max_by, :minmax_by, :member?, :each_with_index, :each_entry, # :min, :max, :minmax, :min_by, :max_by, :minmax_by, :member?, :each_with_index, :each_entry,
# :each_slice, :each_cons, :each_with_object, :chunk, :slice_before, :lazy # :each_slice, :each_cons, :each_with_object, :chunk, :slice_before, :lazy
end
end end

View File

@ -8,7 +8,9 @@
# The Layout lists the names of the instance variables # The Layout lists the names of the instance variables
# The class keeps a list of instance methods, these have a name and code # The class keeps a list of instance methods, these have a name and code
class Class < Module module Parfait
class Class < Module
# ruby 2.1 list (just for reference, keep at bottom) # ruby 2.1 list (just for reference, keep at bottom)
#:allocate, :new, :superclass #:allocate, :new, :superclass
end
end end

View File

@ -20,10 +20,12 @@
# Also at runtime Messages and Frames remain completely "normal" objects. Ie have layouts and so on. # Also at runtime Messages and Frames remain completely "normal" objects. Ie have layouts and so on.
# Which resolves the dichotomy of objects on the stack or heap. Sama sama. # Which resolves the dichotomy of objects on the stack or heap. Sama sama.
class Frame < Object module Parfait
class Frame < Object
def initialize locals , temps def initialize locals , temps
@locals = locals @locals = locals
@tmps = tmps @tmps = tmps
end end
attr_accessor :locals , :tmps attr_accessor :locals , :tmps
end
end end

View File

@ -1,6 +1,7 @@
# almost simplest hash imaginable. make good use of arrays # almost simplest hash imaginable. make good use of arrays
class Hash < Object module Parfait
class Hash < Object
def initialize def initialize
@keys = Array.new() @keys = Array.new()
@values = Array.new() @values = Array.new()
@ -68,5 +69,5 @@ class Hash < Object
# :group_by, :first, :all?, :any?, :one?, :none?, :min, :max, :minmax, :min_by, :max_by, :minmax_by, :each_with_index, # :group_by, :first, :all?, :any?, :one?, :none?, :min, :max, :minmax, :min_by, :max_by, :minmax_by, :each_with_index,
# :reverse_each, :each_entry, :each_slice, :each_cons, :each_with_object, :zip, :take, :take_while, :drop, :drop_while, # :reverse_each, :each_entry, :each_slice, :each_cons, :each_with_object, :zip, :take, :take_while, :drop, :drop_while,
# :cycle, :chunk, :slice_before, :lazy # :cycle, :chunk, :slice_before, :lazy
end
end end

View File

@ -7,7 +7,8 @@
# TODO how this idea works with Numeric ? # TODO how this idea works with Numeric ?
class Integer < Value module Parfait
class Integer < Value
# :integer?, :odd?, :even?, :upto, :downto, :times, :succ, :next, :pred, :chr, :ord, :to_i, :to_int, :floor, # :integer?, :odd?, :even?, :upto, :downto, :times, :succ, :next, :pred, :chr, :ord, :to_i, :to_int, :floor,
# :ceil, :truncate, :round, :gcd, :lcm, :gcdlcm, :numerator, :denominator, :to_r, :rationalize, # :ceil, :truncate, :round, :gcd, :lcm, :gcdlcm, :numerator, :denominator, :to_r, :rationalize,
@ -20,4 +21,5 @@ class Integer < Value
# :to_int, :real?, :integer?, :zero?, :nonzero?, :floor, :ceil, :round, :truncate, :step, :numerator, :denominator, # :to_int, :real?, :integer?, :zero?, :nonzero?, :floor, :ceil, :round, :truncate, :step, :numerator, :denominator,
# :quo, :to_c, :real, :imaginary, :imag, :abs2, :arg, :angle, :phase, :rectangular, :rect, :polar, :conjugate, :conj, # :quo, :to_c, :real, :imaginary, :imag, :abs2, :arg, :angle, :phase, :rectangular, :rect, :polar, :conjugate, :conj,
# :>, :>=, :<, :<=, :between? # :>, :>=, :<, :<=, :between?
end
end end

View File

@ -18,7 +18,8 @@
# the Layout is an array of names of length n # the Layout is an array of names of length n
# Together they turn the object into a hash like structure # Together they turn the object into a hash like structure
class Layout < Object module Parfait
class Layout < Object
# given a name as symbol, return the integer index of that entry # given a name as symbol, return the integer index of that entry
# we use 0 as "not found" as we don't want negatives, and can't raise # we use 0 as "not found" as we don't want negatives, and can't raise
@ -28,4 +29,5 @@ class Layout < Object
#internal implementation.... #internal implementation....
end end
end
end end

View File

@ -2,7 +2,8 @@
# A message is what is sent when you invoke a method. Args and stuff are packed up in to a Message # A message is what is sent when you invoke a method. Args and stuff are packed up in to a Message
# and the Message is sent to the receiver. # and the Message is sent to the receiver.
class Message < Object module Parfait
class Message < Object
def get_type_for(name) def get_type_for(name)
index = @layout.get_index(name) index = @layout.get_index(name)
@ -39,4 +40,5 @@ class Message < Object
method.call method.call
end end
end end
end
end end

View File

@ -11,7 +11,8 @@
# In fact this property is implemented in the Object, as methods # In fact this property is implemented in the Object, as methods
# may be added to any object at run-time # may be added to any object at run-time
class Module module Parfait
class Module
# :<, :<=, :>, :>=, :included_modules, :include?, :name, :ancestors, :instance_methods, :public_instance_methods, # :<, :<=, :>, :>=, :included_modules, :include?, :name, :ancestors, :instance_methods, :public_instance_methods,
# :protected_instance_methods, :private_instance_methods, :constants, :const_get, :const_set, :const_defined?, # :protected_instance_methods, :private_instance_methods, :constants, :const_get, :const_set, :const_defined?,
# :const_missing, :class_variables, :remove_class_variable, :class_variable_get, :class_variable_set, # :const_missing, :class_variables, :remove_class_variable, :class_variable_get, :class_variable_set,
@ -19,4 +20,5 @@ class Module
# :module_exec, :class_exec, :module_eval, :class_eval, :method_defined?, :public_method_defined?, # :module_exec, :class_exec, :module_eval, :class_eval, :method_defined?, :public_method_defined?,
# :private_method_defined?, :protected_method_defined?, :public_class_method, :private_class_method, :autoload, # :private_method_defined?, :protected_method_defined?, :public_class_method, :private_class_method, :autoload,
# :autoload?, :instance_method, :public_instance_method # :autoload?, :instance_method, :public_instance_method
end
end end

View File

@ -3,7 +3,8 @@
# that does lead to the fact that we have Reference functions on the Object though # that does lead to the fact that we have Reference functions on the Object though
class Object < Value module Parfait
class Object < Value
def get_type() def get_type()
OBJECT_TYPE OBJECT_TYPE
@ -32,4 +33,5 @@ class Object < Value
# #
# BasicObject # BasicObject
# :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__ # :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__
end
end end

View File

@ -8,6 +8,8 @@
# object. The smallest object is usually a cache line, 16 bytes or # object. The smallest object is usually a cache line, 16 bytes or
# an exponent of two larger. # an exponent of two larger.
class Page < Object module Parfait
class Page < Object
end
end end

View File

@ -8,8 +8,10 @@
# "New" is slightly misleading in that normal operation only ever # "New" is slightly misleading in that normal operation only ever
# recycles objects. # recycles objects.
class Space < Object module Parfait
class Space < Object
# ObjectSpace # ObjectSpace
# :each_object, :garbage_collect, :define_finalizer, :undefine_finalizer, :_id2ref, :count_objects # :each_object, :garbage_collect, :define_finalizer, :undefine_finalizer, :_id2ref, :count_objects
end
end end

View File

@ -12,7 +12,8 @@
# Value is an abstract class that unifies the "has a type" concept # Value is an abstract class that unifies the "has a type" concept
# Types are not "objectified", but are represented as integer constants # Types are not "objectified", but are represented as integer constants
class Value module Parfait
class Value
# to make the machine work, the constants need # to make the machine work, the constants need
# - to start at 0 # - to start at 0
@ -34,4 +35,5 @@ class Value
return Integer if( type == INTEGER_VALUE ) return Integer if( type == INTEGER_VALUE )
raise "invalid type" raise "invalid type"
end end
end
end end