use crate::parser::ast::FunctionData;
use crate::runner::ds::error::JErrorType;
use crate::runner::ds::value::JsValue;
use crate::runner::plugin::types::EvalContext;
use crate::runner::plugin::registry::BuiltInRegistry;
use super::types::ValueResult;
pub fn call_function(
_func: &FunctionData,
_this_value: JsValue,
_args: Vec<JsValue>,
_ctx: &mut EvalContext,
) -> ValueResult {
Err(JErrorType::TypeError("Function calls not yet fully implemented".to_string()))
}
pub fn call_builtin(
registry: &BuiltInRegistry,
object: &str,
method: &str,
this_value: JsValue,
args: Vec<JsValue>,
ctx: &mut EvalContext,
) -> ValueResult {
if let Some(builtin_fn) = registry.get_method(object, method) {
builtin_fn.call(ctx, this_value, args)
} else {
Err(JErrorType::TypeError(format!(
"{}.{} is not a function",
object, method
)))
}
}
pub fn is_callable(value: &JsValue) -> bool {
match value {
JsValue::Object(_obj) => {
false
}
_ => false,
}
}
pub fn is_constructor(value: &JsValue) -> bool {
match value {
JsValue::Object(_obj) => {
false
}
_ => false,
}
}