class CodeTools::AST::Match2
Attributes
pattern[RW]
value[RW]
Public Class Methods
new(line, pattern, value)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 469 def initialize(line, pattern, value) @line = line @pattern = pattern @value = value end
Public Instance Methods
bytecode(g)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 475 def bytecode(g) pos(g) @pattern.bytecode(g) @value.bytecode(g) g.send :=~, 1 if @pattern.kind_of? RegexLiteral regexp = Regexp.new(@pattern.source) # TODO: this code cannot just use Rubinius-specific methods. # Fix without using respond_to?. if regexp.respond_to? :name_table if table = regexp.name_table table.sort_by { |name, idx| idx }.each do |name, idx| local = g.state.scope.new_local name g.last_match 5, idx.last - 1 case local when Compiler::LocalVariable g.set_local local.slot when Compiler::EvalLocalVariable g.push_variables g.swap g.push_literal name g.swap g.send :set_eval_local, 2, false else raise CompileError, "unknown type of local #{local.inspect}" end g.pop end end end end end
to_sexp()
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 511 def to_sexp [:match2, @pattern.to_sexp, @value.to_sexp] end