Skip to content

Commit

Permalink
Created Symbol objects when coming across Symbol literals - needs tes…
Browse files Browse the repository at this point in the history
…t cases
  • Loading branch information
vidarh committed Aug 3, 2009
1 parent 94255ef commit f3a38a8
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions compiler.rb
Expand Up @@ -60,14 +60,12 @@ def warning(warning_message, *args)
end


# Allocate an integer value to a symbol. We'll "cheat" for now and just
# use the "host" system. The symbol table needs to eventually get
# reflected in the compiled program -- you need to be able to retrieve the
# name etc.. We also need to either create a "real" object for each of them
# *or* use a typetag like MRI (in other words: we can't just treat it as an
# arbitrary integer like this code does.
def intern(sym)
sym.to_sym.to_i
# Allocate a symbol
def intern(scope,sym)
# FIXME: Do this once, and add an :assign to a global var, and use that for any
# later static occurrences of symbols.
args = get_arg(scope,sym.to_s.rest)
get_arg(scope,[:callm, :Symbol, :__get_symbol, args[1]])
end

# Returns an argument with its type identifier.
Expand All @@ -83,7 +81,7 @@ def get_arg(scope, a)
return [:int, a.to_s[1..-1].to_i] if (a.is_a?(Symbol) && a.to_s[0] == ?$) # FIXME: Another temporary hack
if (a.is_a?(Symbol))
name = a.to_s
return [:int,intern(name.rest)] if name[0] == ?:
return intern(scope,name.rest) if name[0] == ?:
return scope.get_arg(a)
end

Expand Down Expand Up @@ -380,7 +378,7 @@ def compile_callm(scope, ob, method, args)
if !off
# Argh. Ok, then. Lets do send
off = @vtableoffsets.get_offset(:__send__)
args = [intern(method)] + args
args = [":#{method}".to_sym] + args
warning("WARNING: No vtable offset for '#{method}' -- you're likely to get a method_missing")
#error(err_msg, scope, [:callm, ob, method, args])
end
Expand Down

0 comments on commit f3a38a8

Please sign in to comment.