refactor: return args and defs from labelGenerator, instead of strings
This commit is contained in:
@@ -17,23 +17,27 @@ private class LabelGenerator {
|
||||
s".L$labelVal"
|
||||
}
|
||||
|
||||
/** Get a named label for a function. */
|
||||
def getLabel(target: CallTarget): String = target match {
|
||||
case Ident(v, _) => s"wacc_$v"
|
||||
case Builtin(name) => s"_$name"
|
||||
private def getLabel(target: CallTarget | RuntimeError): String = target match {
|
||||
case Ident(v, _) => s"wacc_$v"
|
||||
case Builtin(name) => s"_$name"
|
||||
case err: RuntimeError => s".L.${err.name}"
|
||||
}
|
||||
|
||||
/** Get a named label for an error. */
|
||||
def getLabel(target: RuntimeError): String =
|
||||
s".L.${target.name}"
|
||||
/** Get a named label def for a function or error. */
|
||||
def getLabelDef(target: CallTarget | RuntimeError): LabelDef =
|
||||
LabelDef(getLabel(target))
|
||||
|
||||
/** Get a named label for a function or error. */
|
||||
def getLabelArg(target: CallTarget | RuntimeError): LabelArg =
|
||||
LabelArg(getLabel(target))
|
||||
|
||||
/** Get an arbitrary label for a string. */
|
||||
def getLabel(str: String): String =
|
||||
strings.getOrElseUpdate(str, s".L.str${strings.size}")
|
||||
def getLabelArg(str: String): LabelArg =
|
||||
LabelArg(strings.getOrElseUpdate(str, s".L.str${strings.size}"))
|
||||
|
||||
/** Get a named label for a string. */
|
||||
def getLabel(src: String, name: String): String =
|
||||
strings.getOrElseUpdate(src, s".L.$name.str${strings.size}")
|
||||
def getLabelArg(src: String, name: String): LabelArg =
|
||||
LabelArg(strings.getOrElseUpdate(src, s".L.$name.str${strings.size}"))
|
||||
|
||||
/** Generate the assembly labels for constants that were labelled using the LabelGenerator. */
|
||||
def generateConstants: Chain[AsmLine] =
|
||||
|
||||
Reference in New Issue
Block a user