forked from eden-emu/eden
		
	Shader_IR: clean up AST handling and add documentation.
This commit is contained in:
		
							parent
							
								
									e9f4340b88
								
							
						
					
					
						commit
						8561edf839
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -432,6 +432,12 @@ void ASTManager::InsertReturn(Expr condition, bool kills) { | ||||||
|     program->nodes.PushBack(node); |     program->nodes.PushBack(node); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // The decompile algorithm is based on
 | ||||||
|  | // "Taming control flow: A structured approach to eliminating goto statements"
 | ||||||
|  | // by AM Erosa, LJ Hendren 1994. In general, the idea is to get gotos to be
 | ||||||
|  | // on the same structured level as the label which they jump to. This is done,
 | ||||||
|  | // through outward/inward movements and lifting. Once they are at the same
 | ||||||
|  | // level, you can enclose them in an "if" structure or a "do-while" structure.
 | ||||||
| void ASTManager::Decompile() { | void ASTManager::Decompile() { | ||||||
|     auto it = gotos.begin(); |     auto it = gotos.begin(); | ||||||
|     while (it != gotos.end()) { |     while (it != gotos.end()) { | ||||||
|  | @ -656,11 +662,9 @@ void ASTManager::EncloseIfThen(ASTNode goto_node, ASTNode label) { | ||||||
|     sub_zipper->Init(goto_node, if_node); |     sub_zipper->Init(goto_node, if_node); | ||||||
|     zipper.InsertAfter(if_node, prev); |     zipper.InsertAfter(if_node, prev); | ||||||
|     sub_zipper->Remove(goto_node); |     sub_zipper->Remove(goto_node); | ||||||
|     // ShowCurrentState("After IfThen Enclose");
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ASTManager::MoveOutward(ASTNode goto_node) { | void ASTManager::MoveOutward(ASTNode goto_node) { | ||||||
|     // ShowCurrentState("Before MoveOutward");
 |  | ||||||
|     ASTZipper& zipper = goto_node->GetManager(); |     ASTZipper& zipper = goto_node->GetManager(); | ||||||
|     const ASTNode parent = goto_node->GetParent(); |     const ASTNode parent = goto_node->GetParent(); | ||||||
|     ASTZipper& zipper2 = parent->GetManager(); |     ASTZipper& zipper2 = parent->GetManager(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fernando Sahmkow
						Fernando Sahmkow