Permalink
Browse files

Add toplevel constant Ruby for interoperativity

  • Loading branch information...
1 parent bf85794 commit e465c9dcb28390e61f552821e2e77d358f419b7d @txus committed Jan 27, 2012
Showing with 65 additions and 32 deletions.
  1. +9 −6 kernel/test_case.nsc
  2. +26 −23 kernel/traits.nsc
  3. +4 −0 lib/noscript/ast.rb
  4. +6 −2 lib/noscript/compiler.rb
  5. +1 −1 lib/noscript/signature.rb
  6. +19 −0 test/interop_test.rb
View
@@ -7,7 +7,7 @@ n
n
n
i
-159
+161
45
0
1
@@ -158,13 +158,15 @@ i
49
30
2
-44
+45
+0
+31
12
7
-31
+32
12
49
-32
+33
2
11
I
@@ -179,7 +181,7 @@ I
0
n
p
-33
+34
x
7
Runtime
@@ -1674,6 +1676,7 @@ p
x
14
noscript:clone
+n
s
E
8
@@ -1738,7 +1741,7 @@ I
I
6c
I
-9f
+a1
x
45
/Users/txus/Code/noscript/kernel/test_case.ns
View
@@ -7,7 +7,7 @@ n
n
n
i
-74
+76
45
0
1
@@ -35,51 +35,53 @@ i
49
8
2
-44
+45
+0
+9
12
7
6
12
49
-9
+10
2
15
45
0
-10
+11
43
2
7
-11
-45
12
+45
13
-56
14
-49
+56
15
-1
49
16
+1
+49
+17
2
15
45
0
-17
-43
18
-7
+43
19
-45
-12
+7
20
-56
+45
+13
21
+56
+22
49
-15
+16
1
49
-16
+17
2
11
I
@@ -94,7 +96,7 @@ I
0
n
p
-22
+23
x
7
Runtime
@@ -126,6 +128,7 @@ x
x
14
noscript:clone
+n
x
9
const_set
@@ -402,23 +405,23 @@ I
I
2
I
-24
+26
I
5
I
-2b
+2d
I
7
I
-37
+39
I
a
I
-3e
+40
I
e
I
-4a
+4c
x
42
/Users/txus/Code/noscript/kernel/traits.ns
View
@@ -121,6 +121,10 @@ def constant?
@constant
end
+ def ruby?
+ @name == "Ruby"
+ end
+
def deref?
@deref
end
@@ -120,8 +120,12 @@ def visit_Identifier(o)
set_line(o)
if o.constant?
- g.push_runtime
- g.find_const o.name.to_sym
+ if o.ruby?
+ g.push_cpath_top
+ else
+ g.push_runtime
+ g.find_const o.name.to_sym
+ end
elsif o.deref? # @foo equals to self.foo
g.push_self
g.push_literal o.name
@@ -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 ^ 10273849642584596569
+Noscript::Signature = Rubinius::Signature ^ 1341661358288879324
View
@@ -0,0 +1,19 @@
+require 'test_helper'
+
+class InteropTest < MiniTest::Unit::TestCase
+ module Mixin
+ def mixin_method
+ 1234
+ end
+ end
+
+ class Foo
+ def bar
+ 34
+ end
+ end
+
+ def test_call_ruby_from_noscript
+ assert_equal Fixnum, compile("Ruby.Fixnum")
+ end
+end

0 comments on commit e465c9d

Please sign in to comment.