예제 #1
0
static StatementResult excute_statement(LocalEnvironment *env, Statement *stmt) {
    StatementResult result;
    fprintf(stderr, "statement type:%s\n", statement_type_str[stmt->type].format);
    switch(stmt->type) {
    case EXPRESSION_STATEMENT:
        result = execute_expression_statement(env, stmt->u.expr_stat);
        break;
    case IF_STATEMENT:
        result = execute_if_statement(env, &stmt->u.if_stat, stmt->line_num);
        break;
    case FOR_STATEMENT:
        result = execute_for_statement(env, &stmt->u.for_stat, stmt->line_num);
        break;
    case WHILE_STATEMENT:
        result = execute_while_statement(env, &stmt->u.while_stat, stmt->line_num);
        break;
    case RETURN_STATEMENT:
        result = execute_return_statement(env, &stmt->u.return_stat);
        break;
    case BREAK_STATEMENT:
        result = execute_break_statement();
        break;
    case CONTINUE_STATEMENT:
        result = execute_continue_statement();
        break;
    default:
        abc_internal_error(stmt->line_num, UNKNOWN_STATEMENT_TYPE_ERR);
    }
    return result;
}
예제 #2
0
파일: execute.c 프로젝트: BluePanM/code
static StatementResult
execute_statement(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
                  Statement *statement)
{
    StatementResult result;

    result.type = NORMAL_STATEMENT_RESULT;

    switch (statement->type) {
    case EXPRESSION_STATEMENT:
        result = execute_expression_statement(inter, env, statement);
        break;
    case GLOBAL_STATEMENT:
        result = execute_global_statement(inter, env, statement);
        break;
    case IF_STATEMENT:
        result = execute_if_statement(inter, env, statement);
        break;
    case WHILE_STATEMENT:
        result = execute_while_statement(inter, env, statement);
        break;
    case FOR_STATEMENT:
        result = execute_for_statement(inter, env, statement);
        break;
    case RETURN_STATEMENT:
        result = execute_return_statement(inter, env, statement);
        break;
    case BREAK_STATEMENT:
        result = execute_break_statement(inter, env, statement);
        break;
    case CONTINUE_STATEMENT:
        result = execute_continue_statement(inter, env, statement);
        break;
    case STATEMENT_TYPE_COUNT_PLUS_1:   /* FALLTHRU */
    default:
        DBG_panic(("bad case...%d", statement->type));
    }

    return result;
}