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