cl-interpret: impls v1

This commit is contained in:
John 2025-02-23 04:06:14 -06:00
parent 5c99bf09ab
commit adbabc66c5

View File

@ -173,9 +173,24 @@ impl Interpret for Enum {
} }
impl Interpret for Impl { impl Interpret for Impl {
fn interpret(&self, env: &mut Environment) -> IResult<ConValue> { fn interpret(&self, env: &mut Environment) -> IResult<ConValue> {
println!("TODO: impl {}", self.target); let Self { target: ImplKind::Type(Ty { extents: _, kind: TyKind::Path(name) }), body } =
let Self { target: _, body } = self; self
body.interpret(env) else {
eprintln!("TODO: impl X for Ty");
return Ok(ConValue::Empty);
};
env.push_frame("impl", Default::default());
body.interpret(env)?;
let (frame, _) = env
.pop_frame()
.expect("Environment frames must be balanced");
match assignment::addrof_path(env, name.parts.as_slice())? {
Some(ConValue::Module(m)) => m.extend(frame),
Some(other) => eprintln!("TODO: impl for {other}"),
None => {}
}
Ok(ConValue::Empty)
} }
} }