Пример #1
0
int		expose_hook(t_data *data)
{
	img_init(data);
	if (data->fractal == 1)
		mandel_process(data);
	if (data->fractal == 2)
		julia_process(data);
	if (data->fractal == 3)
		burning_process(data);
	if (data->fractal == 4)
		tree_process(data);
	if (data->fractal == 5)
		galaxy_process(data);
	mlx_put_image_to_window(data->mlx, data->win, data->img.adr, 0, 0);
	return (0);
}
Пример #2
0
//generate three address code (TAC)
// so far only traverses the tree and:
// 1. pushes and pops symbols in a symbol table stack according to scope
int tree_process_all(struct tree *t)
{
	if(t == NULL)
	{
		return(1);
	}

	//Pre code generation ops; bring in imports, etc
	tree_preprocess(&t, 0);

	//Generate code
	// init global code list
	struct tac_inst *p = tac_inst_new(2, "MAIN", ":");
	TAC_CODE = tac_inst_list_new(p);

	tree_process(t, 0);

	//post code generation ops; optimization, etc.
}
Пример #3
0
int tree_process(struct tree *t, int depth)
{
	if(t == NULL)
	{	
		return(1);
	}

	//process ops
	// update symbol table
	tree_update_sym_tab(t);

	//classDefinition
	if(strcmp(t->prodrule, "classDefinition") == 0)
	{
		tree_tac_gen_classDefinition(t);
	}
	else if(tree_is_class_instantiation(t) == 0)
	{
		tree_tac_gen_classInstantiation(t);
	}
	/*Now done in class instantiation
	//TODO: globals?
	//variableDefinition
	else if(strcmp(t->prodrule, "variableDefinition") == 0)
	{
		tree_tac_gen_variableDefinition(t, "");
	}
	*/
	//TODO: function call
	/*
	else if(tree_is_function_call(t) == 0)
	{
		tree_tac_gen_function_call(t);
	}
	*/
	//methodDefinition
	else if(strcmp(t->prodrule, "methodDefinition") == 0)
	{
		tree_tac_gen_methodDefinition(t, "");
	}
	// assignmentExpression
	else if(strcmp(t->prodrule, "assignmentExpression") == 0)
	{
		//if this is a full assignmentExpression, process
		struct tree *rtree = NULL; //ident tree
		tree_get_subtree("assignmentOperator", t, &rtree);
		//if 't' has an assignment operator, it has a right hand side.
		if(rtree != NULL)
		{
			tree_tac_gen_assignmentExpression(t);
		}
	}

  	int i;
  	for(i=0; i < t->nkids; i++)
    	{
		tree_process(t->kids[i], depth+1);
	}
	
	return(0); //success
}