Skip to content

Commit

Permalink
Fixed opasign with constant for 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Oct 15, 2011
1 parent d2638d9 commit 19766ef
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/compiler/ast/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ def bytecode(g)
pos(g)

if g.state.op_asgn?
g.push_const_or_nil @name
g.push_literal Rubinius::Compiler::Runtime
g.push_literal @name
g.push_scope
g.send :find_constant_for_op_asign_or, 2
else
g.push_const @name
end
Expand Down
8 changes: 6 additions & 2 deletions lib/compiler/ast/operators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,13 @@ def sexp_name

class OpAssignOr19 < OpAssignOr
def bytecode(g)
pos(g)

g.state.push_op_asgn
super(g)
g.state.pop_op_asgn
@left.or_bytecode(g) do
g.state.pop_op_asgn
@right.bytecode(g)
end
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions lib/compiler/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ def unwrap_block_arg(arg)

module_function :unwrap_block_arg

def find_constant_for_op_asign_or(name, scope)
name = normalize_const_name(name)

current, constant = scope.module, undefined

while current
constant = current.constant_table.fetch name, undefined
unless constant.equal?(undefined)
constant = constant.call if constant.kind_of?(Autoload)
return constant
end

current = current.direct_superclass
end

if instance_of?(Module)
constant = Object.constant_table.fetch name, undefined
unless constant.equal?(undefined)
constant = constant.call if constant.kind_of?(Autoload)
return constant
end
end

nil
end

module_function :find_constant_for_op_asign_or

def self.rbx_marshal_constant
name
end
Expand Down
19 changes: 19 additions & 0 deletions lib/mri_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,24 @@ def self.from(message, column, line, code, file)
end
end

class Object
def StringValue(obj)
return obj if obj.kind_of?(String)

begin
obj.to_str
rescue Exception => orig
raise TypeError,
"Coercion error: #{obj.inspect}.to_str => String failed",
orig
end

return ret if ret.kind_of?(String)

msg = "Coercion error: obj.to_st did NOT return a String (was #{ret.class})"
raise TypeError, msg
end
end

require File.expand_path("../../kernel/common/compiled_method", __FILE__)
require File.expand_path("../../kernel/delta/options", __FILE__)
1 change: 0 additions & 1 deletion spec/tags/19/ruby/language/constants_tags.txt

This file was deleted.

0 comments on commit 19766ef

Please sign in to comment.