Class: Rjq::BytecodeCompiler
- Inherits:
-
Object
- Object
- Rjq::BytecodeCompiler
- Defined in:
- lib/rjq/compiler.rb
Instance Method Summary collapse
- #compile(ast, module_metadata: {}, module_variables: {}) ⇒ Object
-
#initialize(allow_comments: true, max_filter_depth: Parser::DEFAULT_MAX_FILTER_DEPTH) ⇒ BytecodeCompiler
constructor
A new instance of BytecodeCompiler.
Constructor Details
#initialize(allow_comments: true, max_filter_depth: Parser::DEFAULT_MAX_FILTER_DEPTH) ⇒ BytecodeCompiler
Returns a new instance of BytecodeCompiler.
36 37 38 39 40 41 42 |
# File 'lib/rjq/compiler.rb', line 36 def initialize(allow_comments: true, max_filter_depth: Parser::DEFAULT_MAX_FILTER_DEPTH) @constants = [] @constant_indices = {} @current_nodes = [] @allow_comments = allow_comments @max_filter_depth = max_filter_depth end |
Instance Method Details
#compile(ast, module_metadata: {}, module_variables: {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rjq/compiler.rb', line 44 def compile(ast, module_metadata: {}, module_variables: {}) instructions = compile_node(ast.body) Rjq::Program.new( instructions: instructions, constants: @constants, definitions: ast.definitions.map { |definition| compile_definition(definition) }, module_metadata: , module_variables: module_variables ) end |