reviving more tests
This commit is contained in:
@ -2,8 +2,13 @@ module Compiler
|
||||
|
||||
def self.compile expression , method , message
|
||||
exp_name = expression.class.name.split("::").last.sub("Expression","").downcase
|
||||
puts "Expression #{exp_name}"
|
||||
self.send "compile_#{exp_name}".to_sym , expression, method , message
|
||||
#puts "Expression #{exp_name}"
|
||||
begin
|
||||
self.send "compile_#{exp_name}".to_sym , expression, method , message
|
||||
rescue NoMethodError => e
|
||||
puts exp_name
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ module Compiler
|
||||
|
||||
# attr_reader :value
|
||||
def self.compile_integer expession , method , message
|
||||
int = Virtual::IntegerConstant.new(value)
|
||||
int = Virtual::IntegerConstant.new(expession.value)
|
||||
to = Virtual::NewReturn.new(Virtual::Integer , int)
|
||||
method.add_code Virtual::Set.new( to , int)
|
||||
to
|
||||
@ -41,14 +41,14 @@ module Compiler
|
||||
|
||||
# attr_reader :name
|
||||
# compiling name needs to check if it's a variable and if so resolve it
|
||||
# otherwise it's a method without args and a send is ussued.
|
||||
# otherwise it's a method without args and a send is usued.
|
||||
# this makes the namespace static, ie when eval and co are implemented method needs recompilation
|
||||
def self.compile_name expession , method , message
|
||||
return Virtual::Self.new( Virtual::Mystery ) if expession.name == :self
|
||||
if method.has_var(expession.name)
|
||||
message.compile_get(method , expession.name )
|
||||
else
|
||||
raise "Unimplemented #{self}"
|
||||
raise "TODO unimplemented branch #{expession.class}(#{expession})"
|
||||
message.compile_send( method , expession.name , Virtual::Self.new( Virtual::Mystery ) )
|
||||
end
|
||||
end
|
||||
|
@ -5,10 +5,10 @@ module Virtual
|
||||
# - the frame of the method that is executing (local variables): FrameSlot
|
||||
# - self as an object: SelfSlot
|
||||
# - a message that will be sent, NewMessageSlot
|
||||
|
||||
|
||||
# additionally frame, self and return are slots in Message and NewMessage
|
||||
|
||||
class Slot
|
||||
class Slot < Object
|
||||
MESSAGE_REGISTER = :r0
|
||||
SELF_REGISTER = :r1
|
||||
FRAME_REGISTER = :r2
|
||||
@ -31,7 +31,7 @@ module Virtual
|
||||
@value = value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class MessageSlot < Slot
|
||||
def initialize index , type = Mystery , value = nil
|
||||
super(index ,type , value )
|
||||
|
Reference in New Issue
Block a user