mirror of
https://github.com/irmen/prog8.git
synced 2025-06-15 02:23:36 +00:00
23 lines
735 B
Kotlin
23 lines
735 B
Kotlin
package prog8.ast.processing
|
|
|
|
import prog8.ast.INameScope
|
|
import prog8.ast.Node
|
|
import prog8.ast.statements.Directive
|
|
|
|
|
|
internal class ImportedModuleDirectiveRemover: AstWalker() {
|
|
/**
|
|
* Most global directives don't apply for imported modules, so remove them
|
|
*/
|
|
|
|
private val moduleLevelDirectives = listOf("%output", "%launcher", "%zeropage", "%zpreserved", "%address")
|
|
private val noModifications = emptyList<IAstModification>()
|
|
|
|
override fun before(directive: Directive, parent: Node): Iterable<IAstModification> {
|
|
if(directive.directive in moduleLevelDirectives) {
|
|
return listOf(IAstModification.Remove(directive, parent as INameScope))
|
|
}
|
|
return noModifications
|
|
}
|
|
}
|