methods -> prototype

This commit is contained in:
Andrew Morris
2023-06-23 09:23:48 +10:00
parent 290c9b0cf0
commit b3b5887d8b
5 changed files with 7 additions and 7 deletions

View File

@@ -138,14 +138,14 @@ impl std::fmt::Display for Function {
#[derive(Debug, Clone)]
pub struct Class {
pub constructor: Value,
pub methods: Value,
pub prototype: Value,
}
impl std::fmt::Display for Class {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "class({}, ", self.constructor)?;
match &self.methods {
match &self.prototype {
Value::Object(object) => {
write!(f, "{{\n")?;
for (name, method) in &object.properties {
@@ -154,7 +154,7 @@ impl std::fmt::Display for Class {
write!(f, "}})")?;
}
_ => {
write!(f, "{})", self.methods)?;
write!(f, "{})", self.prototype)?;
}
}

View File

@@ -146,7 +146,7 @@ impl Assembler {
fn class(&mut self, class: &Class) {
self.output.push(ValueType::Class as u8);
self.value(&class.constructor);
self.value(&class.methods);
self.value(&class.prototype);
}
fn label(&mut self, label: &Label) {

View File

@@ -530,7 +530,7 @@ impl<'a> AssemblyParser<'a> {
Class {
constructor,
methods,
prototype: methods,
}
}

View File

@@ -185,7 +185,7 @@ where
}
DefinitionContent::Class(class) => {
self.value(Some(&definition.pointer), &mut class.constructor);
self.value(Some(&definition.pointer), &mut class.methods);
self.value(Some(&definition.pointer), &mut class.prototype);
}
DefinitionContent::Value(value) => {
self.value(Some(&definition.pointer), value);

View File

@@ -847,7 +847,7 @@ impl ModuleCompiler {
pointer: defn_name.clone(),
content: DefinitionContent::Class(Class {
constructor,
methods: Value::Object(Box::new(methods)),
prototype: Value::Object(Box::new(methods)),
}),
});