wardite 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +163 -0
- data/Steepfile +1 -0
- data/examples/consts.wat +12 -0
- data/examples/global.wat +13 -0
- data/lib/wardite/alu_f32.generated.rb +250 -0
- data/lib/wardite/alu_f64.generated.rb +250 -0
- data/lib/wardite/alu_i32.generated.rb +398 -18
- data/lib/wardite/alu_i64.generated.rb +514 -0
- data/lib/wardite/convert.generated.rb +234 -0
- data/lib/wardite/instruction.rb +63 -32
- data/lib/wardite/load.rb +679 -0
- data/lib/wardite/value.rb +576 -31
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi.rb +1 -1
- data/lib/wardite.rb +172 -634
- data/scripts/gen_alu.rb +653 -27
- data/scripts/gen_conv.rb +76 -0
- data/scripts/templates/conv_module.rb.tmpl +18 -0
- data/sig/generated/wardite/alu_f32.generated.rbs +11 -0
- data/sig/generated/wardite/alu_f64.generated.rbs +11 -0
- data/sig/generated/wardite/alu_i64.generated.rbs +11 -0
- data/sig/generated/wardite/convert.generated.rbs +11 -0
- data/sig/generated/wardite/instruction.rbs +8 -2
- data/sig/generated/wardite/load.rbs +198 -0
- data/sig/generated/wardite/value.rbs +263 -19
- data/sig/generated/wardite.rbs +36 -168
- metadata +16 -2
data/scripts/gen_conv.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "stringio"
|
2
|
+
|
3
|
+
module GenConv
|
4
|
+
def self.execute(path, defined_ops: {})
|
5
|
+
parent_dir = File.dirname(path)
|
6
|
+
system "mkdir -p #{parent_dir}"
|
7
|
+
|
8
|
+
basic_module = File.read(
|
9
|
+
File.expand_path("../templates/conv_module.rb.tmpl", __FILE__)
|
10
|
+
)
|
11
|
+
|
12
|
+
ope_defs = generate_ops(defined_ops: defined_ops)
|
13
|
+
basic_module.gsub!(/\$\{DEFS\}/, ope_defs)
|
14
|
+
|
15
|
+
dest = File.open(path, "w")
|
16
|
+
dest.puts basic_module
|
17
|
+
|
18
|
+
$stderr.puts "generated: #{path}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.generate_ops(defined_ops:)
|
22
|
+
result = StringIO.new("")
|
23
|
+
defined_ops.each_pair do |to, ops|
|
24
|
+
ops.each_pair do |op, argtypes|
|
25
|
+
argtypes.each do |from|
|
26
|
+
code = generate_one_branch(op: op, to: to, from: from)
|
27
|
+
result << "\n"
|
28
|
+
code.each_line do |ln|
|
29
|
+
result << " " * 6 << ln
|
30
|
+
end
|
31
|
+
result << "\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
result.string
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.generate_one_branch(op:, to:, from:)
|
39
|
+
code = DEF.dup
|
40
|
+
method = op.to_s
|
41
|
+
symbol = "#{to.to_s}_#{method}_#{from.to_sym}"
|
42
|
+
|
43
|
+
if method == "extend"
|
44
|
+
method = "extend_"
|
45
|
+
elsif method.end_with?("_s") or method.end_with?("_u")
|
46
|
+
core, suffix = *(method.split("_")[0..1])
|
47
|
+
symbol = "#{to.to_s}_#{core}_#{from.to_sym}_#{suffix}"
|
48
|
+
end
|
49
|
+
# NOTE to is as namespace
|
50
|
+
code.gsub!(/\$\{SYMBOL\}/, symbol)
|
51
|
+
code.gsub!(/\$\{METHOD\}/, method)
|
52
|
+
code.gsub!(/\$\{TO\}/, to.to_s)
|
53
|
+
code.gsub!(/\$\{TO_CLASS\}/, to_class(to.to_sym))
|
54
|
+
code.gsub!(/\$\{FROM_CLASS\}/, to_class(from.to_sym))
|
55
|
+
return code
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.to_class(typ)
|
59
|
+
{
|
60
|
+
i32: "I32",
|
61
|
+
i64: "I64",
|
62
|
+
f32: "F32",
|
63
|
+
f64: "F64",
|
64
|
+
}[typ]
|
65
|
+
end
|
66
|
+
|
67
|
+
# ope_templates
|
68
|
+
DEF = <<~RUBY
|
69
|
+
when :${SYMBOL}
|
70
|
+
from = runtime.stack.pop
|
71
|
+
raise EvalError, "maybe empty or invalid stack" if !from.is_a?(${FROM_CLASS})
|
72
|
+
to = from.${METHOD}(to: :${TO})
|
73
|
+
raise EvalError, "failed to convert type" if !to.is_a?(${TO_CLASS})
|
74
|
+
runtime.stack.push(to)
|
75
|
+
RUBY
|
76
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# rbs_inline: enabled
|
2
|
+
require_relative "value"
|
3
|
+
|
4
|
+
module Wardite
|
5
|
+
module Evaluator
|
6
|
+
# @rbs runtime: Runtime
|
7
|
+
# @rbs frame: Frame
|
8
|
+
# @rbs insn: Op
|
9
|
+
# @rbs return: void
|
10
|
+
def self.convert_eval_insn(runtime, frame, insn)
|
11
|
+
case insn.code
|
12
|
+
${DEFS}
|
13
|
+
else
|
14
|
+
raise "Unknown opcode for namespace #{insn.namespace}: #{insn.code}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Generated from lib/wardite/alu_f32.generated.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Wardite
|
4
|
+
module Evaluator
|
5
|
+
# @rbs runtime: Runtime
|
6
|
+
# @rbs frame: Frame
|
7
|
+
# @rbs insn: Op
|
8
|
+
# @rbs return: void
|
9
|
+
def self.f32_eval_insn: (Runtime runtime, Frame frame, Op insn) -> void
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Generated from lib/wardite/alu_f64.generated.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Wardite
|
4
|
+
module Evaluator
|
5
|
+
# @rbs runtime: Runtime
|
6
|
+
# @rbs frame: Frame
|
7
|
+
# @rbs insn: Op
|
8
|
+
# @rbs return: void
|
9
|
+
def self.f64_eval_insn: (Runtime runtime, Frame frame, Op insn) -> void
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Generated from lib/wardite/alu_i64.generated.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Wardite
|
4
|
+
module Evaluator
|
5
|
+
# @rbs runtime: Runtime
|
6
|
+
# @rbs frame: Frame
|
7
|
+
# @rbs insn: Op
|
8
|
+
# @rbs return: void
|
9
|
+
def self.i64_eval_insn: (Runtime runtime, Frame frame, Op insn) -> void
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Generated from lib/wardite/convert.generated.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Wardite
|
4
|
+
module Evaluator
|
5
|
+
# @rbs runtime: Runtime
|
6
|
+
# @rbs frame: Frame
|
7
|
+
# @rbs insn: Op
|
8
|
+
# @rbs return: void
|
9
|
+
def self.convert_eval_insn: (Runtime runtime, Frame frame, Op insn) -> void
|
10
|
+
end
|
11
|
+
end
|
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
module Wardite
|
4
4
|
class Op
|
5
|
+
# @see https://pengowray.github.io/wasm-ops/
|
6
|
+
SYMS: Array[Symbol]
|
7
|
+
|
8
|
+
# @rbs return: Hash[Integer, Symbol]
|
9
|
+
def self.table: () -> Hash[Integer, Symbol]
|
10
|
+
|
5
11
|
attr_accessor namespace: Symbol
|
6
12
|
|
7
13
|
attr_accessor code: Symbol
|
@@ -18,9 +24,9 @@ module Wardite
|
|
18
24
|
# @rbs return: [Symbol, Symbol]
|
19
25
|
def self.to_sym: (String chr) -> [ Symbol, Symbol ]
|
20
26
|
|
21
|
-
# @rbs
|
27
|
+
# @rbs code: Symbol
|
22
28
|
# @rbs return: Array[Symbol]
|
23
|
-
def self.operand_of: (
|
29
|
+
def self.operand_of: (Symbol code) -> Array[Symbol]
|
24
30
|
|
25
31
|
# @see https://www.w3.org/TR/wasm-core-1/#value-types%E2%91%A2
|
26
32
|
# @rbs code: Integer
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# Generated from lib/wardite/load.rb with RBS::Inline
|
2
|
+
|
3
|
+
# rbs_inline: enabled
|
4
|
+
module Wardite
|
5
|
+
class Section
|
6
|
+
attr_accessor name: String
|
7
|
+
|
8
|
+
attr_accessor code: Integer
|
9
|
+
|
10
|
+
attr_accessor size: Integer
|
11
|
+
end
|
12
|
+
|
13
|
+
class TypeSection < Section
|
14
|
+
attr_accessor defined_types: Array[Array[Symbol]]
|
15
|
+
|
16
|
+
attr_accessor defined_results: Array[Array[Symbol]]
|
17
|
+
|
18
|
+
# @rbs return: void
|
19
|
+
def initialize: () -> void
|
20
|
+
end
|
21
|
+
|
22
|
+
class FunctionSection < Section
|
23
|
+
attr_accessor func_indices: Array[Integer]
|
24
|
+
|
25
|
+
# @rbs return: void
|
26
|
+
def initialize: () -> void
|
27
|
+
end
|
28
|
+
|
29
|
+
class MemorySection < Section
|
30
|
+
attr_accessor limits: Array[[ Integer, Integer | nil ]]
|
31
|
+
|
32
|
+
# @rbs return: void
|
33
|
+
def initialize: () -> void
|
34
|
+
end
|
35
|
+
|
36
|
+
class GlobalSection < Section
|
37
|
+
class Global
|
38
|
+
attr_accessor type: Symbol
|
39
|
+
|
40
|
+
attr_accessor mutable: bool
|
41
|
+
|
42
|
+
# TODO: unused in wasm 1.0 spec?
|
43
|
+
attr_accessor shared: bool
|
44
|
+
|
45
|
+
attr_accessor value: I32 | I64 | F32 | F64
|
46
|
+
|
47
|
+
# @rbs &blk: (Global) -> void
|
48
|
+
# @rbs return: void
|
49
|
+
def initialize: () { (Global) -> void } -> void
|
50
|
+
end
|
51
|
+
|
52
|
+
attr_accessor globals: Array[Global]
|
53
|
+
|
54
|
+
# @rbs return: void
|
55
|
+
def initialize: () -> void
|
56
|
+
end
|
57
|
+
|
58
|
+
class CodeSection < Section
|
59
|
+
class CodeBody
|
60
|
+
attr_accessor locals_count: Array[Integer]
|
61
|
+
|
62
|
+
attr_accessor locals_type: Array[Symbol]
|
63
|
+
|
64
|
+
attr_accessor body: Array[Op]
|
65
|
+
|
66
|
+
# @rbs &blk: (CodeBody) -> void
|
67
|
+
# @rbs return: void
|
68
|
+
def initialize: () { (CodeBody) -> void } -> void
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_accessor func_codes: Array[CodeBody]
|
72
|
+
|
73
|
+
# @rbs return: void
|
74
|
+
def initialize: () -> void
|
75
|
+
end
|
76
|
+
|
77
|
+
class DataSection < Section
|
78
|
+
class Segment
|
79
|
+
attr_accessor flags: Integer
|
80
|
+
|
81
|
+
attr_accessor offset: Integer
|
82
|
+
|
83
|
+
attr_accessor data: String
|
84
|
+
|
85
|
+
# @rbs &blk: (Segment) -> void
|
86
|
+
# @rbs return: void
|
87
|
+
def initialize: () { (Segment) -> void } -> void
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_accessor segments: Array[Segment]
|
91
|
+
|
92
|
+
# @rbs return: void
|
93
|
+
def initialize: () -> void
|
94
|
+
end
|
95
|
+
|
96
|
+
class ExportSection < Section
|
97
|
+
class ExportDesc
|
98
|
+
attr_accessor name: String
|
99
|
+
|
100
|
+
attr_accessor kind: Integer
|
101
|
+
|
102
|
+
attr_accessor func_index: Integer
|
103
|
+
end
|
104
|
+
|
105
|
+
attr_accessor exports: Hash[String, ExportDesc]
|
106
|
+
|
107
|
+
def initialize: () -> void
|
108
|
+
|
109
|
+
# @rbs &blk: (ExportDesc) -> void
|
110
|
+
def add_desc: () { (ExportDesc) -> void } -> untyped
|
111
|
+
end
|
112
|
+
|
113
|
+
class ImportSection < Section
|
114
|
+
class ImportDesc
|
115
|
+
attr_accessor module_name: String
|
116
|
+
|
117
|
+
attr_accessor name: String
|
118
|
+
|
119
|
+
attr_accessor kind: Integer
|
120
|
+
|
121
|
+
attr_accessor sig_index: Integer
|
122
|
+
end
|
123
|
+
|
124
|
+
attr_accessor imports: Array[ImportDesc]
|
125
|
+
|
126
|
+
def initialize: () -> void
|
127
|
+
|
128
|
+
# @rbs &blk: (ImportDesc) -> void
|
129
|
+
def add_desc: () { (ImportDesc) -> void } -> untyped
|
130
|
+
end
|
131
|
+
|
132
|
+
module BinaryLoader
|
133
|
+
extend Wardite::Leb128Helper
|
134
|
+
|
135
|
+
extend Wardite::ValueHelper
|
136
|
+
|
137
|
+
# @rbs buf: File|StringIO
|
138
|
+
# @rbs import_object: Hash[Symbol, Hash[Symbol, Proc]]
|
139
|
+
# @rbs enable_wasi: boolish
|
140
|
+
# @rbs return: Instance
|
141
|
+
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, Hash[Symbol, Proc]], ?enable_wasi: boolish) -> Instance
|
142
|
+
|
143
|
+
# @rbs return: Integer
|
144
|
+
def self.preamble: () -> Integer
|
145
|
+
|
146
|
+
# @rbs return: Array[Section]
|
147
|
+
def self.sections: () -> Array[Section]
|
148
|
+
|
149
|
+
# @rbs return: TypeSection
|
150
|
+
def self.type_section: () -> TypeSection
|
151
|
+
|
152
|
+
# @rbs return: ImportSection
|
153
|
+
def self.import_section: () -> ImportSection
|
154
|
+
|
155
|
+
# @rbs return: MemorySection
|
156
|
+
def self.memory_section: () -> MemorySection
|
157
|
+
|
158
|
+
# @rbs return: GlobalSection
|
159
|
+
def self.global_section: () -> GlobalSection
|
160
|
+
|
161
|
+
# @rbs return: FunctionSection
|
162
|
+
def self.function_section: () -> FunctionSection
|
163
|
+
|
164
|
+
# @rbs return: CodeSection
|
165
|
+
def self.code_section: () -> CodeSection
|
166
|
+
|
167
|
+
# @rbs buf: StringIO
|
168
|
+
# @rbs return: Array[::Wardite::Op]
|
169
|
+
def self.code_body: (StringIO buf) -> Array[::Wardite::Op]
|
170
|
+
|
171
|
+
# @rbs return: DataSection
|
172
|
+
def self.data_section: () -> DataSection
|
173
|
+
|
174
|
+
# @rbs sbuf: StringIO
|
175
|
+
# @rbs return: String
|
176
|
+
def self.fetch_insn_while_end: (StringIO sbuf) -> String
|
177
|
+
|
178
|
+
# @rbs ops: Array[Op]
|
179
|
+
# @rbs return: Integer
|
180
|
+
def self.decode_expr: (Array[Op] ops) -> Integer
|
181
|
+
|
182
|
+
# @rbs ops: Array[Op]
|
183
|
+
# @rbs return: I32|I64|F32|F64
|
184
|
+
def self.decode_global_expr: (Array[Op] ops) -> (I32 | I64 | F32 | F64)
|
185
|
+
|
186
|
+
# @rbs return: ExportSection
|
187
|
+
def self.export_section: () -> ExportSection
|
188
|
+
|
189
|
+
# @rbs code: Integer
|
190
|
+
# @rbs return: nil
|
191
|
+
def self.unimplemented_skip_section: (Integer code) -> nil
|
192
|
+
|
193
|
+
# @rbs sbuf: StringIO
|
194
|
+
# @rbs n: Integer
|
195
|
+
# @rbs return: String
|
196
|
+
def self.assert_read: (StringIO sbuf, Integer n) -> String
|
197
|
+
end
|
198
|
+
end
|
@@ -1,58 +1,302 @@
|
|
1
1
|
# Generated from lib/wardite/value.rb with RBS::Inline
|
2
2
|
|
3
3
|
module Wardite
|
4
|
+
module ValueHelper
|
5
|
+
# @rbs value: Integer
|
6
|
+
# @rbs return: I32
|
7
|
+
def I32: (Integer value) -> I32
|
8
|
+
|
9
|
+
# @rbs value: Integer
|
10
|
+
# @rbs return: I64
|
11
|
+
def I64: (Integer value) -> I64
|
12
|
+
|
13
|
+
# @rbs value: Float
|
14
|
+
# @rbs return: F32
|
15
|
+
def F32: (Float value) -> F32
|
16
|
+
|
17
|
+
# @rbs value: Float
|
18
|
+
# @rbs return: F64
|
19
|
+
def F64: (Float value) -> F64
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# @rbs value: Integer
|
24
|
+
# @rbs return: Integer
|
25
|
+
def as_u32: (Integer value) -> Integer
|
26
|
+
|
27
|
+
# @rbs value: Integer
|
28
|
+
# @rbs return: Integer
|
29
|
+
def as_u64: (Integer value) -> Integer
|
30
|
+
end
|
31
|
+
|
32
|
+
extend ValueHelper
|
33
|
+
|
4
34
|
class I32
|
35
|
+
include ValueHelper
|
36
|
+
|
37
|
+
I32_MAX: untyped
|
38
|
+
|
39
|
+
# value should be stored as unsigned Integer, even in I32/I64
|
40
|
+
# when we want to access signed value, it'd be done via #value_s
|
5
41
|
attr_accessor value: Integer
|
6
42
|
|
43
|
+
# @rbs str: String
|
44
|
+
# @rbs size: Integer|nil
|
45
|
+
# @rbs signed: bool
|
46
|
+
# @rbs return: I32
|
47
|
+
def self.from_bytes: (String str, ?size: Integer | nil, ?signed: bool) -> I32
|
48
|
+
|
49
|
+
# @rbs return: Integer
|
50
|
+
def memsize: () -> Integer
|
51
|
+
|
52
|
+
# returns a value interpreted as signed integer
|
53
|
+
# @rbs return: Integer
|
54
|
+
def value_s: () -> Integer
|
55
|
+
|
7
56
|
# TODO: eliminate use of pack, to support mruby - in this file!
|
57
|
+
# @rbs size: Integer|nil
|
8
58
|
# @rbs return: String
|
9
|
-
def packed: () -> String
|
59
|
+
def packed: (?size: Integer | nil) -> String
|
60
|
+
|
61
|
+
# @rbs to: Symbol
|
62
|
+
# @rbs return: I32|I64|F32|F64
|
63
|
+
def wrap: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
64
|
+
|
65
|
+
# @rbs to: Symbol
|
66
|
+
# @rbs return: I32|I64|F32|F64
|
67
|
+
def extend_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
68
|
+
|
69
|
+
# @rbs to: Symbol
|
70
|
+
# @rbs return: I32|I64|F32|F64
|
71
|
+
def extend_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
72
|
+
|
73
|
+
# @rbs to: Symbol
|
74
|
+
# @rbs return: I32|I64|F32|F64
|
75
|
+
def trunc_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
76
|
+
|
77
|
+
# @rbs to: Symbol
|
78
|
+
# @rbs return: I32|I64|F32|F64
|
79
|
+
def trunc_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
80
|
+
|
81
|
+
# @rbs to: Symbol
|
82
|
+
# @rbs return: I32|I64|F32|F64
|
83
|
+
def convert_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
84
|
+
|
85
|
+
# @rbs to: Symbol
|
86
|
+
# @rbs return: I32|I64|F32|F64
|
87
|
+
def convert_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
10
88
|
|
89
|
+
# @rbs to: Symbol
|
90
|
+
# @rbs return: I32|I64|F32|F64
|
91
|
+
def demote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
92
|
+
|
93
|
+
# @rbs to: Symbol
|
94
|
+
# @rbs return: I32|I64|F32|F64
|
95
|
+
def promote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
96
|
+
|
97
|
+
# @rbs to: Symbol
|
98
|
+
# @rbs return: I32|I64|F32|F64
|
99
|
+
def reinterpret: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
100
|
+
|
101
|
+
# I32#inspect shows signed value for convinience
|
11
102
|
def inspect: () -> untyped
|
12
103
|
end
|
13
104
|
|
14
105
|
class I64
|
106
|
+
include ValueHelper
|
107
|
+
|
108
|
+
I64_MAX: untyped
|
109
|
+
|
15
110
|
attr_accessor value: Integer
|
16
111
|
|
112
|
+
# @rbs str: String
|
113
|
+
# @rbs size: Integer|nil
|
114
|
+
# @rbs signed: bool
|
115
|
+
# @rbs return: I64
|
116
|
+
def self.from_bytes: (String str, ?size: Integer | nil, ?signed: bool) -> I64
|
117
|
+
|
118
|
+
# @rbs return: Integer
|
119
|
+
def memsize: () -> Integer
|
120
|
+
|
121
|
+
# returns a value interpreted as signed integer
|
122
|
+
# @rbs return: Integer
|
123
|
+
def value_s: () -> Integer
|
124
|
+
|
125
|
+
# @rbs size: Integer|nil
|
17
126
|
# @rbs return: String
|
18
|
-
def packed: () -> String
|
127
|
+
def packed: (?size: Integer | nil) -> String
|
128
|
+
|
129
|
+
# @rbs to: Symbol
|
130
|
+
# @rbs return: I32|I64|F32|F64
|
131
|
+
def wrap: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
132
|
+
|
133
|
+
# @rbs to: Symbol
|
134
|
+
# @rbs return: I32|I64|F32|F64
|
135
|
+
def extend_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
136
|
+
|
137
|
+
# @rbs to: Symbol
|
138
|
+
# @rbs return: I32|I64|F32|F64
|
139
|
+
def extend_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
19
140
|
|
141
|
+
# @rbs to: Symbol
|
142
|
+
# @rbs return: I32|I64|F32|F64
|
143
|
+
def trunc_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
144
|
+
|
145
|
+
# @rbs to: Symbol
|
146
|
+
# @rbs return: I32|I64|F32|F64
|
147
|
+
def trunc_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
148
|
+
|
149
|
+
# @rbs to: Symbol
|
150
|
+
# @rbs return: I32|I64|F32|F64
|
151
|
+
def convert_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
152
|
+
|
153
|
+
# @rbs to: Symbol
|
154
|
+
# @rbs return: I32|I64|F32|F64
|
155
|
+
def convert_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
156
|
+
|
157
|
+
# @rbs to: Symbol
|
158
|
+
# @rbs return: I32|I64|F32|F64
|
159
|
+
def demote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
160
|
+
|
161
|
+
# @rbs to: Symbol
|
162
|
+
# @rbs return: I32|I64|F32|F64
|
163
|
+
def promote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
164
|
+
|
165
|
+
# @rbs to: Symbol
|
166
|
+
# @rbs return: I32|I64|F32|F64
|
167
|
+
def reinterpret: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
168
|
+
|
169
|
+
# I64#inspect shows signed value
|
20
170
|
def inspect: () -> untyped
|
21
171
|
end
|
22
172
|
|
23
173
|
class F32
|
174
|
+
include ValueHelper
|
175
|
+
|
24
176
|
attr_accessor value: Float
|
25
177
|
|
178
|
+
# @rbs str: String
|
179
|
+
# @rbs return: F32
|
180
|
+
def self.from_bytes: (String str) -> F32
|
181
|
+
|
182
|
+
# @rbs return: Integer
|
183
|
+
def memsize: () -> Integer
|
184
|
+
|
185
|
+
# @rbs return: :positive|:negative
|
186
|
+
def sign: () -> (:positive | :negative)
|
187
|
+
|
188
|
+
# @rbs size: Integer|nil
|
26
189
|
# @rbs return: String
|
27
|
-
def packed: () -> String
|
190
|
+
def packed: (?size: Integer | nil) -> String
|
191
|
+
|
192
|
+
# @rbs to: Symbol
|
193
|
+
# @rbs return: I32|I64|F32|F64
|
194
|
+
def wrap: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
195
|
+
|
196
|
+
# @rbs to: Symbol
|
197
|
+
# @rbs return: I32|I64|F32|F64
|
198
|
+
def extend_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
199
|
+
|
200
|
+
# @rbs to: Symbol
|
201
|
+
# @rbs return: I32|I64|F32|F64
|
202
|
+
def extend_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
203
|
+
|
204
|
+
# @todo need more testcase...
|
205
|
+
# @see https://webassembly.github.io/spec/core/exec/numerics.html#xref-exec-numerics-op-trunc-s-mathrm-trunc-mathsf-s-m-n-z
|
206
|
+
# @rbs to: Symbol
|
207
|
+
# @rbs return: I32|I64|F32|F64
|
208
|
+
def trunc_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
209
|
+
|
210
|
+
# @see https://webassembly.github.io/spec/core/exec/numerics.html#xref-exec-numerics-op-trunc-u-mathrm-trunc-mathsf-u-m-n-z
|
211
|
+
# @rbs to: Symbol
|
212
|
+
# @rbs return: I32|I64|F32|F64
|
213
|
+
def trunc_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
214
|
+
|
215
|
+
# @rbs to: Symbol
|
216
|
+
# @rbs return: I32|I64|F32|F64
|
217
|
+
def convert_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
218
|
+
|
219
|
+
# @rbs to: Symbol
|
220
|
+
# @rbs return: I32|I64|F32|F64
|
221
|
+
def convert_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
222
|
+
|
223
|
+
# @rbs to: Symbol
|
224
|
+
# @rbs return: I32|I64|F32|F64
|
225
|
+
def demote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
226
|
+
|
227
|
+
# @rbs to: Symbol
|
228
|
+
# @rbs return: I32|I64|F32|F64
|
229
|
+
def promote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
230
|
+
|
231
|
+
# @rbs to: Symbol
|
232
|
+
# @rbs return: I32|I64|F32|F64
|
233
|
+
def reinterpret: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
28
234
|
|
29
235
|
def inspect: () -> untyped
|
30
236
|
end
|
31
237
|
|
32
238
|
class F64
|
239
|
+
include ValueHelper
|
240
|
+
|
33
241
|
attr_accessor value: Float
|
34
242
|
|
243
|
+
# @rbs str: String
|
244
|
+
# @rbs return: F64
|
245
|
+
def self.from_bytes: (String str) -> F64
|
246
|
+
|
247
|
+
# @rbs return: Integer
|
248
|
+
def memsize: () -> Integer
|
249
|
+
|
250
|
+
# @rbs return: :positive|:negative
|
251
|
+
def sign: () -> (:positive | :negative)
|
252
|
+
|
253
|
+
# @rbs size: Integer|nil
|
35
254
|
# @rbs return: String
|
36
|
-
def packed: () -> String
|
255
|
+
def packed: (?size: Integer | nil) -> String
|
37
256
|
|
38
|
-
|
39
|
-
|
257
|
+
# @rbs to: Symbol
|
258
|
+
# @rbs return: I32|I64|F32|F64
|
259
|
+
def wrap: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
40
260
|
|
41
|
-
|
42
|
-
# @rbs
|
43
|
-
|
44
|
-
def I32: (Integer value) -> I32
|
261
|
+
# @rbs to: Symbol
|
262
|
+
# @rbs return: I32|I64|F32|F64
|
263
|
+
def extend_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
45
264
|
|
46
|
-
# @rbs
|
47
|
-
# @rbs return: I64
|
48
|
-
def
|
265
|
+
# @rbs to: Symbol
|
266
|
+
# @rbs return: I32|I64|F32|F64
|
267
|
+
def extend_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
49
268
|
|
50
|
-
# @
|
51
|
-
# @rbs
|
52
|
-
|
269
|
+
# @see the same as F32
|
270
|
+
# @rbs to: Symbol
|
271
|
+
# @rbs return: I32|I64|F32|F64
|
272
|
+
def trunc_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
53
273
|
|
54
|
-
# @
|
55
|
-
# @rbs
|
56
|
-
|
274
|
+
# @see the same as F32
|
275
|
+
# @rbs to: Symbol
|
276
|
+
# @rbs return: I32|I64|F32|F64
|
277
|
+
def trunc_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
278
|
+
|
279
|
+
# @rbs to: Symbol
|
280
|
+
# @rbs return: I32|I64|F32|F64
|
281
|
+
def convert_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
282
|
+
|
283
|
+
# @rbs to: Symbol
|
284
|
+
# @rbs return: I32|I64|F32|F64
|
285
|
+
def convert_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
286
|
+
|
287
|
+
# @todo no loss of digits...
|
288
|
+
# @rbs to: Symbol
|
289
|
+
# @rbs return: I32|I64|F32|F64
|
290
|
+
def demote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
291
|
+
|
292
|
+
# @rbs to: Symbol
|
293
|
+
# @rbs return: I32|I64|F32|F64
|
294
|
+
def promote: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
295
|
+
|
296
|
+
# @rbs to: Symbol
|
297
|
+
# @rbs return: I32|I64|F32|F64
|
298
|
+
def reinterpret: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
299
|
+
|
300
|
+
def inspect: () -> untyped
|
57
301
|
end
|
58
302
|
end
|