wardite 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +178 -0
- data/Steepfile +1 -0
- data/examples/consts.wat +12 -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 +457 -0
- data/lib/wardite/alu_i64.generated.rb +514 -0
- data/lib/wardite/convert.generated.rb +234 -0
- data/lib/wardite/instruction.rb +82 -33
- data/lib/wardite/leb128.rb +1 -1
- data/lib/wardite/value.rb +627 -0
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi.rb +6 -4
- data/lib/wardite.rb +192 -115
- data/scripts/gen_alu.rb +750 -0
- data/scripts/gen_conv.rb +76 -0
- data/scripts/templates/alu_module.rb.tmpl +18 -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_i32.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 +15 -6
- data/sig/generated/wardite/leb128.rbs +1 -1
- data/sig/generated/wardite/value.rbs +302 -0
- data/sig/generated/wardite/wasi.rbs +4 -2
- data/sig/generated/wardite.rbs +27 -12
- metadata +19 -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.${PREFIX}_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,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_i32.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.i32_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
|
@@ -1,19 +1,28 @@
|
|
1
1
|
# Generated from lib/wardite/instruction.rb with RBS::Inline
|
2
2
|
|
3
|
-
# rbs_inline: enabled
|
4
3
|
module Wardite
|
5
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
|
+
|
11
|
+
attr_accessor namespace: Symbol
|
12
|
+
|
6
13
|
attr_accessor code: Symbol
|
7
14
|
|
8
|
-
|
15
|
+
# TODO: add types of potential operands
|
16
|
+
attr_accessor operand: Array[Integer | Float | Block]
|
9
17
|
|
18
|
+
# @rbs namespace: Symbol
|
10
19
|
# @rbs code: Symbol
|
11
|
-
# @rbs operand: Array[
|
12
|
-
def initialize: (Symbol code, Array[
|
20
|
+
# @rbs operand: Array[Integer|Float|Block]
|
21
|
+
def initialize: (Symbol namespace, Symbol code, Array[Integer | Float | Block] operand) -> untyped
|
13
22
|
|
14
23
|
# @rbs chr: String
|
15
|
-
# @rbs return: Symbol
|
16
|
-
def self.to_sym: (String chr) -> Symbol
|
24
|
+
# @rbs return: [Symbol, Symbol]
|
25
|
+
def self.to_sym: (String chr) -> [ Symbol, Symbol ]
|
17
26
|
|
18
27
|
# @rbs chr: Symbol
|
19
28
|
# @rbs return: Array[Symbol]
|
@@ -0,0 +1,302 @@
|
|
1
|
+
# Generated from lib/wardite/value.rb with RBS::Inline
|
2
|
+
|
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
|
+
|
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
|
41
|
+
attr_accessor value: Integer
|
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
|
+
|
56
|
+
# TODO: eliminate use of pack, to support mruby - in this file!
|
57
|
+
# @rbs size: Integer|nil
|
58
|
+
# @rbs return: 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)
|
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
|
102
|
+
def inspect: () -> untyped
|
103
|
+
end
|
104
|
+
|
105
|
+
class I64
|
106
|
+
include ValueHelper
|
107
|
+
|
108
|
+
I64_MAX: untyped
|
109
|
+
|
110
|
+
attr_accessor value: Integer
|
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
|
126
|
+
# @rbs return: 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)
|
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
|
170
|
+
def inspect: () -> untyped
|
171
|
+
end
|
172
|
+
|
173
|
+
class F32
|
174
|
+
include ValueHelper
|
175
|
+
|
176
|
+
attr_accessor value: Float
|
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
|
189
|
+
# @rbs return: 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)
|
234
|
+
|
235
|
+
def inspect: () -> untyped
|
236
|
+
end
|
237
|
+
|
238
|
+
class F64
|
239
|
+
include ValueHelper
|
240
|
+
|
241
|
+
attr_accessor value: Float
|
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
|
254
|
+
# @rbs return: String
|
255
|
+
def packed: (?size: Integer | nil) -> String
|
256
|
+
|
257
|
+
# @rbs to: Symbol
|
258
|
+
# @rbs return: I32|I64|F32|F64
|
259
|
+
def wrap: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
260
|
+
|
261
|
+
# @rbs to: Symbol
|
262
|
+
# @rbs return: I32|I64|F32|F64
|
263
|
+
def extend_s: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
264
|
+
|
265
|
+
# @rbs to: Symbol
|
266
|
+
# @rbs return: I32|I64|F32|F64
|
267
|
+
def extend_u: (to: Symbol) -> (I32 | I64 | F32 | F64)
|
268
|
+
|
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)
|
273
|
+
|
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
|
301
|
+
end
|
302
|
+
end
|
@@ -3,14 +3,16 @@
|
|
3
3
|
# rbs_inline: enabled
|
4
4
|
module Wardite
|
5
5
|
class WasiSnapshotPreview1
|
6
|
+
include ValueHelper
|
7
|
+
|
6
8
|
attr_accessor fd_table: Array[IO]
|
7
9
|
|
8
10
|
def initialize: () -> untyped
|
9
11
|
|
10
12
|
# @rbs store: Store
|
11
|
-
# @rbs args: Array[
|
13
|
+
# @rbs args: Array[I32|I64|F32|F64]
|
12
14
|
# @rbs return: Object
|
13
|
-
def fd_write: (Store store, Array[
|
15
|
+
def fd_write: (Store store, Array[I32 | I64 | F32 | F64] args) -> Object
|
14
16
|
|
15
17
|
# @rbs return: Hash[Symbol, Proc]
|
16
18
|
def to_module: () -> Hash[Symbol, Proc]
|
data/sig/generated/wardite.rbs
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Generated from lib/wardite.rb with RBS::Inline
|
2
2
|
|
3
|
+
module Wardite
|
4
|
+
module Evaluator
|
5
|
+
extend Wardite::ValueHelper
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
module Wardite
|
4
10
|
class Section
|
5
11
|
attr_accessor name: String
|
@@ -107,7 +113,9 @@ module Wardite
|
|
107
113
|
end
|
108
114
|
|
109
115
|
module BinaryLoader
|
110
|
-
extend Wardite::
|
116
|
+
extend Wardite::Leb128Helper
|
117
|
+
|
118
|
+
extend Wardite::ValueHelper
|
111
119
|
|
112
120
|
# @rbs buf: File|StringIO
|
113
121
|
# @rbs import_object: Hash[Symbol, Hash[Symbol, Proc]]
|
@@ -204,7 +212,10 @@ module Wardite
|
|
204
212
|
end
|
205
213
|
|
206
214
|
class Runtime
|
207
|
-
|
215
|
+
include ValueHelper
|
216
|
+
|
217
|
+
# TODO: add types of class that the stack accomodates
|
218
|
+
attr_accessor stack: Array[I32 | I64 | F32 | F64]
|
208
219
|
|
209
220
|
attr_accessor call_stack: Array[Frame]
|
210
221
|
|
@@ -222,11 +233,6 @@ module Wardite
|
|
222
233
|
# @rbs return: Object|nil
|
223
234
|
def call: (String | Symbol name, Array[Object] args) -> (Object | nil)
|
224
235
|
|
225
|
-
# @rbs idx: Integer
|
226
|
-
# @rbs args: Array[Object]
|
227
|
-
# @rbs return: Object|nil
|
228
|
-
def call_index: (Integer idx, Array[Object] args) -> (Object | nil)
|
229
|
-
|
230
236
|
# @rbs wasm_function: WasmFunction
|
231
237
|
# @rbs return: void
|
232
238
|
def push_frame: (WasmFunction wasm_function) -> void
|
@@ -236,8 +242,8 @@ module Wardite
|
|
236
242
|
def invoke_internal: (WasmFunction wasm_function) -> (Object | nil)
|
237
243
|
|
238
244
|
# @rbs external_function: ExternalFunction
|
239
|
-
# @rbs return:
|
240
|
-
def invoke_external: (ExternalFunction external_function) -> (
|
245
|
+
# @rbs return: I32|I64|F32|F64|nil
|
246
|
+
def invoke_external: (ExternalFunction external_function) -> (I32 | I64 | F32 | F64 | nil)
|
241
247
|
|
242
248
|
# @rbs return: void
|
243
249
|
def execute!: () -> void
|
@@ -259,8 +265,8 @@ module Wardite
|
|
259
265
|
def stack_unwind: (Integer sp, Integer arity) -> void
|
260
266
|
|
261
267
|
# @rbs finish: Integer
|
262
|
-
# @rbs return: Array[
|
263
|
-
def drained_stack: (Integer finish) -> Array[
|
268
|
+
# @rbs return: Array[I32|I64|F32|F64]
|
269
|
+
def drained_stack: (Integer finish) -> Array[I32 | I64 | F32 | F64]
|
264
270
|
|
265
271
|
# @rbs name: Symbol
|
266
272
|
# @rbs args: Array[Object]
|
@@ -283,7 +289,7 @@ module Wardite
|
|
283
289
|
|
284
290
|
attr_accessor labels: Array[Label]
|
285
291
|
|
286
|
-
attr_accessor locals: Array[
|
292
|
+
attr_accessor locals: Array[I32 | I64 | F32 | F64]
|
287
293
|
|
288
294
|
# @rbs pc: Integer
|
289
295
|
# @rbs sp: Integer
|
@@ -327,6 +333,8 @@ module Wardite
|
|
327
333
|
class Memory
|
328
334
|
attr_accessor data: String
|
329
335
|
|
336
|
+
attr_accessor current: Integer
|
337
|
+
|
330
338
|
attr_accessor max: Integer | nil
|
331
339
|
|
332
340
|
# @rbs min: Integer
|
@@ -334,6 +342,10 @@ module Wardite
|
|
334
342
|
# @rbs return: void
|
335
343
|
def initialize: (Integer min, Integer | nil max) -> void
|
336
344
|
|
345
|
+
# @rbs delta: Integer
|
346
|
+
# @rbs return: Integer
|
347
|
+
def grow: (Integer delta) -> Integer
|
348
|
+
|
337
349
|
def inspect: () -> untyped
|
338
350
|
end
|
339
351
|
|
@@ -431,6 +443,9 @@ module Wardite
|
|
431
443
|
class EvalError < StandardError
|
432
444
|
end
|
433
445
|
|
446
|
+
class Unreachable < StandardError
|
447
|
+
end
|
448
|
+
|
434
449
|
# @rbs path: String|nil
|
435
450
|
# @rbs buffer: File|StringIO|nil
|
436
451
|
# @rbs **options: Hash[Symbol, Object]
|