-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
language: implement proper virtual machine support
- Loading branch information
Showing
55 changed files
with
312 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed interface IrCodeElement : IrElement |
4 changes: 1 addition & 3 deletions
4
.../gay/pizza/pork/compiler/IrCodeVisitor.kt → ...otlin/gay/pizza/pork/bir/IrCodeVisitor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed interface IrConstant : IrCodeElement { | ||
override fun crawl(block: (IrElement) -> Unit) {} | ||
} | ||
|
||
@Serializable | ||
data class IrIntegerConstant(val value: Int) : IrConstant | ||
|
||
@Serializable | ||
data class IrLongConstant(val value: Long) : IrConstant | ||
|
||
@Serializable | ||
data class IrDoubleConstant(val value: Double) : IrConstant | ||
|
||
@Serializable | ||
data class IrStringConstant(val value: String) : IrConstant | ||
|
||
@Serializable | ||
data class IrBooleanConstant(val value: Boolean) : IrConstant | ||
|
||
@Serializable | ||
data object IrNoneConstant : IrConstant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed interface IrElement { | ||
fun crawl(block: (IrElement) -> Unit) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class IrFunctionArgument(override val symbol: IrSymbol) : IrSymbolOwner { | ||
override fun crawl(block: (IrElement) -> Unit) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class IrIndex(val data: IrCodeElement, val index: IrCodeElement) : IrCodeElement { | ||
override fun crawl(block: (IrElement) -> Unit) { | ||
block(data) | ||
block(index) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class IrListSize(val list: IrCodeElement) : IrCodeElement { | ||
override fun crawl(block: (IrElement) -> Unit) { | ||
block(list) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class IrNativeDefinition(val form: String, val definitions: List<String>) : IrCodeElement { | ||
override fun crawl(block: (IrElement) -> Unit) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
package gay.pizza.pork.bir | ||
|
||
data class IrSymbol(val id: UInt, val tag: IrSymbolTag) : IrElement { | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class IrSymbol(val id: UInt, val tag: IrSymbolTag, val name: String? = null) : IrElement { | ||
override fun crawl(block: (IrElement) -> Unit) {} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (other !is IrSymbol) return false | ||
return other.id == id && other.tag == tag | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = id.hashCode() | ||
result = 31 * result + tag.hashCode() | ||
return result | ||
} | ||
|
||
val friendlyName: String | ||
get() = if (name != null) { | ||
"$id $tag $name" | ||
} else "$id $tag" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed interface IrSymbolOwner : IrElement { | ||
val symbol: IrSymbol | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package gay.pizza.pork.bir | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed interface IrSymbolUser : IrElement { | ||
val target: IrSymbol | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.