Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Objects can contain falsy slots now

  • Loading branch information...
commit 6b5ea458dc37bf91b4bd83aabb9c5186d200620c 1 parent ce183f9
@txus authored
View
411 kernel/test_case.nsc
@@ -336,7 +336,7 @@ t
n
n
i
-94
+106
58
37
19
@@ -355,7 +355,7 @@ i
1
1
8
-60
+66
7
2
64
@@ -371,64 +371,76 @@ i
4
1
13
-10
-47
-99
45
5
6
+49
7
+1
+9
+53
+99
+45
+8
+9
7
+10
47
49
-8
+11
2
15
13
7
-9
+12
64
13
20
0
49
-10
+13
2
49
-11
+14
2
15
5
5
7
-12
+15
49
4
1
13
-10
-82
-99
45
5
-13
+16
+49
7
-14
+1
+9
+94
+99
+45
+8
+17
+7
+18
47
49
-8
+11
2
15
13
79
49
-15
+19
2
7
-12
+15
12
49
-16
+20
2
11
I
@@ -443,7 +455,7 @@ I
1
n
p
-17
+21
s
E
8
@@ -469,6 +481,13 @@ x
3
get
x
+5
+Empty
+n
+x
+8
+kind_of?
+x
9
NameError
n
@@ -500,6 +519,7 @@ US-ASCII
10
assertions
n
+n
s
E
8
@@ -535,15 +555,15 @@ I
I
3f
I
-3c
+42
I
0
I
-3e
+44
I
41
I
-5e
+6a
n
p
1
@@ -571,7 +591,7 @@ t
n
n
i
-108
+120
58
37
19
@@ -600,7 +620,7 @@ i
2
1
8
-74
+80
7
3
64
@@ -616,22 +636,28 @@ i
5
1
13
-10
-57
-99
45
6
7
-7
+49
8
+1
+9
+63
+99
+45
+9
+10
+7
+11
47
49
-9
+12
2
15
13
7
-10
+13
64
13
20
@@ -641,43 +667,49 @@ i
35
2
49
-11
+14
2
49
-12
+15
2
15
5
5
7
-13
+16
49
5
1
13
-10
-96
-99
45
6
-14
+17
+49
+8
+1
+9
+108
+99
+45
+9
+18
7
-15
+19
47
49
-9
+12
2
15
13
79
49
-16
+20
2
7
-13
+16
12
49
-17
+21
2
11
I
@@ -692,7 +724,7 @@ I
2
n
p
-18
+22
x
11
noscript:==
@@ -721,6 +753,13 @@ x
3
get
x
+5
+Empty
+n
+x
+8
+kind_of?
+x
9
NameError
n
@@ -752,6 +791,7 @@ US-ASCII
10
assertions
n
+n
s
E
8
@@ -787,15 +827,15 @@ I
I
50
I
-4a
+50
I
0
I
-4c
+52
I
52
I
-6c
+78
n
p
2
@@ -829,7 +869,7 @@ t
n
n
i
-116
+140
7
0
64
@@ -841,67 +881,85 @@ i
2
1
13
-10
-24
-99
45
3
4
-7
+49
5
+1
+9
+30
+99
+45
+6
+7
+7
+8
47
49
-6
+9
2
15
5
7
-7
+10
49
2
1
13
-10
-44
-99
45
3
-8
-7
+11
+49
+5
+1
9
+56
+99
+45
+6
+12
+7
+13
47
49
-6
+9
2
15
5
7
-10
+14
49
2
1
13
-10
-64
-99
45
3
-11
+15
+49
+5
+1
+9
+82
+99
+45
+6
+16
7
-12
+17
47
49
-6
+9
2
15
13
49
-13
+18
1
35
3
49
-14
+19
2
19
0
@@ -910,40 +968,46 @@ i
0
13
49
-15
+20
1
15
5
7
-10
+14
49
2
1
13
-10
-103
-99
45
3
-16
+21
+49
+5
+1
+9
+127
+99
+45
+6
+22
7
-12
+17
47
49
-6
+9
2
15
13
45
-17
-18
+23
+24
56
-19
+25
49
-20
+26
1
49
-21
+27
2
11
I
@@ -958,7 +1022,7 @@ I
0
n
p
-22
+28
s
E
8
@@ -977,6 +1041,13 @@ x
3
get
x
+5
+Empty
+n
+x
+8
+kind_of?
+x
9
NameError
n
@@ -996,6 +1067,7 @@ US-ASCII
10
assertions
n
+n
s
E
8
@@ -1009,6 +1081,7 @@ US-ASCII
6
errors
n
+n
s
E
8
@@ -1025,6 +1098,7 @@ x
13
noscript:puts
n
+n
x
8
Function
@@ -1120,19 +1194,19 @@ I
I
59
I
-4c
+5e
I
5a
I
-53
+65
I
5b
I
-68
+80
I
5d
I
-74
+8c
n
p
1
@@ -1160,7 +1234,7 @@ t
n
n
i
-58
+70
5
7
0
@@ -1168,55 +1242,67 @@ i
1
1
13
-10
-20
-99
45
2
3
-7
+49
4
+1
+9
+26
+99
+45
+5
+6
+7
+7
47
49
-5
+8
2
15
5
45
-6
-7
+9
+10
56
-8
+11
49
-9
+12
1
49
-10
+13
2
15
5
7
-11
+14
49
1
1
13
-10
-53
-99
45
2
-12
+15
+49
+4
+1
+9
+65
+99
+45
+5
+16
7
-13
+17
47
49
-5
+8
2
15
5
49
-10
+13
1
11
I
@@ -1231,7 +1317,7 @@ I
0
n
p
-14
+18
s
E
8
@@ -1242,6 +1328,13 @@ x
3
get
x
+5
+Empty
+n
+x
+8
+kind_of?
+x
9
NameError
n
@@ -1269,7 +1362,7 @@ t
n
n
i
-114
+132
58
37
19
@@ -1290,7 +1383,7 @@ i
1
2
9
-112
+130
5
7
2
@@ -1298,90 +1391,108 @@ i
3
1
13
-10
-41
-99
45
4
5
-7
+49
6
+1
+9
47
-49
+99
+45
+7
+8
7
+9
+47
+49
+10
2
15
5
49
-8
+11
1
15
20
1
5
49
-8
+11
1
15
5
7
-9
+12
49
3
1
13
-10
-73
-99
45
4
-10
+13
+49
+6
+1
+9
+85
+99
+45
7
-11
+14
+7
+15
47
49
-7
+10
2
15
5
49
-8
+11
1
15
5
5
7
-12
+16
49
3
1
13
-10
-99
-99
45
4
-13
+17
+49
+6
+1
+9
+117
+99
+45
7
-14
+18
+7
+19
47
49
-7
+10
2
15
13
79
49
-15
+20
2
7
-12
+16
12
49
-16
+21
2
8
-113
+131
1
11
I
@@ -1396,7 +1507,7 @@ I
2
n
p
-17
+22
s
E
8
@@ -1416,6 +1527,13 @@ x
3
get
x
+5
+Empty
+n
+x
+8
+kind_of?
+x
9
NameError
n
@@ -1438,6 +1556,7 @@ US-ASCII
8
teardown
n
+n
s
E
8
@@ -1451,6 +1570,7 @@ US-ASCII
5
tests
n
+n
s
E
8
@@ -1478,27 +1598,27 @@ I
I
64
I
-2e
+34
I
65
I
-35
+3b
I
66
I
-4f
+5b
I
67
I
-70
+82
I
68
I
-71
+83
I
0
I
-72
+84
n
p
2
@@ -1527,6 +1647,7 @@ US-ASCII
12
print report
n
+n
s
E
8
@@ -1540,15 +1661,15 @@ I
I
62
I
-15
+1b
I
69
I
-21
+27
I
6b
I
-3a
+46
n
p
0
View
31 kernel/traits.nsc
@@ -151,7 +151,7 @@ t
n
n
i
-33
+39
58
37
19
@@ -165,24 +165,30 @@ i
1
1
13
-10
-26
-99
45
2
3
-7
+49
4
+1
+9
+32
+99
+45
+5
+6
+7
+7
47
49
-5
+8
2
15
13
20
0
49
-6
+9
2
11
I
@@ -197,7 +203,7 @@ I
1
n
p
-7
+10
s
E
8
@@ -208,6 +214,13 @@ x
3
get
x
+5
+Empty
+n
+x
+8
+kind_of?
+x
9
NameError
n
@@ -234,7 +247,7 @@ I
I
6
I
-21
+27
n
p
1
View
4 lib/noscript/compiler.rb
@@ -126,7 +126,7 @@ def visit_Identifier(o)
g.push_self
g.push_literal o.name
g.send :get, 1
- g.raise_if_nil NameError, "Object has no slot named #{o.name}"
+ g.raise_if_empty NameError, "Object has no slot named #{o.name}"
elsif o.self?
g.push_self
elsif s.slot_for(o.name)
@@ -209,7 +209,7 @@ def visit_SlotGet(o)
o.receiver.accept(self)
g.push_literal o.name
g.send :get, 1
- g.raise_if_nil NameError, "Object has no slot named #{o.name}"
+ g.raise_if_empty NameError, "Object has no slot named #{o.name}"
end
def visit_SlotAssign(o)
View
6 lib/noscript/generator.rb
@@ -8,12 +8,14 @@ def push_runtime
push_const :Runtime
end
- def raise_if_nil(exception_class, message)
+ def raise_if_empty(exception_class, message)
ok = new_label
done = new_label
dup
- git ok # goto the end if it's not nil
+ push_const :Empty
+ send :kind_of?, 1, false
+ gif ok # goto the end if it's not Empty
# Else, raise
push_rubinius
View
9 lib/noscript/runtime.rb
@@ -32,6 +32,9 @@ def noscript_send(name, *args)
noscript_def("respond to?") { |name| respond_to? "noscript:#{name}"}
end
+class Empty
+end
+
class Runtime
# Object protocol:
#
@@ -60,8 +63,8 @@ def initialize
noscript_def("each slot") do |*args|
fn = args.shift
- each do |name|
- fn.call(self, name.to_s, self[name])
+ to_a.each do |k, v|
+ fn.call(self, k.to_s, v)
end
end
@@ -97,7 +100,7 @@ def get(name)
elsif proto = prototype
proto.get(name)
else
- nil
+ Empty.new
end
end
View
2  lib/noscript/signature.rb
@@ -1,3 +1,3 @@
# This file is generated by `rake signature`. The signature
# is used to ensure that only current compiled files are loaded.
-Noscript::Signature = Rubinius::Signature ^ 18081691274476008924
+Noscript::Signature = Rubinius::Signature ^ 1377728806764044089
View
2  test/kernel/test_case_test.rb
@@ -36,7 +36,7 @@ def test_test_case
MyTestCase.run()
CODE
- expected = "\e[31mF\e[0m\e[32m.\e[0m\e[32m.\e[0m\e[32m.\e[0m\n\n\e[0m4 tests, 4 assertions, 1 failures\n * Expected false to be truthy.\n"
+ expected = "\e[32m.\e[0m\e[31mF\e[0m\e[32m.\e[0m\e[32m.\e[0m\n\n\e[0m4 tests, 4 assertions, 1 failures\n * Expected false to be truthy.\n"
assert_output expected do
compile(code)
end
Please sign in to comment.
Something went wrong with that request. Please try again.