revert: 古いプラグインシステム実装前の状態に巻き戻し

- ソースコードをcommit 3f7d71fの状態に復元(古いプラグインシステム実装前)
- docsフォルダは最新の状態を維持(BID-FFI設計ドキュメント含む)
- nyashバイナリの基本動作確認済み
- BID-FFIシステムをクリーンに再実装する準備完了

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-18 08:34:19 +09:00
parent 75868a5a96
commit bec0e9bc92
35 changed files with 731 additions and 2757 deletions

View File

@ -31,8 +31,6 @@ pub enum MirInstruction {
/// Unary operation
/// `%dst = op %operand`
/// DEPRECATED: Phase 5 - Use BinOp instead (e.g., `not %a` → `%a xor true`, `neg %a` → `0 sub %a`)
#[deprecated(since = "Phase 5", note = "Use BinOp instead")]
UnaryOp {
dst: ValueId,
op: UnaryOp,
@ -52,8 +50,6 @@ pub enum MirInstruction {
// === Memory Operations ===
/// Load from memory/variable
/// `%dst = load %ptr`
/// DEPRECATED: Phase 5 - Use BoxFieldLoad instead
#[deprecated(since = "Phase 5", note = "Use BoxFieldLoad instead")]
Load {
dst: ValueId,
ptr: ValueId,
@ -61,8 +57,6 @@ pub enum MirInstruction {
/// Store to memory/variable
/// `store %value -> %ptr`
/// DEPRECATED: Phase 5 - Use BoxFieldStore instead
#[deprecated(since = "Phase 5", note = "Use BoxFieldStore instead")]
Store {
value: ValueId,
ptr: ValueId,
@ -128,8 +122,6 @@ pub enum MirInstruction {
/// Check Box type
/// `%dst = type_check %box "BoxType"`
/// DEPRECATED: Phase 5 - Use Call with @type_check intrinsic
#[deprecated(since = "Phase 5", note = "Use Call with @type_check intrinsic")]
TypeCheck {
dst: ValueId,
value: ValueId,
@ -139,8 +131,6 @@ pub enum MirInstruction {
// === Type Conversion ===
/// Convert between types
/// `%dst = cast %value as Type`
/// DEPRECATED: Phase 5 - Use Call with @cast intrinsic
#[deprecated(since = "Phase 5", note = "Use Call with @cast intrinsic")]
Cast {
dst: ValueId,
value: ValueId,
@ -150,8 +140,6 @@ pub enum MirInstruction {
// === Array Operations ===
/// Get array element
/// `%dst = %array[%index]`
/// DEPRECATED: Phase 5 - Use BoxFieldLoad or Call with @array_get intrinsic
#[deprecated(since = "Phase 5", note = "Use BoxFieldLoad or Call with @array_get intrinsic")]
ArrayGet {
dst: ValueId,
array: ValueId,
@ -160,8 +148,6 @@ pub enum MirInstruction {
/// Set array element
/// `%array[%index] = %value`
/// DEPRECATED: Phase 5 - Use BoxFieldStore or Call with @array_set intrinsic
#[deprecated(since = "Phase 5", note = "Use BoxFieldStore or Call with @array_set intrinsic")]
ArraySet {
array: ValueId,
index: ValueId,
@ -171,8 +157,6 @@ pub enum MirInstruction {
// === Special Operations ===
/// Copy a value (for optimization passes)
/// `%dst = copy %src`
/// DEPRECATED: Phase 5 - Optimization pass only, not needed in IR
#[deprecated(since = "Phase 5", note = "Optimization pass only, not needed in IR")]
Copy {
dst: ValueId,
src: ValueId,
@ -180,8 +164,6 @@ pub enum MirInstruction {
/// Debug/introspection instruction
/// `debug %value "message"`
/// DEPRECATED: Phase 5 - Use Call with @debug intrinsic
#[deprecated(since = "Phase 5", note = "Use Call with @debug intrinsic")]
Debug {
value: ValueId,
message: String,
@ -189,24 +171,18 @@ pub enum MirInstruction {
/// Print instruction for console output
/// `print %value`
/// DEPRECATED: Phase 5 - Use Call with @print intrinsic
#[deprecated(since = "Phase 5", note = "Use Call with @print intrinsic")]
Print {
value: ValueId,
effects: EffectMask,
},
/// No-op instruction (for optimization placeholders)
/// DEPRECATED: Phase 5 - Not needed in final IR
#[deprecated(since = "Phase 5", note = "Not needed in final IR")]
Nop,
// === Control Flow & Exception Handling (Phase 5) ===
/// Throw an exception
/// `throw %exception_value`
/// DEPRECATED: Phase 5 - Use Call with @throw intrinsic
#[deprecated(since = "Phase 5", note = "Use Call with @throw intrinsic")]
Throw {
exception: ValueId,
effects: EffectMask,
@ -214,8 +190,6 @@ pub enum MirInstruction {
/// Catch handler setup (landing pad for exceptions)
/// `catch %exception_type -> %handler_bb`
/// DEPRECATED: Phase 5 - Use Call with @catch intrinsic
#[deprecated(since = "Phase 5", note = "Use Call with @catch intrinsic")]
Catch {
exception_type: Option<String>, // None = catch-all
exception_value: ValueId, // Where to store caught exception
@ -230,8 +204,6 @@ pub enum MirInstruction {
/// Create a new reference to a Box
/// `%dst = ref_new %box`
/// DEPRECATED: Phase 5 - RefGet is sufficient
#[deprecated(since = "Phase 5", note = "RefGet is sufficient")]
RefNew {
dst: ValueId,
box_val: ValueId,
@ -269,16 +241,12 @@ pub enum MirInstruction {
/// Memory barrier read (no-op for now, proper effect annotation)
/// `barrier_read %ptr`
/// DEPRECATED: Phase 5 - Use AtomicFence instead
#[deprecated(since = "Phase 5", note = "Use AtomicFence instead")]
BarrierRead {
ptr: ValueId,
},
/// Memory barrier write (no-op for now, proper effect annotation)
/// `barrier_write %ptr`
/// DEPRECATED: Phase 5 - Use AtomicFence instead
#[deprecated(since = "Phase 5", note = "Use AtomicFence instead")]
BarrierWrite {
ptr: ValueId,
},
@ -287,8 +255,6 @@ pub enum MirInstruction {
/// Create a new Future with initial value
/// `%dst = future_new %value`
/// DEPRECATED: Phase 5 - Use NewBox + BoxCall
#[deprecated(since = "Phase 5", note = "Use NewBox + BoxCall")]
FutureNew {
dst: ValueId,
value: ValueId,
@ -296,8 +262,6 @@ pub enum MirInstruction {
/// Set Future value and mark as ready
/// `future_set %future = %value`
/// DEPRECATED: Phase 5 - Use BoxCall
#[deprecated(since = "Phase 5", note = "Use BoxCall")]
FutureSet {
future: ValueId,
value: ValueId,
@ -305,8 +269,6 @@ pub enum MirInstruction {
/// Wait for Future completion and get value
/// `%dst = await %future`
/// DEPRECATED: Phase 5 - Use BoxCall
#[deprecated(since = "Phase 5", note = "Use BoxCall")]
Await {
dst: ValueId,
future: ValueId,
@ -323,80 +285,6 @@ pub enum MirInstruction {
args: Vec<ValueId>,
effects: EffectMask,
},
// === Phase 8.5: MIR 26-instruction reduction (NEW) ===
/// Box field load operation (replaces Load)
/// `%dst = %box.field`
BoxFieldLoad {
dst: ValueId,
box_val: ValueId,
field: String,
},
/// Box field store operation (replaces Store)
/// `%box.field = %value`
BoxFieldStore {
box_val: ValueId,
field: String,
value: ValueId,
},
/// Check weak reference validity
/// `%dst = weak_check %weak_ref`
WeakCheck {
dst: ValueId,
weak_ref: ValueId,
},
/// Send data via Bus
/// `send %data -> %target`
Send {
data: ValueId,
target: ValueId,
},
/// Receive data from Bus
/// `%dst = recv %source`
Recv {
dst: ValueId,
source: ValueId,
},
/// Tail call optimization
/// `tail_call %func(%args...)`
TailCall {
func: ValueId,
args: Vec<ValueId>,
effects: EffectMask,
},
/// Adopt ownership (parent takes child)
/// `adopt %parent <- %child`
Adopt {
parent: ValueId,
child: ValueId,
},
/// Release strong ownership
/// `release %ref`
Release {
reference: ValueId,
},
/// Memory copy optimization
/// `memcopy %dst <- %src, %size`
MemCopy {
dst: ValueId,
src: ValueId,
size: ValueId,
},
/// Atomic memory fence
/// `atomic_fence %ordering`
AtomicFence {
ordering: AtomicOrdering,
},
}
/// Constant values in MIR
@ -456,16 +344,6 @@ pub enum MirType {
Unknown,
}
/// Atomic memory ordering for fence operations
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AtomicOrdering {
Relaxed,
Acquire,
Release,
AcqRel,
SeqCst,
}
impl MirInstruction {
/// Get the effect mask for this instruction
pub fn effects(&self) -> EffectMask {
@ -526,18 +404,6 @@ impl MirInstruction {
// Phase 9.7: External Function Calls
MirInstruction::ExternCall { effects, .. } => *effects, // Use provided effect mask
// Phase 8.5: MIR 26-instruction reduction (NEW)
MirInstruction::BoxFieldLoad { .. } => EffectMask::READ, // Box field read
MirInstruction::BoxFieldStore { .. } => EffectMask::WRITE, // Box field write
MirInstruction::WeakCheck { .. } => EffectMask::PURE, // Check is pure
MirInstruction::Send { .. } => EffectMask::IO, // Bus send has IO effects
MirInstruction::Recv { .. } => EffectMask::IO, // Bus recv has IO effects
MirInstruction::TailCall { effects, .. } => *effects, // Use provided effect mask
MirInstruction::Adopt { .. } => EffectMask::WRITE, // Ownership change has write effects
MirInstruction::Release { .. } => EffectMask::WRITE, // Ownership release has write effects
MirInstruction::MemCopy { .. } => EffectMask::WRITE, // Memory copy has write effects
MirInstruction::AtomicFence { .. } => EffectMask::IO.add(Effect::Barrier), // Fence has barrier + IO
}
}
@ -566,12 +432,6 @@ impl MirInstruction {
MirInstruction::BoxCall { dst, .. } |
MirInstruction::ExternCall { dst, .. } => *dst,
// Phase 8.5: MIR 26-instruction reduction (NEW)
MirInstruction::BoxFieldLoad { dst, .. } |
MirInstruction::WeakCheck { dst, .. } |
MirInstruction::Recv { dst, .. } |
MirInstruction::MemCopy { dst, .. } => Some(*dst),
MirInstruction::Store { .. } |
MirInstruction::Branch { .. } |
MirInstruction::Jump { .. } |
@ -587,14 +447,6 @@ impl MirInstruction {
MirInstruction::Safepoint |
MirInstruction::Nop => None,
// Phase 8.5: Non-value producing instructions
MirInstruction::BoxFieldStore { .. } |
MirInstruction::Send { .. } |
MirInstruction::TailCall { .. } |
MirInstruction::Adopt { .. } |
MirInstruction::Release { .. } |
MirInstruction::AtomicFence { .. } => None,
MirInstruction::Catch { exception_value, .. } => Some(*exception_value),
}
}
@ -667,22 +519,6 @@ impl MirInstruction {
// Phase 9.7: External Function Calls
MirInstruction::ExternCall { args, .. } => args.clone(),
// Phase 8.5: MIR 26-instruction reduction (NEW)
MirInstruction::BoxFieldLoad { box_val, .. } => vec![*box_val],
MirInstruction::BoxFieldStore { box_val, value, .. } => vec![*box_val, *value],
MirInstruction::WeakCheck { weak_ref, .. } => vec![*weak_ref],
MirInstruction::Send { data, target } => vec![*data, *target],
MirInstruction::Recv { source, .. } => vec![*source],
MirInstruction::TailCall { func, args, .. } => {
let mut used = vec![*func];
used.extend(args);
used
},
MirInstruction::Adopt { parent, child } => vec![*parent, *child],
MirInstruction::Release { reference } => vec![*reference],
MirInstruction::MemCopy { dst, src, size } => vec![*dst, *src, *size],
MirInstruction::AtomicFence { .. } => Vec::new(), // Fence doesn't use values
}
}
}
@ -766,39 +602,6 @@ impl fmt::Display for MirInstruction {
effects)
}
},
// Phase 8.5: MIR 26-instruction reduction (NEW)
MirInstruction::BoxFieldLoad { dst, box_val, field } => {
write!(f, "{} = {}.{}", dst, box_val, field)
},
MirInstruction::BoxFieldStore { box_val, field, value } => {
write!(f, "{}.{} = {}", box_val, field, value)
},
MirInstruction::WeakCheck { dst, weak_ref } => {
write!(f, "{} = weak_check {}", dst, weak_ref)
},
MirInstruction::Send { data, target } => {
write!(f, "send {} -> {}", data, target)
},
MirInstruction::Recv { dst, source } => {
write!(f, "{} = recv {}", dst, source)
},
MirInstruction::TailCall { func, args, effects } => {
write!(f, "tail_call {}({}); effects: {}", func,
args.iter().map(|v| format!("{}", v)).collect::<Vec<_>>().join(", "),
effects)
},
MirInstruction::Adopt { parent, child } => {
write!(f, "adopt {} <- {}", parent, child)
},
MirInstruction::Release { reference } => {
write!(f, "release {}", reference)
},
MirInstruction::MemCopy { dst, src, size } => {
write!(f, "memcopy {} <- {}, {}", dst, src, size)
},
MirInstruction::AtomicFence { ordering } => {
write!(f, "atomic_fence {:?}", ordering)
},
_ => write!(f, "{:?}", self), // Fallback for other instructions
}
}
@ -817,18 +620,6 @@ impl fmt::Display for ConstValue {
}
}
impl fmt::Display for AtomicOrdering {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
AtomicOrdering::Relaxed => write!(f, "relaxed"),
AtomicOrdering::Acquire => write!(f, "acquire"),
AtomicOrdering::Release => write!(f, "release"),
AtomicOrdering::AcqRel => write!(f, "acq_rel"),
AtomicOrdering::SeqCst => write!(f, "seq_cst"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;