Class: Rjq::CompiledProgram
- Inherits:
-
Object
- Object
- Rjq::CompiledProgram
- Defined in:
- lib/rjq/compiler.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#program ⇒ Object
readonly
Returns the value of attribute program.
Instance Method Summary collapse
- #disasm ⇒ Object
-
#initialize(ast, program:) ⇒ CompiledProgram
constructor
A new instance of CompiledProgram.
- #instructions ⇒ Object
- #run(input_value, opts = {}) ⇒ Object
- #run_with_instruction_budget(input_value, opts, budget) ⇒ Object
Constructor Details
#initialize(ast, program:) ⇒ CompiledProgram
Returns a new instance of CompiledProgram.
7 8 9 10 11 |
# File 'lib/rjq/compiler.rb', line 7 def initialize(ast, program:) @ast = ast @program = program freeze end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
5 6 7 |
# File 'lib/rjq/compiler.rb', line 5 def ast @ast end |
#program ⇒ Object (readonly)
Returns the value of attribute program.
5 6 7 |
# File 'lib/rjq/compiler.rb', line 5 def program @program end |
Instance Method Details
#disasm ⇒ Object
30 31 32 |
# File 'lib/rjq/compiler.rb', line 30 def disasm program.disasm end |
#instructions ⇒ Object
13 14 15 |
# File 'lib/rjq/compiler.rb', line 13 def instructions program.instructions end |
#run(input_value, opts = {}) ⇒ Object
17 18 19 |
# File 'lib/rjq/compiler.rb', line 17 def run(input_value, opts = {}) VM.new(self, Runtime.(opts)).run(input_value) end |
#run_with_instruction_budget(input_value, opts, budget) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/rjq/compiler.rb', line 21 def run_with_instruction_budget(input_value, opts, budget) normalized = Runtime.(opts) unless budget.is_a?(VM::InstructionBudget) && budget.maximum == normalized[:max_instructions] raise ArgumentError, 'instruction budget must match max_instructions' end VM.new(self, normalized, instruction_budget: budget).run(input_value) end |