fxes for add test
This commit is contained in:
@ -3,6 +3,14 @@ module Register
|
||||
module Builtin
|
||||
module Integer
|
||||
module ClassMethods
|
||||
def plus c
|
||||
plus_function = Virtual::MethodSource.create_method(:Integer,:plus , [Virtual::Integer] )
|
||||
plus_function.source.return_type = Virtual::Integer
|
||||
plus_function.source.receiver = Virtual::Integer
|
||||
plus_function.source.add_code Register::Math.new( plus_function, :add , 0 )
|
||||
|
||||
return plus_function
|
||||
end
|
||||
# The conversion to base10 is quite a bit more complicated than i thought.
|
||||
# The bulk of it is in div10
|
||||
# We set up variables, do the devision and write the result to the string
|
||||
|
@ -12,7 +12,7 @@ module Virtual
|
||||
if( r.value.is_a? Parfait::Class )
|
||||
class_name = r.value.name
|
||||
else
|
||||
raise "unimplemented #{r}"
|
||||
raise "unimplemented case in function #{r}"
|
||||
end
|
||||
else
|
||||
r = Self.new()
|
||||
|
@ -7,6 +7,10 @@ module Virtual
|
||||
@args = args
|
||||
end
|
||||
attr_reader :name , :me , :args
|
||||
|
||||
def to_s
|
||||
"MessageSend.new(:#{name} , #{me} , #{args})"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -134,6 +134,7 @@ module Virtual
|
||||
def compile_main bytes
|
||||
syntax = @parser.parse_with_debug(bytes)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
#puts parts.to_s
|
||||
Compiler.compile( parts , @space.get_main )
|
||||
end
|
||||
|
||||
|
@ -19,7 +19,7 @@ module Virtual
|
||||
if(ref.value)
|
||||
me = ref.value
|
||||
if( me.is_a? Parfait::Class )
|
||||
raise "unimplemented #{code}"
|
||||
raise "unimplemented #{code} me is #{me}"
|
||||
elsif( me.is_a? Parfait::Object )
|
||||
# get the function from my class. easy peasy
|
||||
puts "Me is #{me.class}"
|
||||
@ -31,6 +31,11 @@ module Virtual
|
||||
method = Virtual.machine.space.get_class_by_name(:Word).get_instance_method(code.name)
|
||||
raise "Method not implemented #{me.class}.#{code.name}" unless method
|
||||
new_codes << MethodCall.new( method )
|
||||
elsif( me.is_a? Fixnum )
|
||||
# get the function from my class. easy peasy
|
||||
method = Virtual.machine.space.get_class_by_name(:Integer).get_instance_method(code.name)
|
||||
raise "Method not implemented #{me.class}.#{code.name}" unless method
|
||||
new_codes << MethodCall.new( method )
|
||||
else
|
||||
# note: this is the current view: call internal send, even the method name says else
|
||||
# but send is "special" and accesses the internal method name and resolves.
|
||||
|
@ -27,6 +27,9 @@ module Virtual
|
||||
|
||||
attr_accessor :type , :value
|
||||
|
||||
def to_s
|
||||
"#{self.class.name}.new(#{type}, #{value})"
|
||||
end
|
||||
private #abstract base class
|
||||
|
||||
def initialize type , value
|
||||
|
Reference in New Issue
Block a user