Class: SeccompTools::Asm::Compiler
- Inherits:
-
Object
- Object
- SeccompTools::Asm::Compiler
- Defined in:
- lib/seccomp-tools/asm/compiler.rb
Overview
Compile seccomp rules.
Instance Method Summary collapse
-
#compile! ⇒ Array<SeccompTools::BPF>
Compiles the processed instructions.
-
#initialize(source, filename, arch) ⇒ Compiler
constructor
Instantiate a Compiler object.
Constructor Details
#initialize(source, filename, arch) ⇒ Compiler
Instantiate a SeccompTools::Asm::Compiler object.
23 24 25 26 27 |
# File 'lib/seccomp-tools/asm/compiler.rb', line 23 def initialize(source, filename, arch) @scanner = Scanner.new(source, arch, filename:) @arch = arch @symbols = {} end |
Instance Method Details
#compile! ⇒ Array<SeccompTools::BPF>
Compiles the processed instructions.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/seccomp-tools/asm/compiler.rb', line 35 def compile! @scanner.validate! statements = SeccompAsmParser.new(@scanner).parse fixup_symbols(statements) resolve_symbols(statements) statements.map.with_index do |s, idx| @line = idx case s.type when :alu then emit_alu(*s.data) when :assign then emit_assign(*s.data) when :if then emit_cmp(*s.data) when :ret then emit_ret(*s.data) end end end |