mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-12 03:30:09 +00:00
Code cleanup
This commit is contained in:
parent
4f46b21867
commit
5f2ecb8258
@ -35,7 +35,6 @@ object MacroExpander {
|
||||
case IfStatement(c, t, e) => IfStatement(f(c), t.map(gx), e.map(gx))
|
||||
case s:AssemblyStatement => s.copy(expression = f(s.expression))
|
||||
case Assignment(d,s) => Assignment(fx(d), f(s))
|
||||
case BlockStatement(s) => BlockStatement(s.map(gx))
|
||||
case BreakStatement(s) => if (s == paramName) BreakStatement(target.toString) else stmt
|
||||
case ContinueStatement(s) => if (s == paramName) ContinueStatement(target.toString) else stmt
|
||||
case _ =>
|
||||
|
@ -150,8 +150,6 @@ object StatementCompiler {
|
||||
case _ =>
|
||||
}
|
||||
ExpressionCompiler.compile(ctx, e, None, NoBranching)
|
||||
case BlockStatement(s) =>
|
||||
s.flatMap(compile(ctx, _))
|
||||
case ReturnStatement(None) =>
|
||||
// TODO: return type check
|
||||
// TODO: better stackpointer fix
|
||||
|
@ -838,7 +838,6 @@ class Environment(val parent: Option[Environment], val prefix: String) {
|
||||
def nameCheck(node: Node): Unit = node match {
|
||||
case _:AssemblyStatement => ()
|
||||
case _:DeclarationStatement => ()
|
||||
case s:BlockStatement => nameCheck(s.body)
|
||||
case s:ForStatement =>
|
||||
checkName[Variable]("Variable", s.variable, s.position)
|
||||
nameCheck(s.start)
|
||||
@ -855,6 +854,8 @@ class Environment(val parent: Option[Environment], val prefix: String) {
|
||||
nameCheck(s.body)
|
||||
nameCheck(s.condition)
|
||||
case s:Statement => nameCheck(s.getAllExpressions)
|
||||
case BlackHoleExpression => ()
|
||||
case _:BooleanLiteralExpression => ()
|
||||
case _:LiteralExpression => ()
|
||||
case VariableExpression(name) =>
|
||||
checkName[VariableLikeThing]("Variable or constant", name, node.position)
|
||||
|
4
src/main/scala/millfork/env/Thing.scala
vendored
4
src/main/scala/millfork/env/Thing.scala
vendored
@ -109,10 +109,6 @@ case class Label(name: String) extends ThingInMemory {
|
||||
|
||||
sealed trait Variable extends TypedThing with VariableLikeThing
|
||||
|
||||
case class BlackHole(typ: Type) extends Variable {
|
||||
override def name = "<black hole>"
|
||||
}
|
||||
|
||||
sealed trait VariableInMemory extends Variable with ThingInMemory with IndexableThing {
|
||||
def zeropage: Boolean
|
||||
|
||||
|
@ -168,10 +168,6 @@ case class Assignment(destination: LhsExpression, source: Expression) extends Ex
|
||||
override def getAllExpressions: List[Expression] = List(destination, source)
|
||||
}
|
||||
|
||||
case class LabelStatement(label: Label) extends ExecutableStatement {
|
||||
override def getAllExpressions: List[Expression] = Nil
|
||||
}
|
||||
|
||||
case class AssemblyStatement(opcode: Opcode.Value, addrMode: AddrMode.Value, expression: Expression, elidable: Boolean) extends ExecutableStatement {
|
||||
override def getAllExpressions: List[Expression] = List(expression)
|
||||
}
|
||||
@ -196,10 +192,6 @@ case class DoWhileStatement(body: List[ExecutableStatement], increment: List[Exe
|
||||
override def getAllExpressions: List[Expression] = condition :: body.flatMap(_.getAllExpressions)
|
||||
}
|
||||
|
||||
case class BlockStatement(body: List[ExecutableStatement]) extends ExecutableStatement {
|
||||
override def getAllExpressions: List[Expression] = body.flatMap(_.getAllExpressions)
|
||||
}
|
||||
|
||||
case class BreakStatement(label: String) extends ExecutableStatement {
|
||||
override def getAllExpressions: List[Expression] = Nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user