🏗️ 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;
|
|
|
|
|
use crate::mir::ValueId;
|
2025-09-13 00:07:38 +09:00
|
|
|
use super::super::ctx::{LowerFnCtx, BlockCtx};
|
🏗️ 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 getField/setField; returns true if handled.
|
2025-09-12 20:40:48 +09:00
|
|
|
use super::super::builder_cursor::BuilderCursor;
|
|
|
|
|
|
|
|
|
|
pub(super) fn try_handle_field_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-13 00:07:38 +09:00
|
|
|
cursor: &mut super::super::builder_cursor::BuilderCursor<'ctx, 'b>,
|
2025-09-12 22:36:20 +09:00
|
|
|
cur_bid: crate::mir::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
|
|
|
vmap: &mut HashMap<ValueId, inkwell::values::BasicValueEnum<'ctx>>,
|
|
|
|
|
dst: &Option<ValueId>,
|
|
|
|
|
method: &str,
|
|
|
|
|
args: &[ValueId],
|
|
|
|
|
recv_h: inkwell::values::IntValue<'ctx>,
|
2025-09-12 22:36:20 +09:00
|
|
|
resolver: &mut super::super::Resolver<'ctx>,
|
|
|
|
|
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> {
|
|
|
|
|
let i64t = codegen.context.i64_type();
|
|
|
|
|
match method {
|
|
|
|
|
"getField" => {
|
|
|
|
|
if args.len() != 1 {
|
|
|
|
|
return Err("getField expects 1 arg (name)".to_string());
|
|
|
|
|
}
|
2025-09-12 22:36:20 +09:00
|
|
|
let name_p = resolver
|
|
|
|
|
.resolve_ptr(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 i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
|
|
|
|
let fnty = i64t.fn_type(&[i64t.into(), i8p.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.instance.get_field_h")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.instance.get_field_h", fnty, None));
|
2025-09-12 22:36:20 +09:00
|
|
|
let call = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b.build_call(callee, &[recv_h.into(), name_p.into()], "getField"))
|
🏗️ 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("get_field returned void".to_string())?;
|
|
|
|
|
let h = if let BVE::IntValue(iv) = rv {
|
|
|
|
|
iv
|
|
|
|
|
} else {
|
|
|
|
|
return Err("get_field ret expected i64".to_string());
|
|
|
|
|
};
|
2025-09-13 00:07:38 +09:00
|
|
|
let pty = codegen.context.ptr_type(AddressSpace::from(0));
|
|
|
|
|
let ptr = codegen
|
🏗️ 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
|
|
|
.builder
|
|
|
|
|
.build_int_to_ptr(h, pty, "gf_handle_to_ptr")
|
|
|
|
|
.map_err(|e| e.to_string())?;
|
2025-09-13 00:07:38 +09:00
|
|
|
vmap.insert(*d, ptr.into());
|
🏗️ 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(true)
|
|
|
|
|
}
|
|
|
|
|
"setField" => {
|
|
|
|
|
if args.len() != 2 {
|
|
|
|
|
return Err("setField expects 2 args (name, value)".to_string());
|
|
|
|
|
}
|
2025-09-12 22:36:20 +09:00
|
|
|
let name_p = resolver
|
|
|
|
|
.resolve_ptr(codegen, cursor, cur_bid, args[0], bb_map, preds, block_end_values, vmap)?;
|
|
|
|
|
let val_h = resolver
|
|
|
|
|
.resolve_i64(codegen, cursor, cur_bid, args[1], 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 i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
|
|
|
|
let fnty = i64t.fn_type(&[i64t.into(), i8p.into(), i64t.into()], false);
|
|
|
|
|
let callee = codegen
|
|
|
|
|
.module
|
|
|
|
|
.get_function("nyash.instance.set_field_h")
|
|
|
|
|
.unwrap_or_else(|| codegen.module.add_function("nyash.instance.set_field_h", fnty, None));
|
2025-09-12 22:36:20 +09:00
|
|
|
let _ = cursor
|
|
|
|
|
.emit_instr(cur_bid, |b| b.build_call(callee, &[recv_h.into(), name_p.into(), val_h.into()], "setField"))
|
🏗️ 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())?;
|
|
|
|
|
Ok(true)
|
|
|
|
|
}
|
|
|
|
|
_ => Ok(false),
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-13 00:07:38 +09:00
|
|
|
|
|
|
|
|
// Boxed wrapper that delegates to the non-boxed implementation
|
|
|
|
|
pub(super) fn try_handle_field_method_boxed<'ctx, 'b>(
|
|
|
|
|
ctx: &mut LowerFnCtx<'ctx, 'b>,
|
|
|
|
|
blk: &BlockCtx<'ctx>,
|
|
|
|
|
dst: &Option<ValueId>,
|
|
|
|
|
method: &str,
|
|
|
|
|
args: &[ValueId],
|
|
|
|
|
recv_h: inkwell::values::IntValue<'ctx>,
|
|
|
|
|
) -> Result<bool, String> {
|
|
|
|
|
try_handle_field_method(
|
|
|
|
|
ctx.codegen,
|
|
|
|
|
ctx.cursor,
|
|
|
|
|
blk.cur_bid,
|
|
|
|
|
ctx.vmap,
|
|
|
|
|
dst,
|
|
|
|
|
method,
|
|
|
|
|
args,
|
|
|
|
|
recv_h,
|
|
|
|
|
ctx.resolver,
|
|
|
|
|
ctx.bb_map,
|
|
|
|
|
ctx.preds,
|
|
|
|
|
ctx.block_end_values,
|
|
|
|
|
)
|
|
|
|
|
}
|