rename c to register machine

This commit is contained in:
Torsten Ruger
2014-05-21 19:43:46 +03:00
parent 937f566b27
commit 46102e56ad
9 changed files with 24 additions and 24 deletions

View File

@ -91,7 +91,7 @@ module Vm
# b.variable = value looks like what it does, but actually generates
# an instruction for the block (mov or add)
#
# 2- any other method will be passed on to the CMachine and the result added to the block
# 2- any other method will be passed on to the RegisterMachine and the result added to the block
# With this trick we can write what looks like assembler,
# Example b.instance_eval
# mov( r1 , r2 )
@ -109,7 +109,7 @@ module Vm
return super
end
end
add_code CMachine.instance.send(meth , *args)
add_code RegisterMachine.instance.send(meth , *args)
end
end

View File

@ -22,7 +22,7 @@ module Vm
end
def do_call into
CMachine.instance.function_call into , self
RegisterMachine.instance.function_call into , self
end
end
end

View File

@ -12,7 +12,7 @@ module Vm
class Code
def class_for clazz
CMachine.instance.class_for(clazz)
RegisterMachine.instance.class_for(clazz)
end
# set the position to zero, will have to reset later

View File

@ -21,13 +21,13 @@ module Vm
class Program < Block
# Initialize with a string for cpu. Naming conventions are: for Machine XXX there exists a module XXX
# with a XXXMachine in it that derives from Vm::CMachine
# with a XXXMachine in it that derives from Vm::RegisterMachine
def initialize machine = nil
super("start" , nil)
machine = RbConfig::CONFIG["host_cpu"] unless machine
machine = "intel" if machine == "x86_64"
machine = machine.capitalize
CMachine.instance = eval("#{machine}::#{machine}Machine").new
RegisterMachine.instance = eval("#{machine}::#{machine}Machine").new
@context = Context.new(self)
#global objects (data)
@objects = []

View File

@ -22,7 +22,7 @@ module Vm
# Instructions work with options, so you can pass anything in, and the only thing the functions does
# is save you typing the clazz.new. It passes the function name as the :opcode
class CMachine
class RegisterMachine
# hmm, not pretty but for now
@@instance = nil

View File

@ -20,7 +20,7 @@ module Vm
# just a base class for data. not sure how this will be usefull (may just have read too much llvm)
class Value
def class_for clazz
CMachine.instance.class_for(clazz)
RegisterMachine.instance.class_for(clazz)
end
end
@ -53,7 +53,7 @@ module Vm
class Unsigned < Word
def plus block , unsigned
CMachine.instance.unsigned_plus self , unsigned
RegisterMachine.instance.unsigned_plus self , unsigned
end
end
@ -75,7 +75,7 @@ module Vm
end
def less_or_equal block , right
CMachine.instance.integer_less_or_equal block , self , right
RegisterMachine.instance.integer_less_or_equal block , self , right
end
def == other
code = class_for(CompareInstruction).new(self , other , opcode: :cmp)
@ -87,18 +87,18 @@ module Vm
class_for(LogicInstruction).new(nil , self , other , opcode: :sub )#, update_status: 1 )
end
def plus block , first , right
CMachine.instance.integer_plus block , self , first , right
RegisterMachine.instance.integer_plus block , self , first , right
end
def minus block , first , right
CMachine.instance.integer_minus block , self , first , right
RegisterMachine.instance.integer_minus block , self , first , right
end
def load block , right
CMachine.instance.integer_load block , self , right
RegisterMachine.instance.integer_load block , self , right
end
def move block , right
CMachine.instance.integer_move block , self , right
RegisterMachine.instance.integer_move block , self , right
end
end