wardite 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '02079b17ada50d21f00ea34c1830452eea21ff12a2fb6e9c5903d07cdca53d3a'
4
- data.tar.gz: 9ab24caf2cc630593ce32ab652c8044a621f67ddce1cb70f75a1cd9e767b13e2
3
+ metadata.gz: a6335000832a623233f1a9719fe271fa4a000270bc55312fc996fe3f4e72bad9
4
+ data.tar.gz: d72874301c47400a24fa9992de296d5d490c04d2c6f1dad2b76493f7eed3b464
5
5
  SHA512:
6
- metadata.gz: 88054ffba3884002ea3ff7c63b21a38ff41a93f2e641ec7b82cf39f47e7df7672c5c6412f4efd1ca9feb6e222aaaadf98e67a40810c8ed213046df348aac8f79
7
- data.tar.gz: 1c5b8765bff6ae42eb00c696efd8af2c6b892911d52fc68a1124fb3804419f121f886ba416b6b39b3183afa22e1f6aadf730681c004f254796c5e6934ab39da1
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 :i32_extend_8_s
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 :i32_extend_16_s
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 :i64_extend_8_s
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 :i64_extend_16_s
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 :i64_extend_32_s
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)
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Wardite
5
- VERSION = "0.4.1" #: String
5
+ VERSION = "0.4.2" #: String
6
6
  end
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.locals_type.each_with_index do |typ, i|
314
- case typ
315
- when :i32, :u32
316
- locals.push I32(0)
317
- when :i64, :u64
318
- locals.push I64(0)
319
- else
320
- $stderr.puts "warning: unknown type #{typ.inspect}. default to I32"
321
- locals.push I32(0)
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
- raise EvalError, "local not found"
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}_extend_#{from_size}_#{suffix}"
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)$/, "")
@@ -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.1
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-10 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A pure-ruby webassembly runtime
14
14
  email: