Пример #1
0
static CRB_Value
eval_function_call_expression(CRB_Interpreter *inter, LcoalEnvriroment *env,
        Expression *expr)
{
    CRB_Value value;
    FunctionDefinition *func;

    char *identifier = expr->u.function_call_expression.identifier;

    func = crb_search_function(identifier);
    if(func == NULL){
        crb_runtime_error(expr->line_number, FUNCTION_NOT_FOUND_ERR,
                STRING_MESSAGE_ARGUMENT, "name", identifier,
                MESSAGE_ARGUMENT_END);
    }
    switch(func->type){
        case CROWBAR_FUNCTION_DEFINITION:
            value = call_crowbar_function(inter, env, expr, func);
            break;
        case NATIVE_FUNCTION_DEFINITION:
            value = call_native_function(inter, env, expr, func->u.native_f.proc);
            break;
        default:
            DBG_panic(("bad case..%d\n", func->type));
    }

    return value;
}
Пример #2
0
static void
eval_function_call_expression(SIMCAR_Interpreter *inter,
                              SIMCAR_LocalEnvironment *env,
                              Expression *expr)
{
    FunctionDefinition  *func;
    SIMCAR_LocalEnvironment    *local_env;

    char *identifier = expr->u.function_call_expression.identifier;

    func = crb_search_function(identifier);
    if (func == NULL) {
        crb_runtime_error(expr->line_number, FUNCTION_NOT_FOUND_ERR,
                          STRING_MESSAGE_ARGUMENT, "name", identifier,
                          MESSAGE_ARGUMENT_END);
    }

    local_env = alloc_local_environment(inter);

    switch (func->type) {
    case CROWBAR_FUNCTION_DEFINITION:
        call_crowbar_function(inter, local_env, env, expr, func);
        break;
    case NATIVE_FUNCTION_DEFINITION:
        call_native_function(inter, local_env, env, expr,
                             func->u.native_f.proc);
        break;
    case FUNCTION_DEFINITION_TYPE_COUNT_PLUS_1:
    default:
        DBG_panic(("bad case..%d\n", func->type));
    }
    dispose_local_environment(inter);
}