Skip to content

Commit

Permalink
Fix NodeType hierarchy.
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Sep 4, 2023
1 parent e49ad7c commit edec706
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions ast/src/main/kotlin/gay/pizza/pork/ast/NodeType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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>

Expand All @@ -37,6 +38,4 @@ enum class NodeType(val parent: NodeType? = null) {
}
parents = calculatedParents.toSet()
}

fun isa(type: NodeType): Boolean = this == type || parents.contains(type)
}
2 changes: 0 additions & 2 deletions frontend/src/main/kotlin/gay/pizza/pork/frontend/World.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@ class World(val contentSource: ContentSource) {
resolveAllImports(unit)
return unit
}

fun units(path: String): Set<CompilationUnit> = resolveAllImports(loadOneUnit(path))
}

0 comments on commit edec706

Please sign in to comment.