+static int _call_get_func(scf_function_t** pf, scf_node_t* array, scf_vector_t* indexes)
+{
+ scf_variable_t* base = _scf_operand_get(array);
+ scf_variable_t* v;
+ int i;
+ int j;
+
+ if (indexes) {
+ for (i = indexes->size - 1; i >= 0; i--) {
+ v = indexes->data[i];
+ j = v->data.i64;
+
+ if (!base->js_dimentions
+ || base->js_nb_dimentions <= 0
+ || base->js_dimentions[0].num <= j)
+ return -EINVAL;
+
+ if (!base->js_dimentions[0].vars || j >= base->js_dimentions[0].vars->size)
+ return -EINVAL;
+
+ base = base->js_dimentions[0].vars->data[j];
+ if (!base)
+ return -EINVAL;
+ }
+ }
+
+ if (SCF_FUNCTION_PTR == base->type) {
+
+ if (!base->const_literal_flag || !base->func_ptr) {
+ scf_loge("function obj '%s' is not const\n", base->w->text->data);
+ return -EINVAL;
+ }
+
+ *pf = base->func_ptr;
+ }
+
+ return 0;
+}
+
+static int _call_use_func(scf_ast_t* ast, scf_node_t* call, scf_function_t* f)
+{
+ scf_variable_t* v;
+ scf_node_t* pf;
+ scf_expr_t* e;
+ scf_type_t* t = NULL;
+
+ int ret = scf_ast_find_type_type(&t, ast, SCF_FUNCTION_PTR);
+ if (ret < 0)
+ return ret;
+
+ v = SCF_VAR_ALLOC_BY_TYPE(f->node.w, t, 1, 1, f);
+ if (!v)
+ return -ENOMEM;
+ v->const_literal_flag = 1;
+
+ pf = scf_node_alloc(NULL, v->type, v);
+ scf_variable_free(v);
+ v = NULL;
+ if (!pf)
+ return -ENOMEM;
+
+ scf_node_free(call->nodes[0]);
+ call->nodes[0] = pf;
+
+ pf->parent = call;
+ return 0;
+}
+