add a standard library, and introduce formed imports (import std "myfile.pork")

This commit is contained in:
2023-09-06 21:39:57 -07:00
parent f31e12df89
commit 0e4362eefb
18 changed files with 153 additions and 32 deletions

View File

@ -110,6 +110,8 @@ types:
ImportDeclaration:
parent: Declaration
values:
- name: form
type: Symbol?
- name: path
type: StringLiteral
IntLiteral:

View File

@ -6,22 +6,23 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("importDeclaration")
class ImportDeclaration(val path: StringLiteral) : Declaration() {
class ImportDeclaration(val form: Symbol?, val path: StringLiteral) : Declaration() {
override val type: NodeType = NodeType.ImportDeclaration
override fun <T> visitChildren(visitor: NodeVisitor<T>): List<T> =
visitor.visitNodes(path)
visitor.visitNodes(form, path)
override fun <T> visit(visitor: NodeVisitor<T>): T =
visitor.visitImportDeclaration(this)
override fun equals(other: Any?): Boolean {
if (other !is ImportDeclaration) return false
return other.path == path
return other.form == form && other.path == path
}
override fun hashCode(): Int {
var result = path.hashCode()
var result = form.hashCode()
result = 31 * result + path.hashCode()
result = 31 * result + type.hashCode()
return result
}