feat: implement .loc, .file and .func debug directives
This commit is contained in:
@@ -199,10 +199,15 @@ object assemblyIR {
|
||||
}
|
||||
|
||||
enum Directive extends AsmLine {
|
||||
case IntelSyntax, RoData, Text
|
||||
case IntelSyntax, RoData, Text, EndFunc
|
||||
case Global(name: String)
|
||||
case Int(value: scala.Int)
|
||||
case Asciz(string: String)
|
||||
case File(no: scala.Int, file: String)
|
||||
case Location(fileNo: scala.Int, lineNo: scala.Int, colNo: Option[scala.Int])
|
||||
case Func(name: String, label: LabelDef)
|
||||
case Type(label: LabelDef, symbolType: SymbolType)
|
||||
case Size(label: LabelDef, expr: SizeExpr)
|
||||
|
||||
override def toString(): String = this match {
|
||||
case IntelSyntax => ".intel_syntax noprefix"
|
||||
@@ -211,6 +216,32 @@ object assemblyIR {
|
||||
case RoData => ".section .rodata"
|
||||
case Int(value) => s"\t.int $value"
|
||||
case Asciz(string) => s"\t.asciz \"$string\""
|
||||
case File(no, file) => s".file $no \"${file}\""
|
||||
case Location(fileNo, lineNo, colNo) =>
|
||||
s"\t.loc $fileNo $lineNo" + colNo.map(c => s" $c").getOrElse("")
|
||||
case Func(name, label) =>
|
||||
s".func $name, ${label.name}"
|
||||
case EndFunc => ".endfunc"
|
||||
case Type(label, symbolType) =>
|
||||
s".type ${label.name}, @${symbolType.toString}"
|
||||
case Directive.Size(label, expr) =>
|
||||
s".size ${label.name}, ${expr.toString}"
|
||||
}
|
||||
}
|
||||
|
||||
enum SymbolType {
|
||||
case Function
|
||||
|
||||
override def toString(): String = this match {
|
||||
case Function => "function"
|
||||
}
|
||||
}
|
||||
|
||||
enum SizeExpr {
|
||||
case Relative(label: LabelDef)
|
||||
|
||||
override def toString(): String = this match {
|
||||
case Relative(label) => s".-${label.name}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user