Class: SyntaxTree::YARV::Compiler::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/compiler.rb

Overview

This represents a set of options that can be passed to the compiler to control how it compiles the code. It mirrors the options that can be passed to RubyVM::InstructionSequence.compile, except it only includes options that actually change the behavior.

Instance Method Summary collapse

Constructor Details

#initialize(frozen_string_literal: false, inline_const_cache: true, operands_unification: true, peephole_optimization: true, specialized_instruction: true, tailcall_optimization: false) ⇒ Options

Returns a new instance of Options.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/syntax_tree/yarv/compiler.rb', line 53

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

Instance Method Details

#frozen_string_literal!Object



80
81
82
# File 'lib/syntax_tree/yarv/compiler.rb', line 80

def frozen_string_literal!
  @frozen_string_literal = true
end

#frozen_string_literal?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/syntax_tree/yarv/compiler.rb', line 84

def frozen_string_literal?
  @frozen_string_literal
end

#inline_const_cache?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/syntax_tree/yarv/compiler.rb', line 88

def inline_const_cache?
  @inline_const_cache
end

#operands_unification?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/syntax_tree/yarv/compiler.rb', line 92

def operands_unification?
  @operands_unification
end

#peephole_optimization?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/syntax_tree/yarv/compiler.rb', line 96

def peephole_optimization?
  @peephole_optimization
end

#specialized_instruction?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/syntax_tree/yarv/compiler.rb', line 100

def specialized_instruction?
  @specialized_instruction
end

#tailcall_optimization?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/syntax_tree/yarv/compiler.rb', line 104

def tailcall_optimization?
  @tailcall_optimization
end

#to_hashObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/syntax_tree/yarv/compiler.rb', line 69

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
  }
end