/*
 * phc -- the open source PHP compiler
 * See license/README.license for licensing information
 *
 * Compile PHP code to the phc intermediate representation
 */

#ifndef PHC_GENERATE_IR
#define PHC_GENERATE_IR

#include <phc/Tree_visitor.h>

class Generate_IR : public Tree_visitor
{
protected:
	int next_temp;
	int next_label;
	AST_class_def* current_class;

	list<int> continue_stack;

	int get_temp(AST_node* node);

public:
	Generate_IR();

public:

	void post_return(AST_return* in);
	void pre_class_def(AST_class_def* in);
	void pre_method(AST_method* in);
	void post_method(AST_method* in);
	void children_if(AST_if* in);
	void children_while(AST_while* in);
	void children_for(AST_for* in);
	void children_continue(AST_continue* in);
	void post_method_invocation(AST_method_invocation* in);
	void post_assignment(AST_assignment* in);
	void post_variable(AST_variable* in);
	void children_conditional_expr(AST_conditional_expr* in);
	void children_bin_op(AST_bin_op* in);
	void post_unary_op(AST_unary_op* in);
	void post_literal(AST_literal* in);

};

#endif // PHC_GENERATE_IR
