feat: type-checker returns micro wacc

This commit is contained in:
2025-02-17 15:26:32 +00:00
parent b7e442b269
commit 27cc25cc0d
3 changed files with 259 additions and 115 deletions

View File

@@ -19,7 +19,7 @@ object microWacc {
extends Expr(identTy)
with CallTarget(identTy)
with LValue
case class ArrayElem(name: Ident, indices: NonEmptyList[Expr])(ty: SemType)
case class ArrayElem(value: LValue, indices: NonEmptyList[Expr])(ty: SemType)
extends Expr(ty)
with LValue
@@ -48,6 +48,23 @@ object microWacc {
case And
case Or
}
object BinaryOperator {
def fromAst(op: ast.BinaryOp): BinaryOperator = op match {
case _: ast.Add => Add
case _: ast.Sub => Sub
case _: ast.Mul => Mul
case _: ast.Div => Div
case _: ast.Mod => Mod
case _: ast.Greater => Greater
case _: ast.GreaterEq => GreaterEq
case _: ast.Less => Less
case _: ast.LessEq => LessEq
case _: ast.Eq => Eq
case _: ast.Neq => Neq
case _: ast.And => And
case _: ast.Or => Or
}
}
// Statements
sealed trait Stmt