当前位置: 首页>>代码示例>>C++>>正文


C++ status::remove_parameters方法代码示例

本文整理汇总了C++中status::remove_parameters方法的典型用法代码示例。如果您正苦于以下问题:C++ status::remove_parameters方法的具体用法?C++ status::remove_parameters怎么用?C++ status::remove_parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在status的用法示例。


在下文中一共展示了status::remove_parameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: code_gen

void n_func_def::code_gen(status& stat, std::ostream& out)
{
	// starting pseudo ops
	stat.change_text_data("text", out);
	out << "\t.globl\t" << stat.get_function_name() << "\n";
	out << "\t.ent\t" << stat.get_function_name() << "\n";
	out << "\t.type\t" << stat.get_function_name() << ", @function\n";
	out << stat.get_function_name() << ":\n";
	
	// dealing with the stack and frame:
	// status contains the function number and number of variables in the function.
	// function 0 is global, main will probably be function 1 (not really relevant here)
	// we need 8 + (vars*4) space on the stack. All variables assigned 4 bytes for simplicity.

	int stack_space = 8 + stat.size_variables();

	out << "\taddiu\t" << "$sp,$sp,-" << stack_space << "\n"; // stack grows down...
	out << "\tsw\t" << "$fp," << (stack_space - 4) << "($sp)\n"; // store the old fp at the top of the stack
	out << "\taddi\t" << "$fp,$sp," << stack_space << "\n"; // set new fp at the top of the stack frame.
	
	if (left != NULL)
		left->code_gen(stat, out); // the function body.

	out << "\tmove\t$v0,$zero\n"; // return zero by default
	if (stat.number_returns() > 0)
		out << "r" << stat.get_function_name() << ":\n"; // label to branch to and return

	out << "\tlw\t" << "$fp," << (stack_space - 4) << "($sp)\n"; // restore the old fp
	out << "\taddiu\t" << "$sp,$sp," << stack_space << "\n"; // move the stack back up.

	out << "\tj\t$ra\n"; // return
	out << "\tnop\n";

	out << "\t.end\t" << stat.get_function_name() << "\n\n";

	stat.remove_parameters();
	return;
}
开发者ID:coopersimon,项目名称:Compiler,代码行数:38,代码来源:ast.cpp


注:本文中的status::remove_parameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。