move soml tests out, small cleanup
This commit is contained in:
parent
5ac14ddccc
commit
adca8b21c1
2
Gemfile
2
Gemfile
@ -1,7 +1,7 @@
|
|||||||
source "http://rubygems.org"
|
source "http://rubygems.org"
|
||||||
|
|
||||||
gem "salama" , :path => "."
|
gem "salama" , :path => "."
|
||||||
gem "ast" #, :github => "whitequark/ast"
|
gem "ast" , :github => "whitequark/ast" , branch: :master
|
||||||
|
|
||||||
gem "rake"
|
gem "rake"
|
||||||
gem "rye"
|
gem "rye"
|
||||||
|
10
Gemfile.lock
10
Gemfile.lock
@ -18,6 +18,13 @@ GIT
|
|||||||
ast (~> 2.1.0)
|
ast (~> 2.1.0)
|
||||||
parslet (~> 1.7.1)
|
parslet (~> 1.7.1)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/whitequark/ast.git
|
||||||
|
revision: 3814fb102af82a30bf334005ebe17332744f9dad
|
||||||
|
branch: master
|
||||||
|
specs:
|
||||||
|
ast (2.1.0)
|
||||||
|
|
||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
@ -31,7 +38,6 @@ GEM
|
|||||||
specs:
|
specs:
|
||||||
annoy (0.5.6)
|
annoy (0.5.6)
|
||||||
highline (>= 1.5.0)
|
highline (>= 1.5.0)
|
||||||
ast (2.1.0)
|
|
||||||
blankslate (3.1.3)
|
blankslate (3.1.3)
|
||||||
codeclimate-test-reporter (1.0.3)
|
codeclimate-test-reporter (1.0.3)
|
||||||
simplecov
|
simplecov
|
||||||
@ -108,7 +114,7 @@ PLATFORMS
|
|||||||
x64-mingw32
|
x64-mingw32
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
ast
|
ast!
|
||||||
codeclimate-test-reporter
|
codeclimate-test-reporter
|
||||||
guard
|
guard
|
||||||
guard-minitest
|
guard-minitest
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module Register
|
module Register
|
||||||
|
|
||||||
# Booting is a complicated, so it is extracted into this file, even it has only one entry point
|
# Booting is complicated, so it is extracted into this file, even it has only one entry point
|
||||||
|
|
||||||
class Machine
|
class Machine
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ module Register
|
|||||||
|
|
||||||
# helper to create a Type, name is the parfait name, ie :Type
|
# helper to create a Type, name is the parfait name, ie :Type
|
||||||
def type_for( name , ivars )
|
def type_for( name , ivars )
|
||||||
l = Parfait::Type.allocate.fake_init
|
l = Parfait::Type.allocate.compile_time_init
|
||||||
l.add_instance_variable :type , :Type
|
l.add_instance_variable :type , name
|
||||||
ivars.each {|n,t| l.add_instance_variable( n , t) }
|
ivars.each {|n,t| l.add_instance_variable( n , t) }
|
||||||
l
|
l
|
||||||
end
|
end
|
||||||
@ -97,7 +97,7 @@ module Register
|
|||||||
# meaning the lauouts have to be booted, @types filled
|
# meaning the lauouts have to be booted, @types filled
|
||||||
# here we pass the actual (ruby) class
|
# here we pass the actual (ruby) class
|
||||||
def object_with_type(cl)
|
def object_with_type(cl)
|
||||||
o = cl.allocate.fake_init
|
o = cl.allocate.compile_time_init
|
||||||
name = cl.name.split("::").last.to_sym
|
name = cl.name.split("::").last.to_sym
|
||||||
o.set_type @types[name]
|
o.set_type @types[name]
|
||||||
o
|
o
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
# may be added to any object at run-time.
|
# may be added to any object at run-time.
|
||||||
|
|
||||||
# An Object carries the data for the instance variables it has.
|
# An Object carries the data for the instance variables it has.
|
||||||
# The type lists the names of the instance variables
|
# The Type 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
|
||||||
|
|
||||||
module Parfait
|
module Parfait
|
||||||
class Class < Object
|
class Class < Object
|
||||||
|
@ -21,10 +21,11 @@ module Parfait
|
|||||||
# At compile time we fake memory by using a global array for pages
|
# At compile time we fake memory by using a global array for pages
|
||||||
def self.new *args
|
def self.new *args
|
||||||
object = self.allocate
|
object = self.allocate
|
||||||
#HACK, but used to do the adapter in the init, bu that is too late now
|
object.compile_time_init if object.respond_to?(:compile_time_init)
|
||||||
object.fake_init if object.respond_to?(:fake_init) # at compile, not run-time
|
|
||||||
# have to grab the class, because we are in the ruby class not the parfait one
|
# have to grab the class, because we are in the ruby class not the parfait one
|
||||||
cl = Space.object_space.get_class_by_name( self.name.split("::").last.to_sym)
|
cl = Space.object_space.get_class_by_name( self.name.split("::").last.to_sym)
|
||||||
|
|
||||||
# and have to set the type before we let the object do anything. otherwise boom
|
# and have to set the type before we let the object do anything. otherwise boom
|
||||||
object.set_type cl.instance_type
|
object.set_type cl.instance_type
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ module Parfait
|
|||||||
include Padding
|
include Padding
|
||||||
include Positioned
|
include Positioned
|
||||||
|
|
||||||
def fake_init
|
def compile_time_init
|
||||||
@memory = Array.new(16)
|
@memory = Array.new(16)
|
||||||
@position = nil
|
@position = nil
|
||||||
self # for chaining
|
self # for chaining
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# The Type allows the mapping of names to index.
|
# The Type allows the mapping of names to index.
|
||||||
|
|
||||||
# The Type of an object describes the memory layout of the object. In a c analogy, it is the
|
# The Type of an object describes the memory layout of the object. In a c analogy, it is the
|
||||||
# information defined in a struct.
|
# information defined in a struct.
|
||||||
# The Type is a list of the names of instance variables, and their value types (int etc).
|
# The Type is a list of the names of instance variables, and their value types (int etc).
|
||||||
#
|
#
|
||||||
# Every object has a Type to describe it, so it's *first* instance variable is **always**
|
# Every object has a Type to describe it, so it's *first* instance variable is **always**
|
||||||
@ -19,13 +19,19 @@
|
|||||||
# But Objects must also be able to carry methods themselves (ruby calls singleton_methods)
|
# But Objects must also be able to carry methods themselves (ruby calls singleton_methods)
|
||||||
# and those too are stored in the Type (both type and class include behaviour)
|
# and those too are stored in the Type (both type and class include behaviour)
|
||||||
|
|
||||||
# In other words, the Type is a list of names and value types that describe
|
# The object is an List of values of length n
|
||||||
# the values stored in an actual object.
|
|
||||||
# The object is an List of values of length n and
|
# The Type is a list of n names and n types that describe the values stored in an actual object.
|
||||||
# the Type is an List of names and value tpyes of length n ,
|
|
||||||
# plus class reference and methods reference
|
|
||||||
# Together they turn the object into a hash like structure
|
# Together they turn the object into a hash like structure
|
||||||
|
|
||||||
|
# For types to be a useful concept, they have to be unique and immutable. Any "change", like adding
|
||||||
|
# a name/type pair, will result in a new instance.
|
||||||
|
|
||||||
|
# The Type class carries a hash of types of the systems, which is used to ensure that
|
||||||
|
# there is only one instance of every type. Hash and equality are defined on type
|
||||||
|
# for this to work.
|
||||||
|
|
||||||
module Parfait
|
module Parfait
|
||||||
class Type < Object
|
class Type < Object
|
||||||
attribute :object_class
|
attribute :object_class
|
||||||
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
|||||||
class TestSpace < MiniTest::Test
|
class TestSpace < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@machine = Register.machine
|
@machine = Register.machine.boot
|
||||||
end
|
end
|
||||||
def classes
|
def classes
|
||||||
[:Kernel,:Word,:List,:Message,:Frame,:Type,:Object,:Class,:Dictionary,:Method , :Integer]
|
[:Kernel,:Word,:List,:Message,:Frame,:Type,:Object,:Class,:Dictionary,:Method , :Integer]
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
require_relative "soml/test_all"
|
|
||||||
|
|
||||||
require_relative "elf/test_all"
|
require_relative "elf/test_all"
|
||||||
|
|
||||||
require_relative "register/test_all"
|
require_relative "register/test_all"
|
||||||
|
Loading…
Reference in New Issue
Block a user