Beispiel #1
0
struct Symbol* and_expression(struct AndExpression* node)
{
    if (node->type == 0)
        return equality_expression(node->equalityExpression);
    struct Symbol* symbol1 = load_symbol(and_expression(node->andExpression));
    struct Symbol* symbol2 = load_symbol(equality_expression(node->equalityExpression));
    return and_symbol(symbol1, symbol2, node->type);
}
Beispiel #2
0
bool is_and(object *exp) {
    return is_tagged_list(exp, and_symbol());
}
Beispiel #3
0
struct Symbol* assignment_expression(struct AssignmentExpression* node)
{
    if (node->type == 0)
        return conditional_expression(node->conditionalExpression);
    // to do
    struct Symbol* orig_symbol;
    struct Symbol* symbol2 = load_symbol(assignment_expression(node->assignmentExpression));
    struct Symbol* symbol1 = unary_expression(node->unaryExpression, &orig_symbol);
    struct Symbol* symbol3 = 0;
    int specifier = symbol1->specifier;

    test_changeable(orig_symbol);
    if (node->assignmentOperator > 1)
    {
        switch (node->assignmentOperator) {
            case 2:
                symbol3 = multiplicative_symbol(symbol1, symbol2, 1);
                break;
            case 3:
                symbol3 = multiplicative_symbol(symbol1, symbol2, 2);
                break;
            case 4:
                symbol3 = multiplicative_symbol(symbol1, symbol2, 3);
                break;
            case 5:
                symbol3 = additive_symbol(symbol1, symbol2, 1);
                break;
            case 6:
                symbol3 = additive_symbol(symbol1, symbol2, 2);
                break;
            case 7:
                symbol3 = shift_symbol(symbol1, symbol2, 1);
                break;
            case 8:
                symbol3 = shift_symbol(symbol1, symbol2, 2);
                break;
            case 9:
                symbol3 = and_symbol(symbol1, symbol2, 1);
                break;
            case 10:
                symbol3 = exclusive_or_symbol(symbol1, symbol2, 1);
                break;
            case 11:
                symbol3 = inclusive_or_symbol(symbol1, symbol2, 1);
                break;
            default:
                break;
        }
    }
    else
        symbol3 = symbol2;
    
    symbol3 = cast_symbol(symbol3, orig_symbol->specifier, orig_symbol->stars);
    ADDSTRING("  store ");
    code_gen_type_specifier(symbol1->specifier,0,symbol1->length,symbol1->stars);
    ADDSTRING(" ");
    code_gen_symbol('%', symbol3);
    ADDSTRING(", ");
    code_gen_type_specifier(orig_symbol->specifier,0,orig_symbol->length,orig_symbol->stars);
    ADDSTRING("* ");
    code_gen_symbol('%',orig_symbol);
    ADDSTRING(", align ");
    int l = len_gen_type_specifier(specifier);
    sprintf(buf, "%d", l);
    ADDSTRING(buf);
    ADDSTRING("\n");
    return symbol3;
}