Interpreter - Store static methods inside classes

This commit is contained in:
Emmanuel BENOîT 2023-01-13 08:16:26 +01:00
parent ed704b1a63
commit 75652b95cf
2 changed files with 12 additions and 2 deletions
src/interpreter

View file

@ -232,7 +232,11 @@ impl StmtNode {
ClassMemberDecl::Method(method) => Some(method),
_ => None,
});
let class = Class::new(decl.name.lexeme.clone(), methods);
let static_methods = self.extract_methods(es, decl, |member| match member {
ClassMemberDecl::StaticMethod(method) => Some(method),
_ => None,
});
let class = Class::new(decl.name.lexeme.clone(), methods, static_methods);
es.environment
.borrow_mut()
.assign(&decl.name, class.into())?;