feat: added runtime errors class and object
This commit is contained in:
@@ -3,6 +3,8 @@ package wacc
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import cats.data.Chain
|
||||
import cats.syntax.foldable._
|
||||
import wacc.RuntimeErrors._
|
||||
|
||||
|
||||
object asmGenerator {
|
||||
import microWacc._
|
||||
@@ -13,24 +15,6 @@ object asmGenerator {
|
||||
import sizeExtensions._
|
||||
import lexer.escapedChars
|
||||
|
||||
abstract case class Error() {
|
||||
def strLabel: String
|
||||
def errStr: String
|
||||
def errLabel: String
|
||||
|
||||
def stringDef: Chain[AsmLine] = Chain(
|
||||
Directive.Int(errStr.size),
|
||||
LabelDef(strLabel),
|
||||
Directive.Asciz(errStr)
|
||||
)
|
||||
}
|
||||
object zeroDivError extends Error {
|
||||
// TODO: is this bad? Can we make an error case class/some other structure?
|
||||
def strLabel = ".L._errDivZero_str0"
|
||||
def errStr = "fatal error: division or modulo by zero"
|
||||
def errLabel = ".L._errDivZero"
|
||||
}
|
||||
|
||||
private val RAX = Register(Q64, AX)
|
||||
private val EAX = Register(D32, AX)
|
||||
private val RDI = Register(Q64, DI)
|
||||
|
||||
Reference in New Issue
Block a user