vm: very basic virtual machine

This commit is contained in:
2023-11-14 23:44:10 -08:00
parent 8c48c93663
commit 041848c14e
92 changed files with 1652 additions and 243 deletions

View File

@ -0,0 +1,42 @@
package gay.pizza.pork.ast
import gay.pizza.pork.ast.gen.*
abstract class FunctionLevelVisitor<T> : NodeVisitor<T> {
override fun visitForInItem(node: ForInItem): T =
throw RuntimeException("Visiting ForInItem is not supported.")
override fun visitSymbol(node: Symbol): T =
throw RuntimeException("Visiting Symbol is not supported.")
override fun visitLetDefinition(node: LetDefinition): T {
topLevelUsedError("LetDefinition")
}
override fun visitArgumentSpec(node: ArgumentSpec): T =
throw RuntimeException("Visiting ArgumentSpec is not supported.")
override fun visitFunctionDefinition(node: FunctionDefinition): T {
topLevelUsedError("FunctionDefinition")
}
override fun visitImportDeclaration(node: ImportDeclaration): T {
topLevelUsedError("ImportDeclaration")
}
override fun visitImportPath(node: ImportPath): T {
topLevelUsedError("ImportPath")
}
override fun visitCompilationUnit(node: CompilationUnit): T {
topLevelUsedError("CompilationUnit")
}
override fun visitNativeFunctionDescriptor(node: NativeFunctionDescriptor): T {
topLevelUsedError("NativeFunctionDescriptor")
}
private fun topLevelUsedError(name: String): Nothing {
throw RuntimeException("$name cannot be visited in a FunctionVisitor.")
}
}