mirror of
				https://github.com/GayPizzaSpecifications/pork.git
				synced 2025-11-03 17:39:38 +00:00 
			
		
		
		
	Fix NodeType hierarchy.
This commit is contained in:
		@ -11,7 +11,7 @@ class FunctionDefinition(
 | 
				
			|||||||
  val arguments: List<Symbol>,
 | 
					  val arguments: List<Symbol>,
 | 
				
			||||||
  val block: Block
 | 
					  val block: Block
 | 
				
			||||||
) : Definition() {
 | 
					) : Definition() {
 | 
				
			||||||
  override val type: NodeType = NodeType.FunctionDeclaration
 | 
					  override val type: NodeType = NodeType.FunctionDefinition
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  override fun <T> visitChildren(visitor: NodeVisitor<T>): List<T> =
 | 
					  override fun <T> visitChildren(visitor: NodeVisitor<T>): List<T> =
 | 
				
			||||||
    visitor.visitNodes(symbol)
 | 
					    visitor.visitNodes(symbol)
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ enum class NodeType(val parent: NodeType? = null) {
 | 
				
			|||||||
  Symbol(Node),
 | 
					  Symbol(Node),
 | 
				
			||||||
  Expression(Node),
 | 
					  Expression(Node),
 | 
				
			||||||
  Declaration(Node),
 | 
					  Declaration(Node),
 | 
				
			||||||
 | 
					  Definition(Node),
 | 
				
			||||||
  Block(Node),
 | 
					  Block(Node),
 | 
				
			||||||
  CompilationUnit(Node),
 | 
					  CompilationUnit(Node),
 | 
				
			||||||
  IntLiteral(Expression),
 | 
					  IntLiteral(Expression),
 | 
				
			||||||
@ -20,7 +21,7 @@ enum class NodeType(val parent: NodeType? = null) {
 | 
				
			|||||||
  FunctionCall(Expression),
 | 
					  FunctionCall(Expression),
 | 
				
			||||||
  If(Expression),
 | 
					  If(Expression),
 | 
				
			||||||
  ImportDeclaration(Declaration),
 | 
					  ImportDeclaration(Declaration),
 | 
				
			||||||
  FunctionDeclaration(Declaration);
 | 
					  FunctionDefinition(Definition);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val parents: Set<NodeType>
 | 
					  val parents: Set<NodeType>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -37,6 +38,4 @@ enum class NodeType(val parent: NodeType? = null) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    parents = calculatedParents.toSet()
 | 
					    parents = calculatedParents.toSet()
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  fun isa(type: NodeType): Boolean = this == type || parents.contains(type)
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -37,6 +37,4 @@ class World(val contentSource: ContentSource) {
 | 
				
			|||||||
    resolveAllImports(unit)
 | 
					    resolveAllImports(unit)
 | 
				
			||||||
    return unit
 | 
					    return unit
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  fun units(path: String): Set<CompilationUnit> = resolveAllImports(loadOneUnit(path))
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user