wardite 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wardite/convert.generated.rb +5 -5
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite.rb +28 -10
- data/scripts/gen_conv.rb +1 -1
- data/sig/generated/wardite.rbs +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6335000832a623233f1a9719fe271fa4a000270bc55312fc996fe3f4e72bad9
|
4
|
+
data.tar.gz: d72874301c47400a24fa9992de296d5d490c04d2c6f1dad2b76493f7eed3b464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d3a12027244cac1cc6efeb382a6a164c070946a85886eae1915c90360a6c139766ae2780103511bf1e332418576a6dbdc1fd7ca7266a2974dd228d24155bedb
|
7
|
+
data.tar.gz: 282d5051760ca800a876daaa1962bea603961ce3fc4551560255030c433e445ba0efc945b75b5829112a6742b6492142ad3c2a1d577f30816bcf76f39bd58f2e
|
@@ -58,7 +58,7 @@ module Wardite
|
|
58
58
|
runtime.stack.push(to)
|
59
59
|
|
60
60
|
|
61
|
-
when :
|
61
|
+
when :i32_extend8_s
|
62
62
|
from = runtime.stack.pop
|
63
63
|
raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
|
64
64
|
to = from.extendN_s(to: :i32, from: :i8)
|
@@ -66,7 +66,7 @@ module Wardite
|
|
66
66
|
runtime.stack.push(to)
|
67
67
|
|
68
68
|
|
69
|
-
when :
|
69
|
+
when :i32_extend16_s
|
70
70
|
from = runtime.stack.pop
|
71
71
|
raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
|
72
72
|
to = from.extendN_s(to: :i32, from: :i16)
|
@@ -178,7 +178,7 @@ module Wardite
|
|
178
178
|
runtime.stack.push(to)
|
179
179
|
|
180
180
|
|
181
|
-
when :
|
181
|
+
when :i64_extend8_s
|
182
182
|
from = runtime.stack.pop
|
183
183
|
raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
|
184
184
|
to = from.extendN_s(to: :i64, from: :i8)
|
@@ -186,7 +186,7 @@ module Wardite
|
|
186
186
|
runtime.stack.push(to)
|
187
187
|
|
188
188
|
|
189
|
-
when :
|
189
|
+
when :i64_extend16_s
|
190
190
|
from = runtime.stack.pop
|
191
191
|
raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
|
192
192
|
to = from.extendN_s(to: :i64, from: :i16)
|
@@ -194,7 +194,7 @@ module Wardite
|
|
194
194
|
runtime.stack.push(to)
|
195
195
|
|
196
196
|
|
197
|
-
when :
|
197
|
+
when :i64_extend32_s
|
198
198
|
from = runtime.stack.pop
|
199
199
|
raise EvalError, "maybe empty or invalid stack" if !from.is_a?(I32)
|
200
200
|
to = from.extendN_s(to: :i64, from: :i32)
|
data/lib/wardite/version.rb
CHANGED
data/lib/wardite.rb
CHANGED
@@ -310,20 +310,28 @@ module Wardite
|
|
310
310
|
end
|
311
311
|
self.stack = drained_stack(local_start)
|
312
312
|
|
313
|
-
wasm_function.
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
313
|
+
wasm_function.locals_count.each_with_index do |count, i|
|
314
|
+
typ = wasm_function.locals_type[i]
|
315
|
+
count.times do
|
316
|
+
case typ
|
317
|
+
when :i32, :u32
|
318
|
+
locals.push I32(0)
|
319
|
+
when :i64, :u64
|
320
|
+
locals.push I64(0)
|
321
|
+
when :f32
|
322
|
+
locals.push F32(0.0)
|
323
|
+
when :f64
|
324
|
+
locals.push F64(0.0)
|
325
|
+
else
|
326
|
+
$stderr.puts "warning: unknown type #{typ.inspect}. default to I32"
|
327
|
+
locals.push I32(0)
|
328
|
+
end
|
322
329
|
end
|
323
330
|
end
|
324
331
|
|
325
332
|
arity = wasm_function.retsig.size
|
326
333
|
frame = Frame.new(-1, stack.size, wasm_function.body, arity, locals)
|
334
|
+
frame.findex = wasm_function.findex
|
327
335
|
self.call_stack.push(frame)
|
328
336
|
end
|
329
337
|
|
@@ -593,7 +601,8 @@ module Wardite
|
|
593
601
|
end
|
594
602
|
local = frame.locals[idx]
|
595
603
|
if !local
|
596
|
-
|
604
|
+
# require "irb"; binding.irb
|
605
|
+
raise EvalError, "local not found, idx = #{idx}"
|
597
606
|
end
|
598
607
|
stack.push(local)
|
599
608
|
|
@@ -884,6 +893,8 @@ module Wardite
|
|
884
893
|
|
885
894
|
attr_accessor :locals #: Array[wasmValue]
|
886
895
|
|
896
|
+
attr_accessor :findex #: Integer
|
897
|
+
|
887
898
|
# @rbs pc: Integer
|
888
899
|
# @rbs sp: Integer
|
889
900
|
# @rbs body: Array[Op]
|
@@ -897,6 +908,8 @@ module Wardite
|
|
897
908
|
@arity = arity
|
898
909
|
@locals = locals
|
899
910
|
@labels = []
|
911
|
+
|
912
|
+
@findex = 0
|
900
913
|
end
|
901
914
|
end
|
902
915
|
|
@@ -970,6 +983,8 @@ module Wardite
|
|
970
983
|
retsig = type_section.defined_results[sigindex]
|
971
984
|
codes = code_section.func_codes[findex]
|
972
985
|
wasm_function = WasmFunction.new(callsig, retsig, codes)
|
986
|
+
idx = self.funcs.size
|
987
|
+
wasm_function.findex = idx
|
973
988
|
self.funcs << wasm_function
|
974
989
|
end
|
975
990
|
end
|
@@ -1233,6 +1248,8 @@ module Wardite
|
|
1233
1248
|
|
1234
1249
|
attr_accessor :code_body #: CodeSection::CodeBody
|
1235
1250
|
|
1251
|
+
attr_accessor :findex #: Integer
|
1252
|
+
|
1236
1253
|
# @rbs callsig: Array[Symbol]
|
1237
1254
|
# @rbs retsig: Array[Symbol]
|
1238
1255
|
# @rbs code_body: CodeSection::CodeBody
|
@@ -1242,6 +1259,7 @@ module Wardite
|
|
1242
1259
|
@retsig = retsig
|
1243
1260
|
|
1244
1261
|
@code_body = code_body
|
1262
|
+
@findex = 0 # for debug
|
1245
1263
|
end
|
1246
1264
|
|
1247
1265
|
# @rbs return: Array[Op]
|
data/scripts/gen_conv.rb
CHANGED
@@ -46,7 +46,7 @@ module GenConv
|
|
46
46
|
elsif method =~ /^extendN_(u|s)$/
|
47
47
|
suffix = $1
|
48
48
|
from_size = from.to_s.scan(/\d+/).join
|
49
|
-
symbol = "#{to.to_s}
|
49
|
+
symbol = "#{to.to_s}_extend#{from_size}_#{suffix}"
|
50
50
|
extra_kargs = ", from: :#{from.to_s}"
|
51
51
|
elsif method.end_with?("_s") or method.end_with?("_u")
|
52
52
|
core = method.sub(/_(s|u)$/, "")
|
data/sig/generated/wardite.rbs
CHANGED
@@ -175,6 +175,8 @@ module Wardite
|
|
175
175
|
|
176
176
|
attr_accessor locals: Array[wasmValue]
|
177
177
|
|
178
|
+
attr_accessor findex: Integer
|
179
|
+
|
178
180
|
# @rbs pc: Integer
|
179
181
|
# @rbs sp: Integer
|
180
182
|
# @rbs body: Array[Op]
|
@@ -334,6 +336,8 @@ module Wardite
|
|
334
336
|
|
335
337
|
attr_accessor code_body: CodeSection::CodeBody
|
336
338
|
|
339
|
+
attr_accessor findex: Integer
|
340
|
+
|
337
341
|
# @rbs callsig: Array[Symbol]
|
338
342
|
# @rbs retsig: Array[Symbol]
|
339
343
|
# @rbs code_body: CodeSection::CodeBody
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wardite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uchio Kondo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A pure-ruby webassembly runtime
|
14
14
|
email:
|