wag 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.gitlab-ci.yml +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +6 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +66 -0
- data/LICENSE.txt +40 -0
- data/README.md +170 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/wag.rb +42 -0
- data/lib/wag/data.rb +18 -0
- data/lib/wag/element.rb +18 -0
- data/lib/wag/encodable.rb +23 -0
- data/lib/wag/export.rb +39 -0
- data/lib/wag/f32_instructions.rb +21 -0
- data/lib/wag/f64_instructions.rb +21 -0
- data/lib/wag/function.rb +33 -0
- data/lib/wag/function_type.rb +16 -0
- data/lib/wag/global.rb +18 -0
- data/lib/wag/global_instructions.rb +19 -0
- data/lib/wag/i32_instructions.rb +22 -0
- data/lib/wag/i64_instructions.rb +23 -0
- data/lib/wag/import.rb +42 -0
- data/lib/wag/indices.rb +14 -0
- data/lib/wag/indices/base.rb +16 -0
- data/lib/wag/indices/func.rb +8 -0
- data/lib/wag/indices/global.rb +8 -0
- data/lib/wag/indices/label.rb +8 -0
- data/lib/wag/indices/local.rb +8 -0
- data/lib/wag/indices/mem.rb +8 -0
- data/lib/wag/indices/table.rb +8 -0
- data/lib/wag/indices/type.rb +8 -0
- data/lib/wag/inflector.rb +13 -0
- data/lib/wag/instructable.rb +65 -0
- data/lib/wag/instruction.rb +193 -0
- data/lib/wag/instructions/base.rb +24 -0
- data/lib/wag/instructions/block.rb +21 -0
- data/lib/wag/instructions/br.rb +18 -0
- data/lib/wag/instructions/br_if.rb +18 -0
- data/lib/wag/instructions/br_table.rb +18 -0
- data/lib/wag/instructions/call.rb +18 -0
- data/lib/wag/instructions/call_indirect.rb +18 -0
- data/lib/wag/instructions/drop.rb +8 -0
- data/lib/wag/instructions/else.rb +9 -0
- data/lib/wag/instructions/end.rb +8 -0
- data/lib/wag/instructions/f32/abs.rb +11 -0
- data/lib/wag/instructions/f32/add.rb +11 -0
- data/lib/wag/instructions/f32/base.rb +13 -0
- data/lib/wag/instructions/f32/ceil.rb +11 -0
- data/lib/wag/instructions/f32/const.rb +20 -0
- data/lib/wag/instructions/f32/convert_i32_s.rb +11 -0
- data/lib/wag/instructions/f32/convert_i32_u.rb +11 -0
- data/lib/wag/instructions/f32/convert_i64_s.rb +11 -0
- data/lib/wag/instructions/f32/convert_i64_u.rb +11 -0
- data/lib/wag/instructions/f32/copysign.rb +11 -0
- data/lib/wag/instructions/f32/demote_f64.rb +11 -0
- data/lib/wag/instructions/f32/div.rb +11 -0
- data/lib/wag/instructions/f32/eq.rb +11 -0
- data/lib/wag/instructions/f32/floor.rb +11 -0
- data/lib/wag/instructions/f32/ge.rb +11 -0
- data/lib/wag/instructions/f32/gt.rb +11 -0
- data/lib/wag/instructions/f32/le.rb +11 -0
- data/lib/wag/instructions/f32/load.rb +11 -0
- data/lib/wag/instructions/f32/lt.rb +11 -0
- data/lib/wag/instructions/f32/max.rb +11 -0
- data/lib/wag/instructions/f32/min.rb +11 -0
- data/lib/wag/instructions/f32/mul.rb +11 -0
- data/lib/wag/instructions/f32/ne.rb +11 -0
- data/lib/wag/instructions/f32/nearest.rb +11 -0
- data/lib/wag/instructions/f32/neg.rb +11 -0
- data/lib/wag/instructions/f32/reinterpret_i32.rb +11 -0
- data/lib/wag/instructions/f32/sqrt.rb +11 -0
- data/lib/wag/instructions/f32/store.rb +11 -0
- data/lib/wag/instructions/f32/sub.rb +11 -0
- data/lib/wag/instructions/f32/trunc.rb +11 -0
- data/lib/wag/instructions/f64/abs.rb +11 -0
- data/lib/wag/instructions/f64/add.rb +11 -0
- data/lib/wag/instructions/f64/base.rb +13 -0
- data/lib/wag/instructions/f64/ceil.rb +11 -0
- data/lib/wag/instructions/f64/const.rb +20 -0
- data/lib/wag/instructions/f64/convert_i32_s.rb +11 -0
- data/lib/wag/instructions/f64/convert_i32_u.rb +11 -0
- data/lib/wag/instructions/f64/convert_i64_s.rb +11 -0
- data/lib/wag/instructions/f64/convert_i64_u.rb +11 -0
- data/lib/wag/instructions/f64/copysign.rb +11 -0
- data/lib/wag/instructions/f64/div.rb +11 -0
- data/lib/wag/instructions/f64/eq.rb +11 -0
- data/lib/wag/instructions/f64/floor.rb +11 -0
- data/lib/wag/instructions/f64/ge.rb +11 -0
- data/lib/wag/instructions/f64/gt.rb +11 -0
- data/lib/wag/instructions/f64/le.rb +11 -0
- data/lib/wag/instructions/f64/load.rb +11 -0
- data/lib/wag/instructions/f64/lt.rb +11 -0
- data/lib/wag/instructions/f64/max.rb +11 -0
- data/lib/wag/instructions/f64/min.rb +11 -0
- data/lib/wag/instructions/f64/mul.rb +11 -0
- data/lib/wag/instructions/f64/ne.rb +11 -0
- data/lib/wag/instructions/f64/nearest.rb +11 -0
- data/lib/wag/instructions/f64/neg.rb +11 -0
- data/lib/wag/instructions/f64/promote_f32.rb +11 -0
- data/lib/wag/instructions/f64/reinterpret_i64.rb +11 -0
- data/lib/wag/instructions/f64/sqrt.rb +11 -0
- data/lib/wag/instructions/f64/store.rb +11 -0
- data/lib/wag/instructions/f64/sub.rb +11 -0
- data/lib/wag/instructions/f64/trunc.rb +11 -0
- data/lib/wag/instructions/global/base.rb +13 -0
- data/lib/wag/instructions/global/get.rb +20 -0
- data/lib/wag/instructions/global/set.rb +20 -0
- data/lib/wag/instructions/i32/add.rb +11 -0
- data/lib/wag/instructions/i32/and.rb +11 -0
- data/lib/wag/instructions/i32/base.rb +13 -0
- data/lib/wag/instructions/i32/clz.rb +11 -0
- data/lib/wag/instructions/i32/const.rb +20 -0
- data/lib/wag/instructions/i32/ctz.rb +11 -0
- data/lib/wag/instructions/i32/div_s.rb +11 -0
- data/lib/wag/instructions/i32/div_u.rb +11 -0
- data/lib/wag/instructions/i32/eq.rb +11 -0
- data/lib/wag/instructions/i32/eqz.rb +11 -0
- data/lib/wag/instructions/i32/ge_s.rb +11 -0
- data/lib/wag/instructions/i32/ge_u.rb +11 -0
- data/lib/wag/instructions/i32/gt_s.rb +11 -0
- data/lib/wag/instructions/i32/gt_u.rb +11 -0
- data/lib/wag/instructions/i32/le_s.rb +11 -0
- data/lib/wag/instructions/i32/le_u.rb +11 -0
- data/lib/wag/instructions/i32/load.rb +11 -0
- data/lib/wag/instructions/i32/load16_s.rb +11 -0
- data/lib/wag/instructions/i32/load16_u.rb +11 -0
- data/lib/wag/instructions/i32/load8_s.rb +11 -0
- data/lib/wag/instructions/i32/load8_u.rb +11 -0
- data/lib/wag/instructions/i32/lt_s.rb +11 -0
- data/lib/wag/instructions/i32/lt_u.rb +11 -0
- data/lib/wag/instructions/i32/mul.rb +11 -0
- data/lib/wag/instructions/i32/ne.rb +11 -0
- data/lib/wag/instructions/i32/or.rb +11 -0
- data/lib/wag/instructions/i32/popcnt.rb +11 -0
- data/lib/wag/instructions/i32/reinterpret_f32.rb +11 -0
- data/lib/wag/instructions/i32/rem_s.rb +11 -0
- data/lib/wag/instructions/i32/rem_u.rb +11 -0
- data/lib/wag/instructions/i32/rotl.rb +11 -0
- data/lib/wag/instructions/i32/rotr.rb +11 -0
- data/lib/wag/instructions/i32/shl.rb +11 -0
- data/lib/wag/instructions/i32/shr_s.rb +11 -0
- data/lib/wag/instructions/i32/shr_u.rb +11 -0
- data/lib/wag/instructions/i32/store.rb +11 -0
- data/lib/wag/instructions/i32/store16.rb +11 -0
- data/lib/wag/instructions/i32/store8.rb +11 -0
- data/lib/wag/instructions/i32/sub.rb +11 -0
- data/lib/wag/instructions/i32/trunc_f32_s.rb +11 -0
- data/lib/wag/instructions/i32/trunc_f32_u.rb +11 -0
- data/lib/wag/instructions/i32/trunc_f64_s.rb +11 -0
- data/lib/wag/instructions/i32/trunc_f64_u.rb +11 -0
- data/lib/wag/instructions/i32/wrap_i64.rb +11 -0
- data/lib/wag/instructions/i32/xor.rb +11 -0
- data/lib/wag/instructions/i64/add.rb +11 -0
- data/lib/wag/instructions/i64/and.rb +11 -0
- data/lib/wag/instructions/i64/base.rb +13 -0
- data/lib/wag/instructions/i64/clz.rb +11 -0
- data/lib/wag/instructions/i64/const.rb +20 -0
- data/lib/wag/instructions/i64/ctz.rb +11 -0
- data/lib/wag/instructions/i64/div_s.rb +11 -0
- data/lib/wag/instructions/i64/div_u.rb +11 -0
- data/lib/wag/instructions/i64/eq.rb +11 -0
- data/lib/wag/instructions/i64/eqz.rb +11 -0
- data/lib/wag/instructions/i64/extend_i32_s.rb +11 -0
- data/lib/wag/instructions/i64/extend_i32_u.rb +11 -0
- data/lib/wag/instructions/i64/ge_s.rb +11 -0
- data/lib/wag/instructions/i64/ge_u.rb +11 -0
- data/lib/wag/instructions/i64/gt_s.rb +11 -0
- data/lib/wag/instructions/i64/gt_u.rb +11 -0
- data/lib/wag/instructions/i64/le_s.rb +11 -0
- data/lib/wag/instructions/i64/le_u.rb +11 -0
- data/lib/wag/instructions/i64/load.rb +11 -0
- data/lib/wag/instructions/i64/load16_s.rb +11 -0
- data/lib/wag/instructions/i64/load16_u.rb +11 -0
- data/lib/wag/instructions/i64/load32_s.rb +11 -0
- data/lib/wag/instructions/i64/load32_u.rb +11 -0
- data/lib/wag/instructions/i64/load8_s.rb +11 -0
- data/lib/wag/instructions/i64/load8_u.rb +11 -0
- data/lib/wag/instructions/i64/lt_s.rb +11 -0
- data/lib/wag/instructions/i64/lt_u.rb +11 -0
- data/lib/wag/instructions/i64/mul.rb +11 -0
- data/lib/wag/instructions/i64/ne.rb +11 -0
- data/lib/wag/instructions/i64/or.rb +11 -0
- data/lib/wag/instructions/i64/popcnt.rb +11 -0
- data/lib/wag/instructions/i64/reinterpret_f64.rb +11 -0
- data/lib/wag/instructions/i64/rem_s.rb +11 -0
- data/lib/wag/instructions/i64/rem_u.rb +11 -0
- data/lib/wag/instructions/i64/rotl.rb +11 -0
- data/lib/wag/instructions/i64/rotr.rb +11 -0
- data/lib/wag/instructions/i64/shl.rb +11 -0
- data/lib/wag/instructions/i64/shr_s.rb +11 -0
- data/lib/wag/instructions/i64/shr_u.rb +11 -0
- data/lib/wag/instructions/i64/store.rb +11 -0
- data/lib/wag/instructions/i64/store16.rb +11 -0
- data/lib/wag/instructions/i64/store32.rb +11 -0
- data/lib/wag/instructions/i64/store8.rb +11 -0
- data/lib/wag/instructions/i64/sub.rb +11 -0
- data/lib/wag/instructions/i64/trunc_f32_s.rb +11 -0
- data/lib/wag/instructions/i64/trunc_f32_u.rb +11 -0
- data/lib/wag/instructions/i64/trunc_f64_s.rb +11 -0
- data/lib/wag/instructions/i64/trunc_f64_u.rb +11 -0
- data/lib/wag/instructions/i64/xor.rb +11 -0
- data/lib/wag/instructions/if.rb +26 -0
- data/lib/wag/instructions/local/base.rb +13 -0
- data/lib/wag/instructions/local/get.rb +20 -0
- data/lib/wag/instructions/local/set.rb +20 -0
- data/lib/wag/instructions/local/tee.rb +20 -0
- data/lib/wag/instructions/loop.rb +9 -0
- data/lib/wag/instructions/memory/base.rb +13 -0
- data/lib/wag/instructions/memory/grow.rb +11 -0
- data/lib/wag/instructions/memory/size.rb +11 -0
- data/lib/wag/instructions/nop.rb +8 -0
- data/lib/wag/instructions/return.rb +9 -0
- data/lib/wag/instructions/select.rb +9 -0
- data/lib/wag/instructions/unreachable.rb +8 -0
- data/lib/wag/label.rb +32 -0
- data/lib/wag/local.rb +19 -0
- data/lib/wag/local_instructions.rb +19 -0
- data/lib/wag/memory.rb +26 -0
- data/lib/wag/memory_instructions.rb +19 -0
- data/lib/wag/module.rb +100 -0
- data/lib/wag/param.rb +20 -0
- data/lib/wag/result.rb +17 -0
- data/lib/wag/table.rb +17 -0
- data/lib/wag/then.rb +13 -0
- data/lib/wag/type.rb +19 -0
- data/lib/wag/types/base.rb +16 -0
- data/lib/wag/types/f32.rb +8 -0
- data/lib/wag/types/f64.rb +8 -0
- data/lib/wag/types/i32.rb +8 -0
- data/lib/wag/types/i64.rb +8 -0
- data/lib/wag/version.rb +5 -0
- data/lib/wag/wabt.rb +45 -0
- data/lib/wag/wasm.rb +22 -0
- data/lib/wag/wat.rb +18 -0
- data/wag.gemspec +35 -0
- metadata +299 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instructable
|
5
|
+
# Define all the basic instructions.
|
6
|
+
%i[unreachable nop block loop if else end br br_if br_table return call
|
7
|
+
call_indirect drop select].each do |instruction_name|
|
8
|
+
camelised_name = WAG::Inflector.inflector.camelize(instruction_name)
|
9
|
+
define_method(instruction_name) do |*args, &block|
|
10
|
+
instruction = WAG::Instruction.const_get(camelised_name).new(*args)
|
11
|
+
instructions << instruction
|
12
|
+
instruction.instance_exec(&block) if block
|
13
|
+
instruction
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Alias Ruby keywords because reasons.
|
18
|
+
alias if_ if
|
19
|
+
alias else_ else
|
20
|
+
alias end_ end
|
21
|
+
alias loop_ loop
|
22
|
+
alias return_ return
|
23
|
+
|
24
|
+
def f32
|
25
|
+
WAG::F32Instructions.new(instructions)
|
26
|
+
end
|
27
|
+
|
28
|
+
def f64
|
29
|
+
WAG::F64Instructions.new(instructions)
|
30
|
+
end
|
31
|
+
|
32
|
+
def local(*args)
|
33
|
+
return WAG::LocalInstructions.new(instructions) if args.empty?
|
34
|
+
|
35
|
+
instruction = WAG::Local.new(*args)
|
36
|
+
instructions << instruction
|
37
|
+
instruction
|
38
|
+
end
|
39
|
+
|
40
|
+
def i32
|
41
|
+
WAG::I32Instructions.new(instructions)
|
42
|
+
end
|
43
|
+
|
44
|
+
def i64
|
45
|
+
WAG::I64Instructions.new(instructions)
|
46
|
+
end
|
47
|
+
|
48
|
+
def memory
|
49
|
+
WAG::MemoryInstructions.new(instructions)
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_sexpr
|
53
|
+
value = super()
|
54
|
+
return value if instructions.empty?
|
55
|
+
|
56
|
+
Array(value).concat(instructions.map(&:to_sexpr))
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def instructions
|
62
|
+
@instructions ||= []
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction # rubocop:disable Metrics/ModuleLength
|
5
|
+
require 'wag/instructions/base'
|
6
|
+
require 'wag/instructions/block'
|
7
|
+
require 'wag/instructions/br'
|
8
|
+
require 'wag/instructions/br_if'
|
9
|
+
require 'wag/instructions/br_table'
|
10
|
+
require 'wag/instructions/call'
|
11
|
+
require 'wag/instructions/call_indirect'
|
12
|
+
require 'wag/instructions/drop'
|
13
|
+
require 'wag/instructions/else'
|
14
|
+
require 'wag/instructions/end'
|
15
|
+
require 'wag/instructions/if'
|
16
|
+
require 'wag/instructions/loop'
|
17
|
+
require 'wag/instructions/nop'
|
18
|
+
require 'wag/instructions/return'
|
19
|
+
require 'wag/instructions/select'
|
20
|
+
require 'wag/instructions/unreachable'
|
21
|
+
|
22
|
+
require 'wag/instructions/f32/base'
|
23
|
+
require 'wag/instructions/f32/abs'
|
24
|
+
require 'wag/instructions/f32/add'
|
25
|
+
require 'wag/instructions/f32/ceil'
|
26
|
+
require 'wag/instructions/f32/const'
|
27
|
+
require 'wag/instructions/f32/convert_i32_s'
|
28
|
+
require 'wag/instructions/f32/convert_i32_u'
|
29
|
+
require 'wag/instructions/f32/convert_i64_s'
|
30
|
+
require 'wag/instructions/f32/convert_i64_u'
|
31
|
+
require 'wag/instructions/f32/copysign'
|
32
|
+
require 'wag/instructions/f32/demote_f64'
|
33
|
+
require 'wag/instructions/f32/div'
|
34
|
+
require 'wag/instructions/f32/eq'
|
35
|
+
require 'wag/instructions/f32/floor'
|
36
|
+
require 'wag/instructions/f32/ge'
|
37
|
+
require 'wag/instructions/f32/gt'
|
38
|
+
require 'wag/instructions/f32/le'
|
39
|
+
require 'wag/instructions/f32/load'
|
40
|
+
require 'wag/instructions/f32/lt'
|
41
|
+
require 'wag/instructions/f32/max'
|
42
|
+
require 'wag/instructions/f32/min'
|
43
|
+
require 'wag/instructions/f32/mul'
|
44
|
+
require 'wag/instructions/f32/ne'
|
45
|
+
require 'wag/instructions/f32/nearest'
|
46
|
+
require 'wag/instructions/f32/neg'
|
47
|
+
require 'wag/instructions/f32/reinterpret_i32'
|
48
|
+
require 'wag/instructions/f32/sqrt'
|
49
|
+
require 'wag/instructions/f32/store'
|
50
|
+
require 'wag/instructions/f32/sub'
|
51
|
+
require 'wag/instructions/f32/trunc'
|
52
|
+
|
53
|
+
require 'wag/instructions/f64/base'
|
54
|
+
require 'wag/instructions/f64/abs'
|
55
|
+
require 'wag/instructions/f64/add'
|
56
|
+
require 'wag/instructions/f64/ceil'
|
57
|
+
require 'wag/instructions/f64/const'
|
58
|
+
require 'wag/instructions/f64/convert_i32_s'
|
59
|
+
require 'wag/instructions/f64/convert_i32_u'
|
60
|
+
require 'wag/instructions/f64/convert_i64_s'
|
61
|
+
require 'wag/instructions/f64/convert_i64_u'
|
62
|
+
require 'wag/instructions/f64/copysign'
|
63
|
+
require 'wag/instructions/f64/div'
|
64
|
+
require 'wag/instructions/f64/eq'
|
65
|
+
require 'wag/instructions/f64/floor'
|
66
|
+
require 'wag/instructions/f64/ge'
|
67
|
+
require 'wag/instructions/f64/gt'
|
68
|
+
require 'wag/instructions/f64/le'
|
69
|
+
require 'wag/instructions/f64/load'
|
70
|
+
require 'wag/instructions/f64/lt'
|
71
|
+
require 'wag/instructions/f64/max'
|
72
|
+
require 'wag/instructions/f64/min'
|
73
|
+
require 'wag/instructions/f64/mul'
|
74
|
+
require 'wag/instructions/f64/ne'
|
75
|
+
require 'wag/instructions/f64/nearest'
|
76
|
+
require 'wag/instructions/f64/neg'
|
77
|
+
require 'wag/instructions/f64/promote_f32'
|
78
|
+
require 'wag/instructions/f64/reinterpret_i64'
|
79
|
+
require 'wag/instructions/f64/sqrt'
|
80
|
+
require 'wag/instructions/f64/store'
|
81
|
+
require 'wag/instructions/f64/sub'
|
82
|
+
require 'wag/instructions/f64/trunc'
|
83
|
+
|
84
|
+
require 'wag/instructions/global/base'
|
85
|
+
require 'wag/instructions/global/get'
|
86
|
+
require 'wag/instructions/global/set'
|
87
|
+
|
88
|
+
require 'wag/instructions/i32/base'
|
89
|
+
require 'wag/instructions/i32/add'
|
90
|
+
require 'wag/instructions/i32/and'
|
91
|
+
require 'wag/instructions/i32/clz'
|
92
|
+
require 'wag/instructions/i32/const'
|
93
|
+
require 'wag/instructions/i32/ctz'
|
94
|
+
require 'wag/instructions/i32/div_s'
|
95
|
+
require 'wag/instructions/i32/div_u'
|
96
|
+
require 'wag/instructions/i32/eq'
|
97
|
+
require 'wag/instructions/i32/eqz'
|
98
|
+
require 'wag/instructions/i32/ge_s'
|
99
|
+
require 'wag/instructions/i32/ge_u'
|
100
|
+
require 'wag/instructions/i32/gt_s'
|
101
|
+
require 'wag/instructions/i32/gt_u'
|
102
|
+
require 'wag/instructions/i32/le_s'
|
103
|
+
require 'wag/instructions/i32/le_u'
|
104
|
+
require 'wag/instructions/i32/load'
|
105
|
+
require 'wag/instructions/i32/load16_s'
|
106
|
+
require 'wag/instructions/i32/load16_u'
|
107
|
+
require 'wag/instructions/i32/load8_s'
|
108
|
+
require 'wag/instructions/i32/load8_u'
|
109
|
+
require 'wag/instructions/i32/lt_s'
|
110
|
+
require 'wag/instructions/i32/lt_u'
|
111
|
+
require 'wag/instructions/i32/mul'
|
112
|
+
require 'wag/instructions/i32/ne'
|
113
|
+
require 'wag/instructions/i32/or'
|
114
|
+
require 'wag/instructions/i32/popcnt'
|
115
|
+
require 'wag/instructions/i32/reinterpret_f32'
|
116
|
+
require 'wag/instructions/i32/rem_s'
|
117
|
+
require 'wag/instructions/i32/rem_u'
|
118
|
+
require 'wag/instructions/i32/rotl'
|
119
|
+
require 'wag/instructions/i32/rotr'
|
120
|
+
require 'wag/instructions/i32/shl'
|
121
|
+
require 'wag/instructions/i32/shr_s'
|
122
|
+
require 'wag/instructions/i32/shr_u'
|
123
|
+
require 'wag/instructions/i32/store'
|
124
|
+
require 'wag/instructions/i32/store16'
|
125
|
+
require 'wag/instructions/i32/store8'
|
126
|
+
require 'wag/instructions/i32/sub'
|
127
|
+
require 'wag/instructions/i32/trunc_f32_s'
|
128
|
+
require 'wag/instructions/i32/trunc_f32_u'
|
129
|
+
require 'wag/instructions/i32/trunc_f64_s'
|
130
|
+
require 'wag/instructions/i32/trunc_f64_u'
|
131
|
+
require 'wag/instructions/i32/wrap_i64'
|
132
|
+
require 'wag/instructions/i32/xor'
|
133
|
+
|
134
|
+
require 'wag/instructions/i64/base'
|
135
|
+
require 'wag/instructions/i64/add'
|
136
|
+
require 'wag/instructions/i64/and'
|
137
|
+
require 'wag/instructions/i64/clz'
|
138
|
+
require 'wag/instructions/i64/const'
|
139
|
+
require 'wag/instructions/i64/ctz'
|
140
|
+
require 'wag/instructions/i64/div_s'
|
141
|
+
require 'wag/instructions/i64/div_u'
|
142
|
+
require 'wag/instructions/i64/eq'
|
143
|
+
require 'wag/instructions/i64/eqz'
|
144
|
+
require 'wag/instructions/i64/extend_i32_s'
|
145
|
+
require 'wag/instructions/i64/extend_i32_u'
|
146
|
+
require 'wag/instructions/i64/ge_s'
|
147
|
+
require 'wag/instructions/i64/ge_u'
|
148
|
+
require 'wag/instructions/i64/gt_s'
|
149
|
+
require 'wag/instructions/i64/gt_u'
|
150
|
+
require 'wag/instructions/i64/le_s'
|
151
|
+
require 'wag/instructions/i64/le_u'
|
152
|
+
require 'wag/instructions/i64/load'
|
153
|
+
require 'wag/instructions/i64/load16_s'
|
154
|
+
require 'wag/instructions/i64/load16_u'
|
155
|
+
require 'wag/instructions/i64/load32_s'
|
156
|
+
require 'wag/instructions/i64/load32_u'
|
157
|
+
require 'wag/instructions/i64/load8_s'
|
158
|
+
require 'wag/instructions/i64/load8_u'
|
159
|
+
require 'wag/instructions/i64/lt_s'
|
160
|
+
require 'wag/instructions/i64/lt_u'
|
161
|
+
require 'wag/instructions/i64/mul'
|
162
|
+
require 'wag/instructions/i64/ne'
|
163
|
+
require 'wag/instructions/i64/or'
|
164
|
+
require 'wag/instructions/i64/popcnt'
|
165
|
+
require 'wag/instructions/i64/reinterpret_f64'
|
166
|
+
require 'wag/instructions/i64/rem_s'
|
167
|
+
require 'wag/instructions/i64/rem_u'
|
168
|
+
require 'wag/instructions/i64/rotl'
|
169
|
+
require 'wag/instructions/i64/rotr'
|
170
|
+
require 'wag/instructions/i64/shl'
|
171
|
+
require 'wag/instructions/i64/shr_s'
|
172
|
+
require 'wag/instructions/i64/shr_u'
|
173
|
+
require 'wag/instructions/i64/store'
|
174
|
+
require 'wag/instructions/i64/store16'
|
175
|
+
require 'wag/instructions/i64/store32'
|
176
|
+
require 'wag/instructions/i64/store8'
|
177
|
+
require 'wag/instructions/i64/sub'
|
178
|
+
require 'wag/instructions/i64/trunc_f32_s'
|
179
|
+
require 'wag/instructions/i64/trunc_f32_u'
|
180
|
+
require 'wag/instructions/i64/trunc_f64_s'
|
181
|
+
require 'wag/instructions/i64/trunc_f64_u'
|
182
|
+
require 'wag/instructions/i64/xor'
|
183
|
+
|
184
|
+
require 'wag/instructions/local/base'
|
185
|
+
require 'wag/instructions/local/get'
|
186
|
+
require 'wag/instructions/local/set'
|
187
|
+
require 'wag/instructions/local/tee'
|
188
|
+
|
189
|
+
require 'wag/instructions/memory/base'
|
190
|
+
require 'wag/instructions/memory/grow'
|
191
|
+
require 'wag/instructions/memory/size'
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class Base
|
6
|
+
include WAG::Encodable
|
7
|
+
|
8
|
+
def self.instruction(op_code)
|
9
|
+
klass = Class.new(self)
|
10
|
+
klass.define_method(:op_code) { op_code }
|
11
|
+
klass
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
name = WAG::Inflector.inflector.demodulize(self.class.name.to_s)
|
16
|
+
WAG::Inflector.inflector.underscore(name).to_sym
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_sexpr
|
20
|
+
name.to_sym
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class Block < Base.instruction(0x02)
|
6
|
+
prepend WAG::Instructable
|
7
|
+
|
8
|
+
def result(*types)
|
9
|
+
return @result if types.empty?
|
10
|
+
|
11
|
+
@result = WAG::Result.new(*types)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_sexpr
|
15
|
+
return [name, @result.to_sexpr] if @result
|
16
|
+
|
17
|
+
name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class Br < Base.instruction(0x0c)
|
6
|
+
prepend WAG::Instructable
|
7
|
+
attr_reader :label
|
8
|
+
|
9
|
+
def initialize(label)
|
10
|
+
@label = WAG::Label.from(label)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_sexpr
|
14
|
+
[name, label.to_sexpr]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class BrIf < Base.instruction(0x0d)
|
6
|
+
prepend WAG::Instructable
|
7
|
+
attr_reader :label
|
8
|
+
|
9
|
+
def initialize(label)
|
10
|
+
@label = WAG::Label.from(label)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_sexpr
|
14
|
+
[name, label.to_sexpr]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class BrTable < Base.instruction(0x0e)
|
6
|
+
prepend WAG::Instructable
|
7
|
+
attr_reader :label
|
8
|
+
|
9
|
+
def initialize(*labels)
|
10
|
+
@labels = labels.map { |label| WAG::Label.from(label) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_sexpr
|
14
|
+
[name].concat(@labels.map(&:to_sexpr))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class Call < Base.instruction(0x10)
|
6
|
+
prepend WAG::Instructable
|
7
|
+
attr_reader :label
|
8
|
+
|
9
|
+
def initialize(label)
|
10
|
+
@label = WAG::Label.from(label)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_sexpr
|
14
|
+
[:call, label.to_sexpr]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WAG
|
4
|
+
module Instruction
|
5
|
+
class CallIndirect < Base.instruction(0x11)
|
6
|
+
prepend WAG::Instructable
|
7
|
+
def result(*types)
|
8
|
+
@result = WAG::Result.new(*types)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_sexpr
|
12
|
+
return [name, @result.to_sexpr] if @result
|
13
|
+
|
14
|
+
super()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|