🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
use inkwell::{values::BasicValueEnum as BVE, AddressSpace};
|
|
|
|
|
|
|
|
|
|
use crate::backend::llvm::context::CodegenContext;
|
2025-09-12 19:23:16 +09:00
|
|
|
use crate::mir::{function::MirFunction, BasicBlockId, ValueId};
|
|
|
|
|
use super::builder_cursor::BuilderCursor;
|
2025-09-12 20:06:48 +09:00
|
|
|
use super::Resolver;
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
|
|
|
|
|
/// Handle String-specific methods. Returns true if handled, false to let caller continue.
|
2025-09-12 19:23:16 +09:00
|
|
|
pub(super) fn try_handle_string_method<'ctx, 'b>(
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
codegen: &CodegenContext<'ctx>,
|
2025-09-12 19:23:16 +09:00
|
|
|
cursor: &mut BuilderCursor<'ctx, 'b>,
|
2025-09-12 20:06:48 +09:00
|
|
|
resolver: &mut Resolver<'ctx>,
|
2025-09-12 19:23:16 +09:00
|
|
|
cur_bid: BasicBlockId,
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
func: &MirFunction,
|
|
|
|
|
vmap: &mut HashMap<ValueId, inkwell::values::BasicValueEnum<'ctx>>,
|
|
|
|
|
dst: &Option<ValueId>,
|
|
|
|
|
box_val: &ValueId,
|
|
|
|
|
method: &str,
|
|
|
|
|
args: &[ValueId],
|
|
|
|
|
recv_v: BVE<'ctx>,
|
2025-09-12 19:23:16 +09:00
|
|
|
bb_map: &std::collections::HashMap<crate::mir::BasicBlockId, inkwell::basic_block::BasicBlock<'ctx>>,
|
|
|
|
|
preds: &std::collections::HashMap<crate::mir::BasicBlockId, Vec<crate::mir::BasicBlockId>>,
|
|
|
|
|
block_end_values: &std::collections::HashMap<crate::mir::BasicBlockId, std::collections::HashMap<ValueId, inkwell::values::BasicValueEnum<'ctx>>>,
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
) -> Result<bool, String> {
|
2025-09-12 05:48:59 +09:00
|
|
|
// Act if receiver is annotated as String/StringBox, or if the actual value is an i8* (string literal path)
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
let is_string_recv = match func.metadata.value_types.get(box_val) {
|
|
|
|
|
Some(crate::mir::MirType::String) => true,
|
|
|
|
|
Some(crate::mir::MirType::Box(b)) if b == "StringBox" => true,
|
2025-09-12 05:48:59 +09:00
|
|
|
_ => matches!(recv_v, BVE::PointerValue(_)),
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
};
|
2025-09-12 05:48:59 +09:00
|
|
|
// Do not early-return; allow method-specific checks below to validate types
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
|
|
|
|
|
// concat fast-paths
|
|
|
|
|
if method == "concat" {
|
|
|
|
|
if args.len() != 1 {
|
|
|
|
|
return Err("String.concat expects 1 arg".to_string());
|
|
|
|
|
}
|
|
|
|
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
|
|
|
|
let rhs_v = *vmap.get(&args[0]).ok_or("concat arg missing")?;
|
|
|
|
|
match (recv_v, rhs_v) {
|
|
|
|
|
(BVE::PointerValue(lp), BVE::PointerValue(rp)) => {
|
|
|
|
|
let fnty = i8p.fn_type(&[i8p.into(), i8p.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.string.concat_ss")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.string.concat_ss", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[lp.into(), rp.into()], "concat_ss_call"))
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
if let Some(d) = dst {
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("concat_ss returned void".to_string())?;
|
|
|
|
|
vmap.insert(*d, rv);
|
|
|
|
|
}
|
|
|
|
|
return Ok(true);
|
|
|
|
|
}
|
2025-09-12 19:23:16 +09:00
|
|
|
(BVE::PointerValue(lp), BVE::IntValue(_ri)) => {
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
let i64t = codegen.context.i64_type();
|
2025-09-12 20:06:48 +09:00
|
|
|
// Localize rhs integer in current block via Resolver
|
|
|
|
|
let ri = resolver.resolve_i64(codegen, cursor, cur_bid, args[0], bb_map, preds, block_end_values, vmap)?;
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
let fnty = i8p.fn_type(&[i8p.into(), i64t.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.string.concat_si")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.string.concat_si", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[lp.into(), ri.into()], "concat_si_call"))
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
if let Some(d) = dst {
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("concat_si returned void".to_string())?;
|
|
|
|
|
vmap.insert(*d, rv);
|
|
|
|
|
}
|
|
|
|
|
return Ok(true);
|
|
|
|
|
}
|
2025-09-12 19:23:16 +09:00
|
|
|
(BVE::IntValue(_li), BVE::PointerValue(rp)) => {
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
let i64t = codegen.context.i64_type();
|
2025-09-12 19:23:16 +09:00
|
|
|
// Localize receiver integer in current block (box_val)
|
2025-09-12 20:06:48 +09:00
|
|
|
let li = resolver.resolve_i64(codegen, cursor, cur_bid, *box_val, bb_map, preds, block_end_values, vmap)?;
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
let fnty = i8p.fn_type(&[i64t.into(), i8p.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.string.concat_is")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.string.concat_is", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[li.into(), rp.into()], "concat_is_call"))
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
if let Some(d) = dst {
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("concat_is returned void".to_string())?;
|
|
|
|
|
vmap.insert(*d, rv);
|
|
|
|
|
}
|
|
|
|
|
return Ok(true);
|
|
|
|
|
}
|
|
|
|
|
_ => { /* fall through */ }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// length/len fast-path
|
|
|
|
|
if method == "length" || method == "len" {
|
|
|
|
|
let i64t = codegen.context.i64_type();
|
|
|
|
|
// Ensure handle for receiver (i8* -> i64 via from_i8_string)
|
|
|
|
|
let recv_h = match recv_v {
|
|
|
|
|
BVE::IntValue(h) => h,
|
|
|
|
|
BVE::PointerValue(p) => {
|
|
|
|
|
let fnty = i64t.fn_type(&[codegen.context.ptr_type(AddressSpace::from(0)).into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.box.from_i8_string")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.box.from_i8_string", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[p.into()], "str_ptr_to_handle"))
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("from_i8_string returned void".to_string())?;
|
|
|
|
|
if let BVE::IntValue(iv) = rv {
|
|
|
|
|
iv
|
|
|
|
|
} else {
|
|
|
|
|
return Err("from_i8_string ret expected i64".to_string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ => return Err("String.length receiver type unsupported".to_string()),
|
|
|
|
|
};
|
|
|
|
|
// call i64 @nyash.string.len_h(i64)
|
|
|
|
|
let fnty = i64t.fn_type(&[i64t.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.string.len_h")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.string.len_h", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[recv_h.into()], "strlen_h"))
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
if let Some(d) = dst {
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("len_h returned void".to_string())?;
|
|
|
|
|
vmap.insert(*d, rv);
|
|
|
|
|
}
|
|
|
|
|
return Ok(true);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-12 01:45:00 +09:00
|
|
|
// substring(start, end) -> i8*
|
|
|
|
|
if method == "substring" {
|
|
|
|
|
if args.len() != 2 {
|
|
|
|
|
return Err("String.substring expects 2 args (start, end)".to_string());
|
|
|
|
|
}
|
|
|
|
|
let i64t = codegen.context.i64_type();
|
|
|
|
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
2025-09-12 05:48:59 +09:00
|
|
|
// receiver preferably i8*; if it's a handle (i64), conservatively cast to i8*
|
2025-09-12 01:45:00 +09:00
|
|
|
let recv_p = match recv_v {
|
|
|
|
|
BVE::PointerValue(p) => p,
|
2025-09-12 19:23:16 +09:00
|
|
|
BVE::IntValue(iv) => cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_int_to_ptr(iv, codegen.context.ptr_type(AddressSpace::from(0)), "str_h2p_sub"))
|
2025-09-12 05:48:59 +09:00
|
|
|
.map_err(|e| e.to_string())?,
|
2025-09-12 01:45:00 +09:00
|
|
|
_ => return Ok(false),
|
|
|
|
|
};
|
2025-09-12 19:23:16 +09:00
|
|
|
// Localize start/end indices to current block via sealed snapshots (i64)
|
2025-09-12 20:06:48 +09:00
|
|
|
let s = resolver.resolve_i64(codegen, cursor, cur_bid, args[0], bb_map, preds, block_end_values, vmap)?;
|
|
|
|
|
let e = resolver.resolve_i64(codegen, cursor, cur_bid, args[1], bb_map, preds, block_end_values, vmap)?;
|
2025-09-12 01:45:00 +09:00
|
|
|
let fnty = i8p.fn_type(&[i8p.into(), i64t.into(), i64t.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.string.substring_sii")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.string.substring_sii", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[recv_p.into(), s.into(), e.into()], "substring_call"))
|
2025-09-12 01:45:00 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
if let Some(d) = dst {
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("substring returned void".to_string())?;
|
|
|
|
|
vmap.insert(*d, rv);
|
|
|
|
|
}
|
|
|
|
|
return Ok(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lastIndexOf(needle) -> i64
|
|
|
|
|
if method == "lastIndexOf" {
|
|
|
|
|
if args.len() != 1 {
|
|
|
|
|
return Err("String.lastIndexOf expects 1 arg".to_string());
|
|
|
|
|
}
|
|
|
|
|
let i64t = codegen.context.i64_type();
|
|
|
|
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
|
|
|
|
// receiver must be i8* for this fast path
|
|
|
|
|
let recv_p = match recv_v {
|
|
|
|
|
BVE::PointerValue(p) => p,
|
|
|
|
|
_ => return Ok(false),
|
|
|
|
|
};
|
|
|
|
|
let a0 = *vmap.get(&args[0]).ok_or("lastIndexOf arg missing")?;
|
|
|
|
|
let needle_p = match a0 {
|
|
|
|
|
BVE::PointerValue(p) => p,
|
|
|
|
|
_ => return Err("lastIndexOf arg must be i8*".to_string()),
|
|
|
|
|
};
|
|
|
|
|
let fnty = i64t.fn_type(&[i8p.into(), i8p.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.string.lastIndexOf_ss")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.string.lastIndexOf_ss", fnty, None));
|
2025-09-12 19:23:16 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b
|
|
|
|
|
.build_call(callee, &[recv_p.into(), needle_p.into()], "lastindexof_call"))
|
2025-09-12 01:45:00 +09:00
|
|
|
.map_err(|e| e.to_string())?;
|
|
|
|
|
if let Some(d) = dst {
|
|
|
|
|
let rv = call
|
|
|
|
|
.try_as_basic_value()
|
|
|
|
|
.left()
|
|
|
|
|
.ok_or("lastIndexOf returned void".to_string())?;
|
|
|
|
|
vmap.insert(*d, rv);
|
|
|
|
|
}
|
|
|
|
|
return Ok(true);
|
|
|
|
|
}
|
|
|
|
|
|
🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
- strings.rs: String method optimizations (concat, length)
- arrays.rs: Array operations (get, set, push, length)
- maps.rs: Map operations (get, set, has, size)
- fields.rs: getField/setField handling
- invoke.rs: Tagged invoke implementation
- marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring
## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
- implementation/: Technical implementation docs
- planning/: Planning and sequence docs
- archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md
## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
|
|
|
Ok(false)
|
|
|
|
|
}
|