got rid of PtScopeVarsDecls

This commit is contained in:
Irmen de Jong 2023-01-29 13:37:02 +01:00
parent 07d5fafe2e
commit e31e5b2477
3 changed files with 19 additions and 32 deletions

View File

@ -317,10 +317,9 @@ class AsmGen(
is PtWhen -> translate(stmt)
is PtIncludeBinary -> TODO()
is PtBreakpoint -> TODO()
is PtVariable -> { /* do nothing; variables are handled elsewhere */ }
is PtScopeVarsDecls -> { /* do nothing; variables are handled elsewhere */ } // TODO translate PtScopeVarsDecls ? or ignore?
is PtVariable, is PtConstant, is PtMemMapped -> { /* do nothing; variables are handled elsewhere */ }
is PtBlock -> throw AssemblyError("block should have been handled elsewhere")
is PtNodeGroup -> TODO()
is PtNodeGroup -> stmt.children.forEach { translate(it) }
is PtNop -> {}
else -> throw AssemblyError("missing asm translation for $stmt")
}

View File

@ -39,22 +39,22 @@ internal fun PtRange.toConstantIntegerRange(): IntProgression? {
fun PtExpression.isSimple(): Boolean {
when(this) {
is PtAddressOf -> TODO()
is PtArray -> TODO()
is PtArrayIndexer -> TODO()
is PtBinaryExpression -> TODO()
is PtBuiltinFunctionCall -> TODO()
is PtContainmentCheck -> TODO()
is PtFunctionCall -> TODO()
is PtIdentifier -> TODO()
return when(this) {
is PtAddressOf -> true
is PtArray -> true
is PtArrayIndexer -> index is PtNumber || index is PtIdentifier
is PtBinaryExpression -> false
is PtBuiltinFunctionCall -> name in arrayOf("msb", "lsb", "peek", "peekw", "mkword", "set_carry", "set_irqd", "clear_carry", "clear_irqd")
is PtContainmentCheck -> false
is PtFunctionCall -> false
is PtIdentifier -> true
is PtMachineRegister -> TODO()
is PtMemoryByte -> TODO()
is PtNumber -> TODO()
is PtPrefix -> TODO()
is PtRange -> TODO()
is PtString -> TODO()
is PtTypeCast -> TODO()
is PtMemoryByte -> address is PtNumber || address is PtIdentifier
is PtNumber -> true
is PtPrefix -> value.isSimple()
is PtRange -> true
is PtString -> true
is PtTypeCast -> value.isSimple()
}
}
@ -78,19 +78,7 @@ internal fun PtProgram.lookup(name: String): PtNode {
require(remainder.isEmpty())
return node
}
is PtSub -> {
if(remainder.isEmpty())
return node
if(remainder.size==1) {
// look to see if there is a block of vardecls
val scopevars = node.children.firstOrNull() as? PtScopeVarsDecls
if(scopevars!=null)
return recurse(scopevars)
}
val childName = remainder.removeFirst()
return recurse(node.children.filterIsInstance<PtNamedNode>().single { it.name==childName})
}
is PtBlock, is PtScopeVarsDecls, is PtNamedNode -> {
is PtBlock, is PtSub, is PtNamedNode -> {
if(remainder.isEmpty())
return node
val childName = remainder.removeFirst()

View File

@ -10,10 +10,10 @@ import prog8.ast.expressions.*
import prog8.ast.statements.*
import prog8.code.SymbolTable
import prog8.code.ast.*
import prog8.code.core.BuiltinFunctions
import prog8.code.core.CompilationOptions
import prog8.code.core.DataType
import prog8.code.core.SourceCode
import prog8.compiler.BuiltinFunctions
import prog8.compiler.builtinFunctionReturnType
import java.io.File
import kotlin.io.path.Path