From 077dcf3e362578752d846fd67e91725c3947918c Mon Sep 17 00:00:00 2001 From: Vidar Hokstad Date: Thu, 4 Jun 2015 04:52:03 +0000 Subject: [PATCH] Uhm.. For some reason I thought class-ivars were not working properly for Symbol, but when trying to write a test to fix it, it turned out to work, so this cleans up Symbol accordingly --- lib/core/symbol.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/core/symbol.rb b/lib/core/symbol.rb index d67311c..c905786 100644 --- a/lib/core/symbol.rb +++ b/lib/core/symbol.rb @@ -14,11 +14,7 @@ # use to return the same object for the same symbol literal class Symbol - # FIXME: - # Both class variables and class instance variables are currently not - # working properly, so for now we store the hash of the already allocated - # symbols in a constant: - SymHash = {} + @symbols = {} # FIXME: Should be private, but we don't support that yet def initialize(name) @@ -38,10 +34,10 @@ def hash # Alternatively, the compiler can do this _once_ at the start for # any symbol encountered in the source text, and store the result. def self.__get_symbol(name) - sym = SymHash[name] + sym = @symbols[name] if sym.nil? ## FIXME: Doing !sym instead fails w/method missing sym = Symbol.new(name) - SymHash[name] = sym + @symbols[name] = sym end sym end