feat: Extract BID converter from Copilot and prepare plugin migration
- Extract Copilot's BID converter code to src/bid-converter-copilot/ for future use - Create comprehensive plugin migration request document for Copilot - Target 13 built-in boxes for plugin conversion (HTTP, GUI, Audio, etc.) - Preserve existing nyash.toml-based plugin system - Reorganize docs/説明書/reference/ structure for better organization
This commit is contained in:
1
local_tests/test_just_42.nyash
Normal file
1
local_tests/test_just_42.nyash
Normal file
@ -0,0 +1 @@
|
||||
42
|
||||
11
local_tests/test_llvm_mock.nyash
Normal file
11
local_tests/test_llvm_mock.nyash
Normal file
@ -0,0 +1,11 @@
|
||||
// Test LLVM mock interpreter
|
||||
static box Main {
|
||||
init { result }
|
||||
|
||||
main() {
|
||||
local a = 10
|
||||
local b = 32
|
||||
local sum = a + b
|
||||
return sum // Should return 42
|
||||
}
|
||||
}
|
||||
1
local_tests/test_print_42.nyash
Normal file
1
local_tests/test_print_42.nyash
Normal file
@ -0,0 +1 @@
|
||||
print(42)
|
||||
253
local_tests/test_simple.wat
Normal file
253
local_tests/test_simple.wat
Normal file
@ -0,0 +1,253 @@
|
||||
(module
|
||||
(import "env" "print" (func $print (param i32) ))
|
||||
(import "env" "print_str" (func $print_str (param i32 i32) ))
|
||||
(import "env" "console_log" (func $console_log (param i32 i32) ))
|
||||
(import "env" "canvas_fillRect" (func $canvas_fillRect (param i32 i32 i32 i32 i32 i32 i32 i32) ))
|
||||
(import "env" "canvas_fillText" (func $canvas_fillText (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) ))
|
||||
(import "env" "box_to_string" (func $box_to_string (param i32) (result i32)))
|
||||
(import "env" "box_print" (func $box_print (param i32) ))
|
||||
(import "env" "box_equals" (func $box_equals (param i32 i32) (result i32)))
|
||||
(import "env" "box_clone" (func $box_clone (param i32) (result i32)))
|
||||
(memory (export "memory") 1)
|
||||
(data (i32.const 4102) "\53\74\72\69\6e\67\42\6f\78")
|
||||
(data (i32.const 4096) "\5f\5f\6d\65\5f\5f")
|
||||
(global $heap_ptr (mut i32) (i32.const 2048))
|
||||
(func $malloc (param $size i32) (result i32)
|
||||
(local $ptr i32)
|
||||
(local $aligned_size i32)
|
||||
|
||||
;; Align size to 4-byte boundary
|
||||
local.get $size
|
||||
i32.const 3
|
||||
i32.add
|
||||
i32.const -4
|
||||
i32.and
|
||||
local.set $aligned_size
|
||||
|
||||
;; Get current heap pointer
|
||||
global.get $heap_ptr
|
||||
local.set $ptr
|
||||
|
||||
;; Advance heap pointer by aligned size
|
||||
global.get $heap_ptr
|
||||
local.get $aligned_size
|
||||
i32.add
|
||||
global.set $heap_ptr
|
||||
|
||||
;; Return allocated pointer
|
||||
local.get $ptr
|
||||
)
|
||||
(func $box_alloc (param $type_id i32) (param $field_count i32) (result i32)
|
||||
(local $ptr i32)
|
||||
(local $total_size i32)
|
||||
|
||||
;; Calculate total size: header (12) + fields (field_count * 4)
|
||||
local.get $field_count
|
||||
i32.const 4
|
||||
i32.mul
|
||||
i32.const 12
|
||||
i32.add
|
||||
local.set $total_size
|
||||
|
||||
;; Allocate memory
|
||||
local.get $total_size
|
||||
call $malloc
|
||||
local.set $ptr
|
||||
|
||||
;; Initialize type_id
|
||||
local.get $ptr
|
||||
local.get $type_id
|
||||
i32.store
|
||||
|
||||
;; Initialize ref_count to 1
|
||||
local.get $ptr
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Initialize field_count
|
||||
local.get $ptr
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.get $field_count
|
||||
i32.store
|
||||
|
||||
;; Return box pointer
|
||||
local.get $ptr
|
||||
)
|
||||
(func $alloc_stringbox (result i32)
|
||||
(local $ptr i32)
|
||||
|
||||
;; Allocate memory for box
|
||||
i32.const 20
|
||||
call $malloc
|
||||
local.set $ptr
|
||||
|
||||
;; Initialize type_id
|
||||
local.get $ptr
|
||||
i32.const 4097
|
||||
i32.store
|
||||
|
||||
;; Initialize ref_count to 1
|
||||
local.get $ptr
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Initialize field_count
|
||||
local.get $ptr
|
||||
i32.const 8
|
||||
i32.add
|
||||
i32.const 2
|
||||
i32.store
|
||||
|
||||
;; Return box pointer
|
||||
local.get $ptr
|
||||
)
|
||||
(func $alloc_integerbox (result i32)
|
||||
(local $ptr i32)
|
||||
|
||||
;; Allocate memory for box
|
||||
i32.const 16
|
||||
call $malloc
|
||||
local.set $ptr
|
||||
|
||||
;; Initialize type_id
|
||||
local.get $ptr
|
||||
i32.const 4098
|
||||
i32.store
|
||||
|
||||
;; Initialize ref_count to 1
|
||||
local.get $ptr
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Initialize field_count
|
||||
local.get $ptr
|
||||
i32.const 8
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Return box pointer
|
||||
local.get $ptr
|
||||
)
|
||||
(func $alloc_boolbox (result i32)
|
||||
(local $ptr i32)
|
||||
|
||||
;; Allocate memory for box
|
||||
i32.const 16
|
||||
call $malloc
|
||||
local.set $ptr
|
||||
|
||||
;; Initialize type_id
|
||||
local.get $ptr
|
||||
i32.const 4099
|
||||
i32.store
|
||||
|
||||
;; Initialize ref_count to 1
|
||||
local.get $ptr
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Initialize field_count
|
||||
local.get $ptr
|
||||
i32.const 8
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Return box pointer
|
||||
local.get $ptr
|
||||
)
|
||||
(func $alloc_databox (result i32)
|
||||
(local $ptr i32)
|
||||
|
||||
;; Allocate memory for box
|
||||
i32.const 16
|
||||
call $malloc
|
||||
local.set $ptr
|
||||
|
||||
;; Initialize type_id
|
||||
local.get $ptr
|
||||
i32.const 4101
|
||||
i32.store
|
||||
|
||||
;; Initialize ref_count to 1
|
||||
local.get $ptr
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Initialize field_count
|
||||
local.get $ptr
|
||||
i32.const 8
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.store
|
||||
|
||||
;; Return box pointer
|
||||
local.get $ptr
|
||||
)
|
||||
(func $main (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32)
|
||||
nop
|
||||
call $alloc_stringbox
|
||||
local.set $0
|
||||
local.get $0
|
||||
i32.const 12
|
||||
i32.add
|
||||
i32.const 4096
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.add
|
||||
i32.const 6
|
||||
i32.store
|
||||
call $alloc_stringbox
|
||||
local.set $2
|
||||
local.get $2
|
||||
i32.const 12
|
||||
i32.add
|
||||
i32.const 4102
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 16
|
||||
i32.add
|
||||
i32.const 9
|
||||
i32.store
|
||||
local.get $2
|
||||
local.set $1
|
||||
local.get $0
|
||||
i32.const 12
|
||||
i32.add
|
||||
local.get $1
|
||||
i32.store
|
||||
call $alloc_stringbox
|
||||
local.set $3
|
||||
local.get $3
|
||||
i32.const 12
|
||||
i32.add
|
||||
i32.const 4096
|
||||
i32.store
|
||||
local.get $3
|
||||
i32.const 16
|
||||
i32.add
|
||||
i32.const 6
|
||||
i32.store
|
||||
local.get $3
|
||||
i32.const 12
|
||||
i32.add
|
||||
i32.load
|
||||
local.set $4
|
||||
local.get $4
|
||||
return
|
||||
)
|
||||
(export "main" (func $main))
|
||||
)
|
||||
8
local_tests/test_simple_literal.nyash
Normal file
8
local_tests/test_simple_literal.nyash
Normal file
@ -0,0 +1,8 @@
|
||||
// Simplest possible test
|
||||
static box Main {
|
||||
init { }
|
||||
|
||||
main() {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user