konpeito 0.2.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/konpeito/codegen/builtin_methods.rb +7 -27
- data/lib/konpeito/codegen/inliner.rb +55 -1
- data/lib/konpeito/codegen/jvm_generator.rb +1256 -133
- data/lib/konpeito/codegen/llvm_generator.rb +492 -96
- data/lib/konpeito/codegen/monomorphizer.rb +53 -1
- data/lib/konpeito/hir/builder.rb +198 -57
- data/lib/konpeito/type_checker/hm_inferrer.rb +30 -4
- data/lib/konpeito/type_checker/unification.rb +37 -0
- data/lib/konpeito/version.rb +1 -1
- data/tools/konpeito-asm/build.sh +1 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KArray.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/RubyDispatch.class +0 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KArray.java +82 -1
- data/tools/konpeito-asm/src/konpeito/runtime/RubyDispatch.java +1821 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3daf2b84b1f0d775d0cc7ca3a3ed5937f82a44d44a068131b62a326049893f5d
|
|
4
|
+
data.tar.gz: 0ebda1e25a79a24d8bbed4376d048945a595202060802315d69eebf23293be2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 355daf3587c553762d23be9cf1620a08f87c13afc825114cb4b6413e64a33ca7173a5c569109c21745390732a603ade72d3cca8c67c5953b5418fbfe8b94fd18
|
|
7
|
+
data.tar.gz: 50b4130ab80368df57e5466e4b0faadebdd40f385b018cdcc1a3f8b1da6557c0ae559b55b277b3f0619a47ff1edbf9a18b0ad153fc044a4707649f2c9c54f3f3
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ All notable changes to Konpeito will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.2] - 2026-02-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Conformance test suite expansion: 41 spec files with 1,009 assertions covering core Ruby language features
|
|
12
|
+
- JVM runtime: comprehensive method dispatch for String, Array, Hash, Integer, Float, Symbol, Range, Regexp, MatchData in RubyDispatch
|
|
13
|
+
- JVM runtime: KArray methods — flatten, compact, zip, take, drop, rotate, sample
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- JVM backend: VerifyError for double parameter slot reuse — `_nil_assigned_vars` now infers types from HIR annotations for non-literal values instead of falsely tagging as mixed-type
|
|
17
|
+
- Native backend: monomorphizer now skips specialization for functions that compare parameters with nil (fixes `assert_nil` crash on out-of-bounds array access)
|
|
18
|
+
- Native backend: for-loop rewritten to index-based while loop, enabling break/next inside for bodies
|
|
19
|
+
- Native backend: enumerable, string_methods, symbol conformance fixes
|
|
20
|
+
|
|
8
21
|
## [0.2.1] - 2026-02-20
|
|
9
22
|
|
|
10
23
|
### Added
|
|
@@ -131,6 +144,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
131
144
|
- `%a{extern}` - external C struct wrappers
|
|
132
145
|
- `%a{simd}` - SIMD vectorization
|
|
133
146
|
|
|
147
|
+
[0.2.2]: https://github.com/i2y/konpeito/compare/v0.2.1...v0.2.2
|
|
134
148
|
[0.2.1]: https://github.com/i2y/konpeito/compare/v0.2.0...v0.2.1
|
|
135
149
|
[0.2.0]: https://github.com/i2y/konpeito/compare/v0.1.3...v0.2.0
|
|
136
150
|
[0.1.3]: https://github.com/i2y/konpeito/compare/v0.1.2...v0.1.3
|
|
@@ -142,7 +142,7 @@ module Konpeito
|
|
|
142
142
|
|
|
143
143
|
Object: {
|
|
144
144
|
# Object identity and comparison
|
|
145
|
-
|
|
145
|
+
# rb_obj_equal is not exported - == falls back to rb_funcallv
|
|
146
146
|
:=== => { c_func: "rb_equal", arity: 1, return_type: :Bool, conv: :simple },
|
|
147
147
|
|
|
148
148
|
# Object type checking
|
|
@@ -177,38 +177,18 @@ module Konpeito
|
|
|
177
177
|
none?: { arity: 0, return_type: :Bool, conv: :block_iterator },
|
|
178
178
|
},
|
|
179
179
|
|
|
180
|
-
Float:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
# Float conversion
|
|
185
|
-
to_i: { c_func: "rb_num2long", arity: 0, return_type: :Integer, conv: :simple },
|
|
186
|
-
to_int: { c_func: "rb_num2long", arity: 0, return_type: :Integer, conv: :simple },
|
|
187
|
-
floor: { c_func: "rb_float_floor", arity: 0, return_type: :Integer, conv: :simple },
|
|
188
|
-
ceil: { c_func: "rb_float_ceil", arity: 0, return_type: :Integer, conv: :simple },
|
|
189
|
-
round: { c_func: "rb_float_round", arity: 0, return_type: :Integer, conv: :simple },
|
|
190
|
-
truncate: { c_func: "rb_float_truncate", arity: 0, return_type: :Integer, conv: :simple },
|
|
191
|
-
|
|
192
|
-
# Float query
|
|
193
|
-
nan?: { c_func: "rb_float_nan_p", arity: 0, return_type: :Bool, conv: :simple },
|
|
194
|
-
infinite?: { c_func: "rb_float_infinite_p", arity: 0, return_type: :Any, conv: :simple },
|
|
195
|
-
finite?: { c_func: "rb_float_finite_p", arity: 0, return_type: :Bool, conv: :simple },
|
|
196
|
-
},
|
|
180
|
+
# Float methods: rb_float_cmp, rb_float_floor, rb_float_ceil, rb_float_round,
|
|
181
|
+
# rb_float_truncate, rb_float_nan_p, rb_float_infinite_p, rb_float_finite_p
|
|
182
|
+
# are all NOT exported from libruby — they fall back to rb_funcallv
|
|
197
183
|
|
|
198
184
|
NilClass: {
|
|
199
|
-
|
|
200
|
-
to_s: { c_func: "rb_nil_to_s", arity: 0, return_type: :String, conv: :simple },
|
|
185
|
+
# rb_true is not exported from libruby - nil? falls back to rb_funcallv
|
|
201
186
|
to_a: { c_func: "rb_ary_new", arity: 0, return_type: :Array, conv: :simple },
|
|
202
187
|
to_h: { c_func: "rb_hash_new", arity: 0, return_type: :Hash, conv: :simple },
|
|
203
188
|
},
|
|
204
189
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
FalseClass: {
|
|
210
|
-
to_s: { c_func: "rb_false_to_s", arity: 0, return_type: :String, conv: :simple },
|
|
211
|
-
},
|
|
190
|
+
# rb_true_to_s / rb_false_to_s are not exported from libruby
|
|
191
|
+
# TrueClass and FalseClass methods fall back to rb_funcallv
|
|
212
192
|
}.freeze
|
|
213
193
|
|
|
214
194
|
# Helper method to look up a builtin method
|
|
@@ -298,7 +298,8 @@ module Konpeito
|
|
|
298
298
|
args: new_args,
|
|
299
299
|
block: inst.block,
|
|
300
300
|
type: inst.type,
|
|
301
|
-
result_var: new_result
|
|
301
|
+
result_var: new_result,
|
|
302
|
+
safe_navigation: inst.safe_navigation
|
|
302
303
|
)
|
|
303
304
|
|
|
304
305
|
when HIR::IntegerLit, HIR::FloatLit, HIR::StringLit,
|
|
@@ -475,6 +476,10 @@ module Konpeito
|
|
|
475
476
|
new_value = transform_value(inst.value, prefix, param_map)
|
|
476
477
|
HIR::StoreConstant.new(name: inst.name, value: new_value, scope: inst.scope, type: inst.type)
|
|
477
478
|
|
|
479
|
+
when HIR::DefinedCheck
|
|
480
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
481
|
+
HIR::DefinedCheck.new(check_type: inst.check_type, name: inst.name, type: inst.type, result_var: new_result)
|
|
482
|
+
|
|
478
483
|
when HIR::SuperCall
|
|
479
484
|
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
480
485
|
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
@@ -491,6 +496,36 @@ module Konpeito
|
|
|
491
496
|
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
492
497
|
HIR::ProcCall.new(proc_value: new_proc, args: new_args, type: inst.type, result_var: new_result)
|
|
493
498
|
|
|
499
|
+
when HIR::FiberNew
|
|
500
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
501
|
+
new_block_def = clone_block_def(inst.block_def, prefix, param_map)
|
|
502
|
+
HIR::FiberNew.new(block_def: new_block_def, result_var: new_result)
|
|
503
|
+
|
|
504
|
+
when HIR::FiberResume
|
|
505
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
506
|
+
new_fiber = transform_value(inst.fiber, prefix, param_map)
|
|
507
|
+
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
508
|
+
HIR::FiberResume.new(fiber: new_fiber, args: new_args, type: inst.type, result_var: new_result)
|
|
509
|
+
|
|
510
|
+
when HIR::FiberYield
|
|
511
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
512
|
+
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
513
|
+
HIR::FiberYield.new(args: new_args, type: inst.type, result_var: new_result)
|
|
514
|
+
|
|
515
|
+
when HIR::FiberAlive
|
|
516
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
517
|
+
new_fiber = transform_value(inst.fiber, prefix, param_map)
|
|
518
|
+
HIR::FiberAlive.new(fiber: new_fiber, result_var: new_result)
|
|
519
|
+
|
|
520
|
+
when HIR::FiberCurrent
|
|
521
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
522
|
+
HIR::FiberCurrent.new(result_var: new_result)
|
|
523
|
+
|
|
524
|
+
when HIR::MultiWriteExtract
|
|
525
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
526
|
+
new_array = transform_value(inst.array, prefix, param_map)
|
|
527
|
+
HIR::MultiWriteExtract.new(array: new_array, index: inst.index, type: inst.type, result_var: new_result)
|
|
528
|
+
|
|
494
529
|
else
|
|
495
530
|
# For other instructions, just return as-is with renamed result
|
|
496
531
|
inst
|
|
@@ -509,6 +544,25 @@ module Konpeito
|
|
|
509
544
|
)
|
|
510
545
|
HIR::LoadLocal.new(var: new_var, type: value.type, result_var: nil)
|
|
511
546
|
end
|
|
547
|
+
when HIR::StringLit
|
|
548
|
+
# Clone literal with new result_var (don't convert to LoadLocal reference)
|
|
549
|
+
new_result = value.result_var ? prefix + value.result_var : nil
|
|
550
|
+
HIR::StringLit.new(value: value.value, result_var: new_result)
|
|
551
|
+
when HIR::IntegerLit
|
|
552
|
+
new_result = value.result_var ? prefix + value.result_var : nil
|
|
553
|
+
HIR::IntegerLit.new(value: value.value, result_var: new_result)
|
|
554
|
+
when HIR::FloatLit
|
|
555
|
+
new_result = value.result_var ? prefix + value.result_var : nil
|
|
556
|
+
HIR::FloatLit.new(value: value.value, result_var: new_result)
|
|
557
|
+
when HIR::BoolLit
|
|
558
|
+
new_result = value.result_var ? prefix + value.result_var : nil
|
|
559
|
+
HIR::BoolLit.new(value: value.value, result_var: new_result)
|
|
560
|
+
when HIR::SymbolLit
|
|
561
|
+
new_result = value.result_var ? prefix + value.result_var : nil
|
|
562
|
+
HIR::SymbolLit.new(value: value.value, result_var: new_result)
|
|
563
|
+
when HIR::NilLit
|
|
564
|
+
new_result = value.result_var ? prefix + value.result_var : nil
|
|
565
|
+
HIR::NilLit.new(result_var: new_result)
|
|
512
566
|
when HIR::Instruction
|
|
513
567
|
if value.result_var
|
|
514
568
|
# Create a LoadLocal to reference the renamed variable
|