Class: Wardite::Op
- Inherits:
-
Object
- Object
- Wardite::Op
- Defined in:
- lib/wardite/instruction.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
: Symbol.
-
#operand ⇒ Object
: Array.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, operand) ⇒ Op
constructor
A new instance of Op.
Constructor Details
#initialize(code, operand) ⇒ Op
Returns a new instance of Op.
10 11 12 13 |
# File 'lib/wardite/instruction.rb', line 10 def initialize(code, operand) @code = code @operand = operand end |
Instance Attribute Details
#code ⇒ Object
: Symbol
4 5 6 |
# File 'lib/wardite/instruction.rb', line 4 def code @code end |
#operand ⇒ Object
: Array
6 7 8 |
# File 'lib/wardite/instruction.rb', line 6 def operand @operand end |
Class Method Details
.i2type(code) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/wardite/instruction.rb', line 56 def self.i2type(code) case code when 0x7f :i32 when 0x7e :i64 when 0x7d :f32 when 0x7c :f64 else raise "unknown type code #{code}" end end |
.operand_of(code) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wardite/instruction.rb', line 40 def self.operand_of(code) case code when :local_get, :local_set, :call [:u32] when :i32_const [:i32] when :i32_store [:u32, :u32] else [] end end |
.to_sym(chr) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wardite/instruction.rb', line 17 def self.to_sym(chr) case chr when "\u000b" :end when "\u0010" :call when "\u0020" :local_get when "\u0021" :local_set when "\u0036" :i32_store when "\u0041" :i32_const when "\u006a" :i32_add else raise NotImplementedError, "unimplemented: #{chr.inspect}" end end |