fxes for add test
This commit is contained in:
parent
4a51bdd643
commit
9680ff2a71
4
Gemfile
4
Gemfile
@ -4,8 +4,8 @@ gem "salama" , :path => "."
|
||||
|
||||
gem "rake"
|
||||
|
||||
gem "salama-reader" , :github => "salama/salama-reader"
|
||||
#gem "salama-reader" , :path => "../salama-reader"
|
||||
#gem "salama-reader" , :github => "salama/salama-reader"
|
||||
gem "salama-reader" , :path => "../salama-reader"
|
||||
gem "salama-object-file" , :github => "salama/salama-object-file"
|
||||
#gem "salama-object-file" , :path => "../salama-object-file"
|
||||
gem "salama-arm" , :github => "salama/salama-arm"
|
||||
|
13
Gemfile.lock
13
Gemfile.lock
@ -10,13 +10,6 @@ GIT
|
||||
specs:
|
||||
salama-object-file (0.2.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/salama/salama-reader.git
|
||||
revision: 841592c667acea1e796f950851262e6938b231bc
|
||||
specs:
|
||||
salama-reader (0.2.0)
|
||||
parslet (~> 1.7.0)
|
||||
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
@ -24,6 +17,12 @@ PATH
|
||||
salama-object-file (~> 0.2)
|
||||
salama-reader (~> 0.2)
|
||||
|
||||
PATH
|
||||
remote: ../salama-reader
|
||||
specs:
|
||||
salama-reader (0.2.0)
|
||||
parslet (~> 1.7.0)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
|
@ -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
|
||||
|
@ -81,13 +81,22 @@ HERE
|
||||
check
|
||||
end
|
||||
|
||||
def ttest_function_ops_simple
|
||||
def test_function_ops_simple
|
||||
@string_input = <<HERE
|
||||
def foo()
|
||||
2 + 5
|
||||
end
|
||||
HERE
|
||||
@output = nil
|
||||
@output = [[Virtual::MethodEnter],[Virtual::MethodReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
def test_ops_simple
|
||||
@string_input = <<HERE
|
||||
2 + 5
|
||||
HERE
|
||||
@output = [[Virtual::MethodEnter , Virtual::Set,Virtual::NewMessage,Virtual::Set,
|
||||
Virtual::Set ,Virtual::Set,Virtual::Set,Virtual::MessageSend] , [Virtual::MethodReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user