From 5f2ecb8258c0b386b2b144987f856be492137730 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Sat, 17 Mar 2018 18:12:31 +0100 Subject: [PATCH] Code cleanup --- src/main/scala/millfork/compiler/MacroExpander.scala | 1 - src/main/scala/millfork/compiler/StatementCompiler.scala | 2 -- src/main/scala/millfork/env/Environment.scala | 3 ++- src/main/scala/millfork/env/Thing.scala | 4 ---- src/main/scala/millfork/node/Node.scala | 8 -------- 5 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/scala/millfork/compiler/MacroExpander.scala b/src/main/scala/millfork/compiler/MacroExpander.scala index cd5623d4..bda462f3 100644 --- a/src/main/scala/millfork/compiler/MacroExpander.scala +++ b/src/main/scala/millfork/compiler/MacroExpander.scala @@ -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 _ => diff --git a/src/main/scala/millfork/compiler/StatementCompiler.scala b/src/main/scala/millfork/compiler/StatementCompiler.scala index f31b502f..fdfa8578 100644 --- a/src/main/scala/millfork/compiler/StatementCompiler.scala +++ b/src/main/scala/millfork/compiler/StatementCompiler.scala @@ -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 diff --git a/src/main/scala/millfork/env/Environment.scala b/src/main/scala/millfork/env/Environment.scala index fa96b36b..b900c291 100644 --- a/src/main/scala/millfork/env/Environment.scala +++ b/src/main/scala/millfork/env/Environment.scala @@ -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) diff --git a/src/main/scala/millfork/env/Thing.scala b/src/main/scala/millfork/env/Thing.scala index d8b675d5..b63e61d6 100644 --- a/src/main/scala/millfork/env/Thing.scala +++ b/src/main/scala/millfork/env/Thing.scala @@ -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 = "" -} - sealed trait VariableInMemory extends Variable with ThingInMemory with IndexableThing { def zeropage: Boolean diff --git a/src/main/scala/millfork/node/Node.scala b/src/main/scala/millfork/node/Node.scala index 0dccd979..565acb05 100644 --- a/src/main/scala/millfork/node/Node.scala +++ b/src/main/scala/millfork/node/Node.scala @@ -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 }