data_type_t typecheck_expression(node_t* root) { data_type_t toReturn; if(outputStage == 10) fprintf( stderr, "Type checking expression %s\n", root->expression_type.text); toReturn = te(root); //Insert additional checking here switch(root->expression_type.index) { case FUNC_CALL_E: /* check number of arguments */ fprintf(stderr, ""); /*hack to avoid some wierd error */ function_symbol_t *func = malloc(sizeof(function_symbol_t)); func = function_get(root->children[0]->label); if(root->children[1] != NULL && func->nArguments != root->children[1]->n_children) type_error(root); else for(int i = 0; i < func->nArguments; i++) if(root->children[1] != NULL && !equal_types(func->argument_types[i], root->children[1]->children[i]->data_type)) type_error(root); return func->return_type; break; case CLASS_FIELD_E: /* add code to compute the * type of class_field_access * expressions */ return root->children[1]->data_type; break; } }
bool function_get_definition(const wcstring &name, wcstring *out_definition) { scoped_lock locker(functions_lock); const function_info_t *func = function_get(name); if (func && out_definition) { out_definition->assign(func->definition); } return func != NULL; }
bool function_get_desc(const wcstring &name, wcstring *out_desc) { // Empty length string goes to NULL. scoped_lock locker(functions_lock); const function_info_t *func = function_get(name); if (out_desc && func && !func->description.empty()) { out_desc->assign(_(func->description.c_str())); return true; } else { return false; } }
/* find an anonymous function by address */ void *context_find_anonymous(context_t *cont, byte *ptr) { function_t *func; context_lock(cont); func = LIST_TO_STRUCT(function_t, list, cont->anonym.next); while (func != NULL) { if (func->func_code == ptr) { function_get(func); context_unlock(cont); return func; } func = LIST_TO_STRUCT(function_t, list, func->list.next); } context_unlock(cont); return NULL; }
/* find a function by name */ void *context_find_function(context_t *cont, byte *name) { function_t *func; context_lock(cont); func = LIST_TO_STRUCT(function_t, list, cont->funcs.next); while (func != NULL) { if (!string_compare(func->name, (char *)name)) { function_get(func); context_unlock(cont); return func; } func = LIST_TO_STRUCT(function_t, list, func->list.next); } context_unlock(cont); return NULL; }
int function_get_definition_offset(const wcstring &name) { scoped_lock lock(functions_lock); const function_info_t *func = function_get(name); return func ? func->definition_offset : -1; }
const wchar_t *function_get_definition_file(const wcstring &name) { scoped_lock lock(functions_lock); const function_info_t *func = function_get(name); return func ? func->definition_file : NULL; }
int function_get_shadows(const wcstring &name) { scoped_lock lock(functions_lock); const function_info_t *func = function_get(name); return func ? func->shadows : false; }
wcstring_list_t function_get_named_arguments(const wcstring &name) { scoped_lock lock(functions_lock); const function_info_t *func = function_get(name); return func ? func->named_arguments : wcstring_list_t(); }
std::map<wcstring,env_var_t> function_get_inherit_vars(const wcstring &name) { scoped_lock lock(functions_lock); const function_info_t *func = function_get(name); return func ? func->inherit_vars : std::map<wcstring,env_var_t>(); }