Exemplo n.º 1
0
/** execute_routine    	Execute a program, procedure, or
 *			function.
 *
 * @param p_function_id : ptr to the routine symtab node
 */
void cx_executor::execute_routine (cx_symtab_node *p_function_id) {

    enter_routine(p_function_id);

    execute_compound(p_function_id);

    exit_routine(p_function_id);
}
Exemplo n.º 2
0
/** execute_statement   	Execute a Cx statement
 *
 * @param p_function_id : ptr to the routine symtab node
 */
void cx_executor::execute_statement(cx_symtab_node *p_function_id) {
    if (token != tc_left_bracket) {
        ++statement_count;
        trace_statement();
    }

    switch (token) {
        case tc_identifier:
        {
            if (p_node->defn.how == dc_function) {
                execute_function_call(p_node);
            } else {
                cx_symtab_node *p_var = p_node;
                get_token();
                if (token_in(token, tokenlist_assign_ops)) {
                    execute_assignment(p_var);
                } else {
                    execute_variable(p_var, false);
                    pop();
                }
            }
        }
            break;
        case tc_DO: execute_DO(p_function_id);
            break;
        case tc_WHILE: execute_WHILE(p_function_id);
            break;
        case tc_IF: execute_IF(p_function_id);
            break;
        case tc_FOR: execute_FOR(p_function_id);
            break;
        case tc_SWITCH: //parse_SWITCH();
            break;
        case tc_CASE:
        case tc_DEFAULT://parse_case_label();
            break;
        case tc_BREAK:
            get_token();
            break_loop = true;
            break;
        case tc_left_bracket: execute_compound(p_function_id);
            break;
        case tc_RETURN: execute_RETURN(p_function_id);
            break;
        default:
            break;
    }
}