remove references to soml
This commit is contained in:
34
test/bench/typed/helper.rb
Normal file
34
test/bench/typed/helper.rb
Normal file
@ -0,0 +1,34 @@
|
||||
require_relative '../../typed/helper'
|
||||
|
||||
# Benchmarks for the stuff in results.md
|
||||
|
||||
module BenchTests
|
||||
|
||||
include RuntimeTests
|
||||
|
||||
def setup
|
||||
@stdout = ""
|
||||
@machine = Register.machine.boot
|
||||
# Typed::Compiler.load_parfait
|
||||
# most interesting parts saved as interger/word .soml in this dir
|
||||
end
|
||||
|
||||
def main
|
||||
runko = <<HERE
|
||||
class Object
|
||||
int main()
|
||||
PROGRAM
|
||||
end
|
||||
end
|
||||
HERE
|
||||
runko.sub("PROGRAM" , @main )
|
||||
end
|
||||
|
||||
def check_remote val
|
||||
check_r val , true
|
||||
end
|
||||
|
||||
def connected
|
||||
make_box
|
||||
end
|
||||
end
|
43
test/bench/typed/integer.rb
Normal file
43
test/bench/typed/integer.rb
Normal file
@ -0,0 +1,43 @@
|
||||
require_relative 'helper'
|
||||
|
||||
class BenchInt < MiniTest::Test
|
||||
include BenchTests
|
||||
|
||||
def test_adds
|
||||
@main = "int count = 100352 - 352
|
||||
while_plus( count - 1)
|
||||
40.fibw( )
|
||||
count = count - 1
|
||||
end
|
||||
return count"
|
||||
check_remote 0
|
||||
end
|
||||
|
||||
def test_calls
|
||||
@main = "int count = 1000
|
||||
while_plus( count - 1)
|
||||
20.fibr( )
|
||||
count = count - 1
|
||||
end
|
||||
return count"
|
||||
check_remote 0
|
||||
end
|
||||
|
||||
def test_itos
|
||||
@main = "int count = 100352 - 352
|
||||
while_plus( count - 1)
|
||||
count.to_s( )
|
||||
count = count - 1
|
||||
end
|
||||
return count"
|
||||
check_remote 0
|
||||
end
|
||||
def test_loop
|
||||
@main = "int count = 100352 - 352
|
||||
while_plus( count - 1)
|
||||
count = count - 1
|
||||
end
|
||||
return count"
|
||||
check_remote 0
|
||||
end
|
||||
end
|
88
test/bench/typed/integer.soml
Normal file
88
test/bench/typed/integer.soml
Normal file
@ -0,0 +1,88 @@
|
||||
class Integer < Value
|
||||
|
||||
int as_char()
|
||||
if_plus( self - 9)
|
||||
return 32
|
||||
else
|
||||
return 48 + self
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
int div10_typed()
|
||||
int tmp = self >> 1
|
||||
int q = self >> 2
|
||||
q = q + tmp
|
||||
tmp = q >> 4
|
||||
q = q + tmp
|
||||
tmp = q >> 8
|
||||
q = q + tmp
|
||||
tmp = q >> 16
|
||||
q = q + tmp
|
||||
q = q >> 3
|
||||
int r = q * 10
|
||||
r = self - r
|
||||
r = r + 6
|
||||
r = r >> 4
|
||||
return q + r
|
||||
end
|
||||
|
||||
Word as_string(Word str)
|
||||
if_minus( self - 10 )
|
||||
int num = as_char()
|
||||
str = str.push_char( num )
|
||||
else
|
||||
int rest = self.div10()
|
||||
str = rest.as_string( str )
|
||||
rest = rest * 10
|
||||
rest = self - rest
|
||||
str = rest.as_string(str)
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
Word to_s()
|
||||
Word start = " "
|
||||
start.set_length(0)
|
||||
return as_string( start )
|
||||
end
|
||||
|
||||
int puti()
|
||||
Word str = self.to_s()
|
||||
str.putstring()
|
||||
return self
|
||||
end
|
||||
|
||||
int mod4()
|
||||
return self & 3
|
||||
end
|
||||
|
||||
int fibr( )
|
||||
if_plus( self - 2 )
|
||||
int tmp
|
||||
tmp = self - 1
|
||||
int a = tmp.fibr( )
|
||||
tmp = self - 2
|
||||
int b = tmp.fibr( )
|
||||
return a + b
|
||||
else
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
int fibw( )
|
||||
int result = 1
|
||||
int a = 0
|
||||
int b = 1
|
||||
int i = 2
|
||||
while_plus( self - i )
|
||||
result = a + b
|
||||
a = b
|
||||
b = result
|
||||
i = i + 1
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
end
|
17
test/bench/typed/object.soml
Normal file
17
test/bench/typed/object.soml
Normal file
@ -0,0 +1,17 @@
|
||||
class Object
|
||||
|
||||
Type get_type()
|
||||
return self.type
|
||||
end
|
||||
|
||||
Class get_class()
|
||||
Type l = self.type
|
||||
return l.object_class
|
||||
end
|
||||
|
||||
Word get_class_name()
|
||||
Type l = self.type
|
||||
Class c = l.object_class
|
||||
return c.name
|
||||
end
|
||||
end
|
18
test/bench/typed/word.rb
Normal file
18
test/bench/typed/word.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require_relative 'helper'
|
||||
|
||||
class BenchWord < MiniTest::Test
|
||||
include BenchTests
|
||||
|
||||
def test_hello
|
||||
@main = <<HERE
|
||||
int count = 100352 - 352
|
||||
Word hello = "Hello there"
|
||||
while_plus( count - 1)
|
||||
hello.putstring()
|
||||
count = count - 1
|
||||
end
|
||||
return 1
|
||||
HERE
|
||||
check_remote 1
|
||||
end
|
||||
end
|
29
test/bench/typed/word.soml
Normal file
29
test/bench/typed/word.soml
Normal file
@ -0,0 +1,29 @@
|
||||
class Word < Object
|
||||
|
||||
int _internal_index(int index)
|
||||
return index + 11
|
||||
end
|
||||
|
||||
int get_char_at(int index)
|
||||
index = _internal_index(index)
|
||||
return get_internal_byte(index)
|
||||
end
|
||||
|
||||
int set_length(int i)
|
||||
set_internal_word( 2 , i)
|
||||
return i
|
||||
end
|
||||
|
||||
int set_char_at( int index , int val)
|
||||
index = _internal_index(index)
|
||||
return set_internal_byte(index , val)
|
||||
end
|
||||
|
||||
Word push_char(int char)
|
||||
int index = self.char_length + 1
|
||||
self.set_length(index)
|
||||
|
||||
set_char_at(index , char)
|
||||
return self
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user