Class: SeccompTools::Asm::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/seccomp-tools/asm/statement.rb

Overview

A statement after parsing the assembly. Each statement will be converted to a BPF.

Internally used by sasm.y.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, data, symbols) ⇒ Statement

Instantiates a SeccompTools::Asm::Statement object.

Parameters:

  • type (:alu, :assign, :if, :ret)

    Kind of this statement.

  • data (Object)

    The data for describing this statement. Type of data varies according to the value of type.

  • symbols (Array<Token>)

    Label tokens that refer to this statement.



26
27
28
29
30
# File 'lib/seccomp-tools/asm/statement.rb', line 26

def initialize(type, data, symbols)
  @type = type
  @data = data
  @symbols = symbols
end

Instance Attribute Details

#dataObject (readonly)

Returns The operands of this statement, see #initialize.

Returns:

  • (Object)

    The operands of this statement, see #initialize.



14
15
16
# File 'lib/seccomp-tools/asm/statement.rb', line 14

def data
  @data
end

#symbolsArray<Token> (readonly)

Returns Labels that refer to this statement.

Returns:

  • (Array<Token>)

    Labels that refer to this statement.



16
17
18
# File 'lib/seccomp-tools/asm/statement.rb', line 16

def symbols
  @symbols
end

#typeSymbol (readonly)

Returns Kind of this statement, one of :alu, :assign, :if and :ret.

Returns:

  • (Symbol)

    Kind of this statement, one of :alu, :assign, :if and :ret.



12
13
14
# File 'lib/seccomp-tools/asm/statement.rb', line 12

def type
  @type
end

Instance Method Details

#==(other) ⇒ Boolean

Returns true only if the type, data and symbols are all equal.

Parameters:

  • other (Statement)

    The statement to be compared with.

Returns:

  • (Boolean)

    true only if the type, data and symbols are all equal.



36
37
38
# File 'lib/seccomp-tools/asm/statement.rb', line 36

def ==(other)
  [type, data, symbols] == [other.type, other.data, other.symbols]
end