本文整理汇总了C++中status::is_float方法的典型用法代码示例。如果您正苦于以下问题:C++ status::is_float方法的具体用法?C++ status::is_float怎么用?C++ status::is_float使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类status
的用法示例。
在下文中一共展示了status::is_float方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: code_gen
void n_expression::code_gen(status& stat, std::ostream& out)
{
// left OP right : result_reg = t0 OP t1
bool unlock = false;
if (!stat.get_assign_expr())
{
stat.lock_register(out);
stat.set_assign_expr();
unlock = true;
}
if (opstr == "+")
{
if (left != NULL)
{
left->code_gen(stat, out);
stat.lock_register(out);
right->code_gen(stat, out);
int op2 = stat.get_register();
int op2f = stat.get_f_register();
stat.unlock_register(out);
if (stat.is_float())
out << "\tadd.s\t$f" << stat.get_f_register() << ",$f" << stat.get_f_register() << ",$f" << op2f << "\n";
else
out << "\tadd\t$t" << stat.get_register() << ",$t" << stat.get_register() << ",$t" << op2 << "\n";
}
else
{
right->code_gen(stat, out);
}
}
else if (opstr == "-")
{
if (left != NULL)
{
left->code_gen(stat, out);
stat.lock_register(out);
right->code_gen(stat, out);
int op2 = stat.get_register();
int op2f = stat.get_f_register();
stat.unlock_register(out);
if (stat.is_float())
out << "\tsub.s\t$f" << stat.get_f_register() << ",$f" << stat.get_f_register() << ",$f" << op2f << "\n";
else
out << "\tsub\t$t" << stat.get_register() << ",$t" << stat.get_register() << ",$t" << op2 << "\n";
}
else
{
stat.lock_register(out);
right->code_gen(stat, out);
int op2 = stat.get_register();
stat.unlock_register(out);
out << "\tneg\t$t" << stat.get_register() << ",$t" << op2 << "\n";
}
}
else if (opstr == "*")
{
if (left != NULL) // if operation is left MULT right
{
left->code_gen(stat, out);
stat.lock_register(out);
right->code_gen(stat, out);
int op2 = stat.get_register();
int op2f = stat.get_f_register();
stat.unlock_register(out);
if (stat.is_float())
out << "\tmul.s\t$f" << stat.get_f_register() << ",$f" << stat.get_f_register() << ",$f" << op2f << "\n";
else
out << "\tmul\t$t" << stat.get_register() << ",$t" << stat.get_register() << ",$t" << op2 << "\n";
}
else // if operation is dereferencing
{
if (stat.get_assign_var())
stat.lock_register(out);
int op2 = stat.get_register();
stat.set_dereference();
right->code_gen(stat, out);
stat.set_dereference();
if (stat.get_assign_var()) // if variable needs to be saved
stat.unlock_register(out);
out << "\t" << stat.pointer_opcode() << "\t$t" << stat.get_register() << ",($t" << op2 << ")\n";
}
}
else if (opstr == "/")
{
left->code_gen(stat, out);
stat.lock_register(out);
right->code_gen(stat, out);
int op2 = stat.get_register();
int op2f = stat.get_f_register();
stat.unlock_register(out);
if (stat.is_float())
out << "\tdiv.s\t$f" << stat.get_f_register() << ",$f" << stat.get_f_register() << ",$f" << op2f << "\n";
else
out << "\tdiv\t$t" << stat.get_register() << ",$t" << stat.get_register() << ",$t" << op2 << "\n";
}
else if (opstr == "%")
{
left->code_gen(stat, out);
stat.lock_register(out);
right->code_gen(stat, out);
//.........这里部分代码省略.........