make the tests run (and pass) again
This commit is contained in:
parent
4aca2caa05
commit
3659cb4b81
@ -1,15 +1,15 @@
|
||||
require 'parslet'
|
||||
|
||||
module Parfait
|
||||
eval(File.open("./lib/parfait/hash.rb").read)
|
||||
eval(File.open("./lib/parfait/hash.rb").read)
|
||||
end
|
||||
|
||||
require "ast/all"
|
||||
require "stream_reader"
|
||||
require "elf/object_writer"
|
||||
require 'salama-reader'
|
||||
require 'parser/transform'
|
||||
require "sof/all"
|
||||
require "salama-object-file"
|
||||
require "virtual/machine"
|
||||
require "register/register_machine"
|
||||
require "arm/arm_machine"
|
||||
require "ast/all"
|
||||
require_relative "stream_reader"
|
||||
|
@ -15,21 +15,21 @@ module Virtual
|
||||
# (ie garbage collection is reclaming, not destroying and recreating) although there may be a way to increase that number.
|
||||
#
|
||||
# The ast is transformed to virtaul-machine objects, some of which represent code, some data.
|
||||
#
|
||||
# The next step transforms to the register machine layer, which is what actually executes.
|
||||
#
|
||||
# The next step transforms to the register machine layer, which is what actually executes.
|
||||
#
|
||||
|
||||
# More concretely, a virtual machine is a sort of oo turing machine, it has a current instruction, executes the
|
||||
# instructions, fetches the next one and so on.
|
||||
# instructions, fetches the next one and so on.
|
||||
# Off course the instructions are not soo simple, but in oo terms quite so.
|
||||
#
|
||||
# The machine is virtual in the sense that it is completely modeled in software,
|
||||
#
|
||||
# The machine is virtual in the sense that it is completely modeled in software,
|
||||
# it's complete state explicitly available (not implicitly by walking stacks or something)
|
||||
|
||||
# The machine has a no register, but local variables, a scope at each point in time.
|
||||
# The machine has a no register, but local variables, a scope at each point in time.
|
||||
# Scope changes with calls and blocks, but is saved at each level. In terms of lower level implementation this means
|
||||
# that the the model is such that what is a variable in ruby, never ends up being just on the pysical stack.
|
||||
#
|
||||
#
|
||||
class Machine
|
||||
|
||||
def initialize
|
||||
@ -59,19 +59,9 @@ module Virtual
|
||||
syntax = @parser.parse_with_debug(bytes)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
main = Virtual::CompiledMethod.main
|
||||
expressions = parts.compile( main , self.message )
|
||||
parts.compile( main , self.message )
|
||||
end
|
||||
|
||||
|
||||
# run the instruction stream given. Instructions are a graph and executing means traversing it.
|
||||
# If there is no next instruction the machine stops
|
||||
def run instruction
|
||||
while instruction do
|
||||
next_instruction = instruction.next
|
||||
instruction.execute
|
||||
instruction = next_instruction
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
require_relative "type"
|
||||
require "parfait/message"
|
||||
require "parfait/frame"
|
||||
|
||||
module Positioned
|
||||
def position
|
||||
@ -9,7 +10,7 @@ module Positioned
|
||||
def set_position pos
|
||||
# resetting of position used to be error, but since relink and dynamic instruction size it is ok. in measures
|
||||
if @position != nil and ((@position - pos).abs > 32)
|
||||
raise "position set again #{pos}!=#{@position} for #{self}"
|
||||
raise "position set again #{pos}!=#{@position} for #{self}"
|
||||
end
|
||||
@position = pos
|
||||
end
|
||||
@ -19,7 +20,7 @@ module Virtual
|
||||
# our machine is made up of objects, some of which are code, some data
|
||||
#
|
||||
# during compilation objects are module Virtual objects, but during execution they are not scoped
|
||||
#
|
||||
#
|
||||
# So compiling/linking/assembly turns ::virtual objects into binary that represents ruby objects at runtime
|
||||
# The equivalence is listed below (i'll try and work on clearer correspondence later)
|
||||
# ::Virtual Runtime / parfait
|
||||
@ -65,7 +66,7 @@ module Virtual
|
||||
when Array , Symbol , String , Virtual::CompiledMethod , Virtual::Block , Virtual::StringConstant
|
||||
@@ARRAY
|
||||
when Hash
|
||||
@@HASH.merge :keys => object.keys , :values => object.values
|
||||
@@HASH.merge :keys => object.keys , :values => object.values
|
||||
when Virtual::BootClass
|
||||
@@CLAZZ
|
||||
when Virtual::BootSpace
|
||||
|
Loading…
Reference in New Issue
Block a user