mirror of
https://github.com/irmen/prog8.git
synced 2025-02-27 18:29:00 +00:00
refactor interface
This commit is contained in:
parent
64032d766e
commit
dcab0d1e98
@ -48,15 +48,32 @@ data class Position(val file: String, val line: Int, val startCol: Int, val endC
|
||||
|
||||
|
||||
interface IAstProcessor {
|
||||
fun process(module: Module)
|
||||
fun process(expr: PrefixExpression): IExpression
|
||||
fun process(expr: BinaryExpression): IExpression
|
||||
fun process(directive: Directive): IStatement
|
||||
fun process(block: Block): IStatement
|
||||
fun process(decl: VarDecl): IStatement
|
||||
fun process(subroutine: Subroutine): IStatement
|
||||
fun process(jump: Jump): IStatement
|
||||
fun process(functionCall: FunctionCall): IExpression
|
||||
fun process(module: Module) {
|
||||
}
|
||||
fun process(expr: PrefixExpression): IExpression {
|
||||
return expr
|
||||
}
|
||||
fun process(expr: BinaryExpression): IExpression {
|
||||
return expr
|
||||
}
|
||||
fun process(directive: Directive): IStatement {
|
||||
return directive
|
||||
}
|
||||
fun process(block: Block): IStatement {
|
||||
return block
|
||||
}
|
||||
fun process(decl: VarDecl): IStatement {
|
||||
return decl
|
||||
}
|
||||
fun process(subroutine: Subroutine): IStatement {
|
||||
return subroutine
|
||||
}
|
||||
fun process(jump: Jump): IStatement {
|
||||
return jump
|
||||
}
|
||||
fun process(functionCall: FunctionCall): IExpression {
|
||||
return functionCall
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -623,7 +640,7 @@ private fun il65Parser.UnconditionaljumpContext.toAst(withPosition: Boolean): IS
|
||||
|
||||
|
||||
private fun il65Parser.LabeldefContext.toAst(withPosition: Boolean): IStatement {
|
||||
val lbl = Label(text)
|
||||
val lbl = Label(this.children[0].text)
|
||||
lbl.position = toPosition(withPosition)
|
||||
return lbl
|
||||
}
|
||||
|
@ -28,14 +28,6 @@ class AstChecker : IAstProcessor {
|
||||
module.lines.forEach { it.process(this) }
|
||||
}
|
||||
|
||||
override fun process(expr: PrefixExpression): IExpression {
|
||||
return expr
|
||||
}
|
||||
|
||||
override fun process(expr: BinaryExpression): IExpression {
|
||||
return expr
|
||||
}
|
||||
|
||||
override fun process(functionCall: FunctionCall): IExpression {
|
||||
functionCall.arglist.map{it.process(this)}
|
||||
return functionCall
|
||||
|
@ -44,11 +44,6 @@ class AstOptimizer : IAstProcessor {
|
||||
return functionCall
|
||||
}
|
||||
|
||||
override fun process(jump: Jump): IStatement {
|
||||
return jump
|
||||
}
|
||||
|
||||
|
||||
override fun process(decl: VarDecl): IStatement {
|
||||
decl.value = decl.value?.process(this)
|
||||
decl.arrayspec?.process(this)
|
||||
@ -126,10 +121,6 @@ class AstOptimizer : IAstProcessor {
|
||||
else -> expr
|
||||
}
|
||||
}
|
||||
|
||||
override fun process(directive: Directive): IStatement {
|
||||
return directive
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,37 +40,4 @@ class ImportedAstChecker : IAstProcessor {
|
||||
}
|
||||
module.lines = newLines
|
||||
}
|
||||
|
||||
override fun process(subroutine: Subroutine): IStatement {
|
||||
return subroutine
|
||||
}
|
||||
|
||||
override fun process(expr: PrefixExpression): IExpression {
|
||||
return expr
|
||||
}
|
||||
|
||||
override fun process(expr: BinaryExpression): IExpression {
|
||||
return expr
|
||||
}
|
||||
|
||||
override fun process(block: Block): IStatement {
|
||||
return block
|
||||
}
|
||||
|
||||
override fun process(decl: VarDecl): IStatement {
|
||||
return decl
|
||||
}
|
||||
|
||||
override fun process(directive: Directive): IStatement {
|
||||
return directive
|
||||
}
|
||||
|
||||
override fun process(functionCall: FunctionCall): IExpression {
|
||||
return functionCall
|
||||
}
|
||||
|
||||
override fun process(jump: Jump): IStatement {
|
||||
return jump
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user