pr2.3
This commit is contained in:
parent
790629fee7
commit
8d80685654
@ -102,7 +102,7 @@ impl From<ProgramImage> for BytecodeModule {
|
|||||||
Value::String(v) => ConstantPoolEntry::String(v.clone()),
|
Value::String(v) => ConstantPoolEntry::String(v.clone()),
|
||||||
Value::Int32(v) => ConstantPoolEntry::Int32(*v),
|
Value::Int32(v) => ConstantPoolEntry::Int32(*v),
|
||||||
Value::Bounded(v) => ConstantPoolEntry::Int32(*v as i32),
|
Value::Bounded(v) => ConstantPoolEntry::Int32(*v as i32),
|
||||||
Value::Gate(_) => ConstantPoolEntry::Null,
|
Value::Handle(_) => ConstantPoolEntry::Null,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ pub enum Value {
|
|||||||
/// Bounded 16-bit-ish integer.
|
/// Bounded 16-bit-ish integer.
|
||||||
Bounded(u32),
|
Bounded(u32),
|
||||||
/// A pointer to an object on the heap.
|
/// A pointer to an object on the heap.
|
||||||
Gate(usize),
|
Handle(usize),
|
||||||
/// Represents the absence of a value (equivalent to `null` or `undefined`).
|
/// Represents the absence of a value (equivalent to `null` or `undefined`).
|
||||||
Null,
|
Null,
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ impl PartialEq for Value {
|
|||||||
(Value::Boolean(a), Value::Boolean(b)) => a == b,
|
(Value::Boolean(a), Value::Boolean(b)) => a == b,
|
||||||
(Value::String(a), Value::String(b)) => a == b,
|
(Value::String(a), Value::String(b)) => a == b,
|
||||||
(Value::Bounded(a), Value::Bounded(b)) => a == b,
|
(Value::Bounded(a), Value::Bounded(b)) => a == b,
|
||||||
(Value::Gate(a), Value::Gate(b)) => a == b,
|
(Value::Handle(a), Value::Handle(b)) => a == b,
|
||||||
(Value::Null, Value::Null) => true,
|
(Value::Null, Value::Null) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ impl Value {
|
|||||||
Value::Bounded(b) => format!("{}b", b),
|
Value::Bounded(b) => format!("{}b", b),
|
||||||
Value::Boolean(b) => b.to_string(),
|
Value::Boolean(b) => b.to_string(),
|
||||||
Value::String(s) => s.clone(),
|
Value::String(s) => s.clone(),
|
||||||
Value::Gate(r) => format!("[Gate {}]", r),
|
Value::Handle(r) => format!("[Handle {}]", r),
|
||||||
Value::Null => "null".to_string(),
|
Value::Null => "null".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ impl<'a> HostReturn<'a> {
|
|||||||
self.stack.push(Value::Null);
|
self.stack.push(Value::Null);
|
||||||
}
|
}
|
||||||
pub fn push_gate(&mut self, g: usize) {
|
pub fn push_gate(&mut self, g: usize) {
|
||||||
self.stack.push(Value::Gate(g));
|
self.stack.push(Value::Handle(g));
|
||||||
}
|
}
|
||||||
pub fn push_string(&mut self, s: String) {
|
pub fn push_string(&mut self, s: String) {
|
||||||
self.stack.push(Value::String(s));
|
self.stack.push(Value::String(s));
|
||||||
|
|||||||
@ -92,7 +92,7 @@ pub struct VirtualMachine {
|
|||||||
pub breakpoints: std::collections::HashSet<usize>,
|
pub breakpoints: std::collections::HashSet<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// HIP/Gate runtime structures removed per PR-2.1
|
// HIP/Handle runtime structures removed per PR-2.1
|
||||||
|
|
||||||
impl Default for VirtualMachine {
|
impl Default for VirtualMachine {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|||||||
@ -1,58 +1,3 @@
|
|||||||
# PR-2.3 — Normalize Value Model (Stack vs Heap References)
|
|
||||||
|
|
||||||
### Briefing
|
|
||||||
|
|
||||||
The VM must use a clear value model: primitives and tuples on the stack, heap objects referenced through opaque handles. This PR prepares the VM for the GC-based heap.
|
|
||||||
|
|
||||||
### Target
|
|
||||||
|
|
||||||
* Define a single `Value` representation that distinguishes:
|
|
||||||
|
|
||||||
* Immediate primitives.
|
|
||||||
* Heap references (opaque handles).
|
|
||||||
* Remove any gate-based or borrow-based value types.
|
|
||||||
|
|
||||||
### Work items
|
|
||||||
|
|
||||||
* Review the `Value` or equivalent enum/struct.
|
|
||||||
* Remove variants related to gates, borrows, or HIP.
|
|
||||||
* Ensure only the following categories remain:
|
|
||||||
|
|
||||||
* Primitives (int, bool, etc.).
|
|
||||||
* Tuples or small aggregates.
|
|
||||||
* Heap reference handle (placeholder for future GC objects).
|
|
||||||
* Update stack operations accordingly.
|
|
||||||
|
|
||||||
### Acceptance checklist
|
|
||||||
|
|
||||||
* [ ] `Value` type has no HIP/gate-related variants.
|
|
||||||
* [ ] All stack operations compile with the new value model.
|
|
||||||
* [ ] No borrow/mutate semantics remain.
|
|
||||||
* [ ] `cargo test` passes.
|
|
||||||
|
|
||||||
### Tests
|
|
||||||
|
|
||||||
* Existing tests only.
|
|
||||||
|
|
||||||
### Junie instructions
|
|
||||||
|
|
||||||
**You MAY:**
|
|
||||||
|
|
||||||
* Simplify the `Value` enum/struct.
|
|
||||||
* Remove legacy variants and adjust matches.
|
|
||||||
|
|
||||||
**You MUST NOT:**
|
|
||||||
|
|
||||||
* Design the GC handle layout.
|
|
||||||
* Introduce new object systems.
|
|
||||||
* Change instruction semantics beyond type cleanup.
|
|
||||||
|
|
||||||
**If unclear:**
|
|
||||||
|
|
||||||
* Ask what the intended value shape should be.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# PR-2.4 — Consolidate Trap and Error Surface
|
# PR-2.4 — Consolidate Trap and Error Surface
|
||||||
|
|
||||||
### Briefing
|
### Briefing
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user