Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Provide shims for methods that should compile
  • Loading branch information
kddnewton committed Nov 23, 2022
commit 85df98f85dc297e16bc27003f2202728c871687e
52 changes: 52 additions & 0 deletions lib/syntax_tree/yarv/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ def initialize(
frozen_string_literal: false,
inline_const_cache: true,
operands_unification: true,
peephole_optimization: true,
specialized_instruction: true,
tailcall_optimization: false
)
@frozen_string_literal = frozen_string_literal
@inline_const_cache = inline_const_cache
@operands_unification = operands_unification
@peephole_optimization = peephole_optimization
@specialized_instruction = specialized_instruction
@tailcall_optimization = tailcall_optimization
end
Expand All @@ -69,6 +71,7 @@ def to_hash
frozen_string_literal: @frozen_string_literal,
inline_const_cache: @inline_const_cache,
operands_unification: @operands_unification,
peephole_optimization: @peephole_optimization,
specialized_instruction: @specialized_instruction,
tailcall_optimization: @tailcall_optimization
}
Expand All @@ -90,6 +93,10 @@ def operands_unification?
@operands_unification
end

def peephole_optimization?
@peephole_optimization
end

def specialized_instruction?
@specialized_instruction
end
Expand Down Expand Up @@ -608,6 +615,9 @@ def visit_bare_assoc_hash(node)
end
end

def visit_begin(node)
end

def visit_binary(node)
case node.operator
when :"&&"
Expand Down Expand Up @@ -669,6 +679,9 @@ def visit_bodystmt(node)
visit(node.statements)
end

def visit_break(node)
end

def visit_call(node)
if node.is_a?(CallNode)
return(
Expand Down Expand Up @@ -1016,6 +1029,9 @@ def visit_elsif(node)
)
end

def visit_ensure(node)
end

def visit_field(node)
visit(node.parent)
end
Expand All @@ -1024,6 +1040,9 @@ def visit_float(node)
iseq.putobject(node.accept(RubyVisitor.new))
end

def visit_fndptn(node)
end

def visit_for(node)
visit(node.collection)

Expand Down Expand Up @@ -1064,6 +1083,9 @@ def visit_hash(node)
end
end

def visit_hshptn(node)
end

def visit_heredoc(node)
if node.beginning.value.end_with?("`")
visit_xstring_literal(node)
Expand Down Expand Up @@ -1143,6 +1165,9 @@ def visit_imaginary(node)
iseq.putobject(node.accept(RubyVisitor.new))
end

def visit_in(node)
end

def visit_int(node)
iseq.putobject(node.accept(RubyVisitor.new))
end
Expand Down Expand Up @@ -1243,6 +1268,9 @@ def visit_mrhs(node)
end
end

def visit_next(node)
end

def visit_not(node)
visit(node.statement)
iseq.send(YARV.calldata(:!))
Expand Down Expand Up @@ -1408,6 +1436,12 @@ def visit_paren(node)
visit(node.contents)
end

def visit_pinned_begin(node)
end

def visit_pinned_var_ref(node)
end

def visit_program(node)
node.statements.body.each do |statement|
break unless statement.is_a?(Comment)
Expand Down Expand Up @@ -1566,6 +1600,9 @@ def visit_rational(node)
iseq.putobject(node.accept(RubyVisitor.new))
end

def visit_redo(node)
end

def visit_regexp_literal(node)
if (compiled = RubyVisitor.compile(node))
iseq.putobject(compiled)
Expand All @@ -1576,12 +1613,27 @@ def visit_regexp_literal(node)
end
end

def visit_rescue(node)
end

def visit_rescue_ex(node)
end

def visit_rescue_mod(node)
end

def visit_rest_param(node)
iseq.local_table.plain(node.name.value.to_sym)
iseq.argument_options[:rest_start] = iseq.argument_size
iseq.argument_size += 1
end

def visit_retry(node)
end

def visit_return(node)
end

def visit_sclass(node)
visit(node.target)
iseq.putnil
Expand Down
2 changes: 2 additions & 0 deletions test/compiler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ class CompilerTest < Minitest::Test
YARV::Compiler::Options.new,
YARV::Compiler::Options.new(frozen_string_literal: true),
YARV::Compiler::Options.new(operands_unification: false),
# TODO: have this work when peephole optimizations are turned off.
# YARV::Compiler::Options.new(peephole_optimization: false),
YARV::Compiler::Options.new(specialized_instruction: false),
YARV::Compiler::Options.new(inline_const_cache: false),
YARV::Compiler::Options.new(tailcall_optimization: true)
Expand Down