Always transpile function when annotated with tick or load
This commit is contained in:
parent
62dd12cab3
commit
42503bdc78
|
@ -87,7 +87,7 @@ impl Transpiler {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
self.functions.write().unwrap().insert(
|
self.add_function_data(
|
||||||
name,
|
name,
|
||||||
FunctionData {
|
FunctionData {
|
||||||
namespace: "shulkerscript".to_string(),
|
namespace: "shulkerscript".to_string(),
|
||||||
|
@ -99,6 +99,18 @@ impl Transpiler {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the given function data to the transpiler.
|
||||||
|
/// If the function has the `tick` or `load` annotation, it will be transpiled immediately.
|
||||||
|
fn add_function_data(&mut self, name: String, function: FunctionData) {
|
||||||
|
let always_transpile_function =
|
||||||
|
function.annotations.contains_key("tick") || function.annotations.contains_key("load");
|
||||||
|
let cloned_name = always_transpile_function.then(|| name.clone());
|
||||||
|
self.functions.write().unwrap().insert(name, function);
|
||||||
|
if let Some(name) = cloned_name {
|
||||||
|
self.get_or_transpile_function(&name);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets the function at the given path, or transpiles it if it hasn't been transpiled yet.
|
/// Gets the function at the given path, or transpiles it if it hasn't been transpiled yet.
|
||||||
/// Returns the location of the function or None if the function does not exist.
|
/// Returns the location of the function or None if the function does not exist.
|
||||||
#[allow(clippy::significant_drop_tightening)]
|
#[allow(clippy::significant_drop_tightening)]
|
||||||
|
|
Loading…
Reference in New Issue