public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
Add symbol_index primitive
drbrain (author)
Wed Jul 23 17:39:32 -0700 2008
commit  6e9c36d60563672e5ea46a6c0aa81f044925220b
tree    ee539abe16f94e886cca6e7c56784ad75865d410
parent  7ecb05ada2cb7975dd6527f3936ef42174ceb085
...
16
17
18
 
 
 
 
 
19
20
21
...
16
17
18
19
20
21
22
23
24
25
26
0
@@ -16,6 +16,11 @@ namespace rubinius {
0
       return DATA_STRIP_TAG(this);
0
     }
0
 
0
+ // Ruby.primitive :symbol_index
0
+ INTEGER index(STATE) {
0
+ return Object::i2n(this->index());
0
+ }
0
+
0
     static Symbol* from_index(STATE, size_t index) {
0
       return (Symbol*)DATA_APPLY_TAG(index, DATA_TAG_SYMBOL);
0
     }
...
70
71
72
 
 
 
 
 
 
73
74
75
...
70
71
72
73
74
75
76
77
78
79
80
81
0
@@ -70,6 +70,12 @@ class TestSymbol : public CxxTest::TestSuite {
0
     TS_ASSERT(!strncmp("blah", str->byte_address(state), 4));
0
   }
0
 
0
+ void test_index() {
0
+ Symbol* sym = state->globals.symbols->lookup(state, "blah", 4);
0
+
0
+ TS_ASSERT_EQUALS(sym->index(state)->n2i(), sym->index());
0
+ }
0
+
0
   void test_to_str() {
0
     Symbol* sym = (Symbol*)state->globals.symbols->lookup(state, "blah");
0
 

Comments

    No one has commented yet.