Compile static methods

This commit is contained in:
Andrew Morris
2023-06-23 10:02:32 +10:00
parent 6ef2eea2c1
commit 540b25225a
2 changed files with 9 additions and 2 deletions

View File

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

View File

@@ -674,6 +674,7 @@ impl ModuleCompiler {
) -> Pointer {
let mut constructor: Value = Value::Void;
let mut prototype: Object = Object::default();
let mut static_: Object = Object::default();
let mut dependent_definitions: Vec<Definition>;
let defn_name = match ident {
@@ -820,7 +821,12 @@ impl ModuleCompiler {
Functionish::Fn(None, method.function.clone()),
));
prototype
let dst = match method.is_static {
false => &mut prototype,
true => &mut static_,
};
dst
.properties
.push((name, Value::Pointer(method_defn_name)));
}
@@ -848,7 +854,7 @@ impl ModuleCompiler {
content: DefinitionContent::Class(Class {
constructor,
prototype: Value::Object(Box::new(prototype)),
static_: Value::Object(Box::new(Object::default())),
static_: Value::Object(Box::new(static_)),
}),
});