just_engine/runner/eval/
function.rs1use crate::parser::ast::FunctionData;
6use crate::runner::ds::error::JErrorType;
7use crate::runner::ds::value::JsValue;
8use crate::runner::plugin::types::EvalContext;
9use crate::runner::plugin::registry::BuiltInRegistry;
10
11use super::types::ValueResult;
12
13pub fn call_function(
15 _func: &FunctionData,
16 _this_value: JsValue,
17 _args: Vec<JsValue>,
18 _ctx: &mut EvalContext,
19) -> ValueResult {
20 Err(JErrorType::TypeError("Function calls not yet fully implemented".to_string()))
27}
28
29pub fn call_builtin(
31 registry: &BuiltInRegistry,
32 object: &str,
33 method: &str,
34 this_value: JsValue,
35 args: Vec<JsValue>,
36 ctx: &mut EvalContext,
37) -> ValueResult {
38 if let Some(builtin_fn) = registry.get_method(object, method) {
39 builtin_fn.call(ctx, this_value, args)
40 } else {
41 Err(JErrorType::TypeError(format!(
42 "{}.{} is not a function",
43 object, method
44 )))
45 }
46}
47
48pub fn is_callable(value: &JsValue) -> bool {
50 match value {
51 JsValue::Object(_obj) => {
52 false
54 }
55 _ => false,
56 }
57}
58
59pub fn is_constructor(value: &JsValue) -> bool {
61 match value {
62 JsValue::Object(_obj) => {
63 false
65 }
66 _ => false,
67 }
68}