Class: Lignite::SimpleAssembler
- Inherits:
-
Object
- Object
- Lignite::SimpleAssembler
- Defined in:
- lib/lignite/assembler.rb
Overview
Acts like DirectCommands but instead of executing, assembles them to a RBF file
Instance Method Summary collapse
-
#initialize ⇒ SimpleAssembler
constructor
A new instance of SimpleAssembler.
-
#method_missing(name, *args, &block) ⇒ Object
Delegate the ops to the BodyCompiler,.
- #respond_to_missing?(name, _include_private) ⇒ Boolean
- #write(rbf_filename) ⇒ Object
Constructor Details
#initialize ⇒ SimpleAssembler
Returns a new instance of SimpleAssembler.
116 117 118 119 120 121 122 |
# File 'lib/lignite/assembler.rb', line 116 def initialize @globals = Variables.new @locals = Variables.new @declarer = RbfDeclarer::Dummy.new @interp = BodyCompiler.new(@globals, @locals, @declarer) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Delegate the ops to the BodyCompiler,
135 136 137 138 139 |
# File 'lib/lignite/assembler.rb', line 135 def method_missing(name, *args, &block) super unless @interp.respond_to?(name) @interp.public_send(name, *args, &block) end |
Instance Method Details
#respond_to_missing?(name, _include_private) ⇒ Boolean
141 142 143 |
# File 'lib/lignite/assembler.rb', line 141 def respond_to_missing?(name, _include_private) @interp.respond_to?(name) || super end |
#write(rbf_filename) ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/lignite/assembler.rb', line 124 def write(rbf_filename) @interp.object_end vmthread = RbfObject.vmthread(body: @interp.bytes, local_bytes: @locals.bytesize) asm = Assembler.new asm.objects = [vmthread] asm.globals = @globals asm.write(rbf_filename) end |