// File: /workspace/github_cpp_makefile_star2_O1/acliusBackHome[P]kamaya/dist/ParseExpression.cpp
// Function: ParseExpression::generate_expression(ExpressionType, ParseExpression const&, ParseExpression const&)
const ParseExpression &ParseExpression::generate_expression(
        ExpressionType type,
        const ParseExpression &expr1,
        const ParseExpression &expr2) {
    ParseExpression res;
    res.expr_type = type;
    res.child[0] = get_expr_id(expr1);
    res.child[1] = get_expr_id(expr2);
    switch (type) {
        case E_ADD:
        case E_SUB:
        case E_MUL:
        case E_DIV:
        case E_MOD:
        case E_POW: {
            // 如果其中一个是不可在编译期计算的表达式, 另一个是常量表达式, 则表达式返回值为不可计算表达式的类型
            if ((!expr1.is_const()) && expr2.is_const()) {
                res.ret_type_id = expr1.get_ret_type().get_id();
            } else if (!(expr2.is_const()) && expr1.is_const()) {
                res.ret_type_id = expr2.get_ret_type().get_id();
            } else {
                // 两者都是变量或者两者都是常量
                try {
                    res.ret_type_id = ParseType::convert(type, expr1.get_ret_type(), expr2.get_ret_type());
                } catch (ParseException &exc) {
                    string info = "in ParseExpression::generate_expression("
                                  "ExpressionType type, "
                                  "const ParseExpression &expr1, "
                                  "const ParseExpression &expr2)";
                    info += " expr1=" + to_string(expr1.get_id());
                    info += " expr2=" + to_string(expr2.get_id());
                    exc.push_trace(info);
                    throw exc;
                }
                if (expr1.is_const() && expr2.is_const()) {
                    res.calculate_const();
                }
            }
            // 求幂运算比较特殊(想出来C语言支持求幂运算符的要求的真是天才),
            // 返回值是long double
            if (type == E_POW) {
                ParseType ret_type(T_DOUBLE, S_LONG);
                res.ret_type_id = ret_type.get_id();
            }
            break;
        }
        case E_LOGIC_OR:
        case E_LOGIC_AND:
        case E_G:
        case E_GE:
        case E_EQUAL:
        case E_NE:
        case E_L:
        case E_LE:
            res.ret_type_id = T_BOOL;
            if (expr1.is_const() && expr2.is_const()) {
                res.calculate_const();
            }
            break;
        case E_ADR:
        case E_PTR:
        case E_NEG:
        case E_POS:
        case E_BIT_NOT:
        case E_NOT:
        case E_GET_ITEM:
        case E_UNDEFINED:
        case E_VAR:
        case E_CONST:
        case E_FUN:
        case E_ASSIGN: {
            // 错误调用该函数
            string info = "ParseExpression::generate_expression("
                          "ExpressionType type, "
                          "const ParseExpression &expr1, "
                          "const ParseExpression &expr2)";
            info += " expr1=" + to_string(expr1.get_id());
            info += " expr2=" + to_string(expr2.get_id());
            throw ParseException(EX_EXPRESSION_CAN_NOT_GENERATE, info);
        }
    }
    update(res);
    return get_expression(res.get_id());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %r14d
movq $-0x1, -0x80(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movl %edi, -0x78(%rbp)
movq 0x10(%rsi), %rax
testq %rax, %rax
jne 0x2c614
movq %r15, %rdi
callq 0x2b7a0
movq 0x10(%r15), %rax
movq %rax, -0xa0(%rbp)
movq 0x10(%rbx), %rax
testq %rax, %rax
jne 0x2c630
movq %rbx, %rdi
callq 0x2b7a0
movq 0x10(%rbx), %rax
movq %rax, -0x98(%rbp)
cmpl $0x19, %r14d
ja 0x2c75e
movl $0x1fe0000, %eax        # imm = 0x1FE0000
btl %r14d, %eax
jae 0x2c685
movq $0x1, -0x80(%rbp)
movq %r15, %rdi
callq 0x2bb90
testb %al, %al
je 0x2c75e
movq %rbx, %rdi
callq 0x2bb90
testb %al, %al
je 0x2c75e
leaq -0xa0(%rbp), %rdi
callq 0x343a4
jmp 0x2c75e
movl $0x7e0, %eax            # imm = 0x7E0
btl %r14d, %eax
jae 0x2c7b2
movq %r15, %rdi
callq 0x2bb90
testb %al, %al
jne 0x2c6ac
movq %rbx, %rdi
callq 0x2bb90
testb %al, %al
jne 0x2c6c7
movq %rbx, %rdi
callq 0x2bb90
testb %al, %al
jne 0x2c6dd
movq %r15, %rdi
callq 0x2bb90
testb %al, %al
je 0x2c6dd
movq %rbx, %r15
movq %r15, %rdi
callq 0x2bbcc
movq %rax, %rdi
callq 0x2770a
movq %rax, -0x80(%rbp)
jmp 0x2c726
movq %r15, %rdi
callq 0x2bbcc
movq %rax, %r12
movq %rbx, %rdi
callq 0x2bbcc
movl %r14d, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x28dd2
movq %rax, -0x80(%rbp)
movq %r15, %rdi
callq 0x2bb90
testb %al, %al
je 0x2c726
movq %rbx, %rdi
callq 0x2bb90
testb %al, %al
je 0x2c726
leaq -0xa0(%rbp), %rdi
callq 0x343a4
cmpl $0xa, %r14d
jne 0x2c75e
leaq -0xd8(%rbp), %rdi
movl $0x7, %esi
movl $0x2, %edx
callq 0x275d4
leaq -0xd8(%rbp), %rdi
callq 0x2770a
movq %rax, -0x80(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x28344
leaq -0xa0(%rbp), %rdi
callq 0x2b7a0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
jne 0x2c789
leaq -0xa0(%rbp), %rdi
callq 0x2b7a0
movq -0x90(%rbp), %rdi
callq 0x2b8a6
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2c47e
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1ac53(%rip), %rsi     # 0x47418
leaq 0x1acc1(%rip), %rdx     # 0x4748d
leaq -0xd8(%rbp), %rdi
callq 0xf65c
movq 0x10(%r15), %rsi
testq %rsi, %rsi
jne 0x2c7ed
movq %r15, %rdi
callq 0x2b7a0
movq 0x10(%r15), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe329
leaq 0x17554(%rip), %rsi     # 0x43d51
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe2af
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2c830
callq 0x42b0
leaq -0x58(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x2c842
callq 0x42b0
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
jne 0x2c857
movq %rbx, %rdi
callq 0x2b7a0
movq 0x10(%rbx), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe329
leaq 0x174f2(%rip), %rsi     # 0x43d59
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe2af
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2c896
callq 0x42b0
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x2c8a4
callq 0x42b0
movl $0x28, %edi
callq 0x4190
movq %rax, %rbx
leaq -0xd8(%rbp), %rdx
movq %rax, %rdi
movl $0x10, %esi
callq 0x33d12
leaq 0x2f4a4(%rip), %rsi     # 0x5bd70
leaq -0x1e519(%rip), %rdx    # 0xe3ba
movq %rbx, %rdi
callq 0x4540
jmp 0x2cac1
jmp 0x2c959
movq %rax, %r14
movq %rbx, %rdi
callq 0x4250
jmp 0x2c95c
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2c905
callq 0x42b0
jmp 0x2c905
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
jne 0x2c939
jmp 0x2c95c
jmp 0x2c959
movq %rax, %r14
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c92c
callq 0x42b0
jmp 0x2c92c
movq %rax, %r14
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c95c
callq 0x42b0
jmp 0x2c95c
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
callq 0x28344
jmp 0x2cb3f
jmp 0x2cb3c
movq %rax, %r14
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cb3f
callq 0x42b0
jmp 0x2cb3f
jmp 0x2cb3c
movq %rax, %r14
cmpl $0x1, %edx
jne 0x2cb3f
movq %r14, %rdi
callq 0x4160
movq %rax, %r14
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1aa70(%rip), %rsi     # 0x47415
leaq 0x1aae1(%rip), %rdx     # 0x4748d
leaq -0xd8(%rbp), %rdi
callq 0xf65c
movq 0x10(%r15), %rsi
testq %rsi, %rsi
jne 0x2c9cd
movq %r15, %rdi
callq 0x2b7a0
movq 0x10(%r15), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe329
leaq 0x17374(%rip), %rsi     # 0x43d51
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe2af
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2ca10
callq 0x42b0
leaq -0x58(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x2ca22
callq 0x42b0
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
jne 0x2ca37
movq %rbx, %rdi
callq 0x2b7a0
movq 0x10(%rbx), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe329
leaq 0x17312(%rip), %rsi     # 0x43d59
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0xe2af
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x4110
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2ca76
callq 0x42b0
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x2ca84
callq 0x42b0
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x34162
movl $0x28, %edi
callq 0x4190
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3420a
leaq 0x2f2be(%rip), %rsi     # 0x5bd70
leaq -0x1e6ff(%rip), %rdx    # 0xe3ba
movq %rbx, %rdi
callq 0x4540
jmp 0x2cb14
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2cad9
callq 0x42b0
jmp 0x2cad9
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
jne 0x2cb0d
jmp 0x2cb17
jmp 0x2cb14
movq %rax, %r14
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cb00
callq 0x42b0
jmp 0x2cb00
movq %rax, %r14
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cb17
callq 0x42b0
jmp 0x2cb17
movq %rax, %r14
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cb2d
callq 0x42b0
jmp 0x2cb2d
movq %rax, %r14
callq 0x4500
jmp 0x2cb3f
movq %rax, %rdi
callq 0xe590
movq %rax, %r14
leaq -0xa0(%rbp), %rdi
callq 0x2c47e
movq %r14, %rdi
callq 0x4560
nop