Example #1
0
int max_exp_list(A_expList exp_list) {
    if (exp_list->kind == A_lastExpList) {
        return max_exp(exp_list->u.last);
    } else {
        return max(max_exp(exp_list->u.pair.head), max_exp_list(exp_list->u.pair.tail));
    }
}
Example #2
0
int max_exp(A_exp exp) {
    if (exp->kind == A_idExp || exp->kind == A_numExp) {
        return 0;
    } else if (exp->kind == A_opExp) {
        return max(max_exp(exp->u.op.left), max_exp(exp->u.op.right));
    } else {
        return max(maxargs(exp->u.eseq.stm), max_exp(exp->u.eseq.exp));
    }
}
Example #3
0
int maxargs(A_stm statement) {
    if (statement->kind == A_printStm) {
        A_expList exp_list = statement->u.print.exps;
        return max(count_exp_list(exp_list), max_exp_list(exp_list));
    } else if (statement->kind == A_assignStm) {
        return max_exp(statement->u.assign.exp);
    } else if (statement->kind == A_compoundStm) {
        return max(maxargs(statement->u.compound.stm1), maxargs(statement->u.compound.stm2));
    } else {
        return 0;
    }
}
Example #4
0
F32 Player::scale()
{
    F32 s = ( (F32)exp() / (F32)max_exp());
    if( s < 0.001f ) s = 0.001f;
    return s;
}