2015-05-12 08:54:36 +02:00
|
|
|
require "parfait/value"
|
|
|
|
require "parfait/object"
|
|
|
|
require "parfait/module"
|
|
|
|
require "parfait/class"
|
2015-05-12 18:10:45 +02:00
|
|
|
require "parfait/dictionary"
|
|
|
|
require "parfait/list"
|
2015-05-13 15:06:38 +02:00
|
|
|
require "parfait/word"
|
2015-05-12 08:54:36 +02:00
|
|
|
require "parfait/message"
|
|
|
|
require "parfait/frame"
|
2015-05-12 14:36:44 +02:00
|
|
|
require "parfait/space"
|
2015-05-12 13:58:29 +02:00
|
|
|
|
|
|
|
# Below we define functions (in different classes) that are not part of the run-time
|
|
|
|
# They are used for the boot process, ie when this codes executes in the vm that builds salama
|
|
|
|
|
|
|
|
# To stay sane, we use the same classes that we use later, but "adapt" them to work in ruby
|
|
|
|
# This affects mainly memory layout
|
|
|
|
|
|
|
|
module FakeMem
|
|
|
|
def initialize
|
|
|
|
@memory = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-15 15:45:36 +02:00
|
|
|
module Parfait
|
|
|
|
class Object
|
|
|
|
include FakeMem
|
|
|
|
def self.new_object *args
|
|
|
|
#puts "I am #{self}"
|
|
|
|
object = self.new(*args)
|
|
|
|
object
|
|
|
|
end
|
|
|
|
def internal_object_length
|
|
|
|
@memory.length
|
|
|
|
end
|
|
|
|
def internal_object_get(index)
|
|
|
|
@memory[index]
|
|
|
|
end
|
|
|
|
def internal_object_set(index , value)
|
|
|
|
@memory[index] = value
|
|
|
|
end
|
|
|
|
def internal_object_grow(index)
|
|
|
|
@memory[index] = nil
|
|
|
|
end
|
2015-05-12 17:52:01 +02:00
|
|
|
end
|
2015-05-15 15:45:36 +02:00
|
|
|
class Parfait::Class
|
2015-05-12 17:52:01 +02:00
|
|
|
end
|
2015-05-15 15:45:36 +02:00
|
|
|
class Parfait::List
|
|
|
|
def length
|
|
|
|
internal_object_length
|
|
|
|
end
|
2015-05-12 13:58:29 +02:00
|
|
|
end
|
2015-05-14 19:39:12 +02:00
|
|
|
|
2015-05-15 15:45:36 +02:00
|
|
|
# Functions to generate parfait objects
|
|
|
|
def self.new_word( string )
|
|
|
|
string = string.to_s if string.is_a? Symbol
|
|
|
|
word = Parfait::Word.new( string.length )
|
|
|
|
string.codepoints.each_with_index do |code , index |
|
|
|
|
word.set_char(index , code)
|
2015-05-14 19:39:12 +02:00
|
|
|
end
|
|
|
|
word
|
|
|
|
end
|
|
|
|
end
|