From 62a66d89c63004887e76926b06250f5c7632d5e7 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 11 Aug 2019 10:15:34 +0200 Subject: [PATCH] was not needed --- compiler/res/version.txt | 2 +- .../prog8/ast/expressions/AstExpressions.kt | 1 - .../src/prog8/ast/processing/AstChecker.kt | 2 - .../ast/processing/AstIdentifiersChecker.kt | 1 - .../VarInitValueAndAddressOfCreator.kt | 3 -- .../compiler/target/c64/codegen2/AsmGen2.kt | 8 ++-- examples/test.p8 | 41 ++++++++++++++----- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/compiler/res/version.txt b/compiler/res/version.txt index ec8bede26..9afa1ca4e 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -1.50 +1.51-dev diff --git a/compiler/src/prog8/ast/expressions/AstExpressions.kt b/compiler/src/prog8/ast/expressions/AstExpressions.kt index 891f90cd3..e453cd840 100644 --- a/compiler/src/prog8/ast/expressions/AstExpressions.kt +++ b/compiler/src/prog8/ast/expressions/AstExpressions.kt @@ -240,7 +240,6 @@ data class AddressOf(var identifier: IdentifierReference, override val position: identifier.parent=this } - var scopedname: String? = null // will be set in a later state by the compiler // TODO get rid of this?? override fun constValue(program: Program): NumericLiteralValue? = null override fun referencesIdentifiers(vararg name: String) = false override fun inferType(program: Program) = DataType.UWORD diff --git a/compiler/src/prog8/ast/processing/AstChecker.kt b/compiler/src/prog8/ast/processing/AstChecker.kt index 6346d1234..103e1e939 100644 --- a/compiler/src/prog8/ast/processing/AstChecker.kt +++ b/compiler/src/prog8/ast/processing/AstChecker.kt @@ -442,8 +442,6 @@ internal class AstChecker(private val program: Program, if(variable.datatype !in ArrayDatatypes && variable.datatype !in StringDatatypes && variable.datatype!=DataType.STRUCT) checkResult.add(ExpressionError("invalid pointer-of operand type", addressOf.position)) } - if(addressOf.scopedname==null) - throw FatalAstException("the scopedname of AddressOf should have been set by now $addressOf") super.visit(addressOf) } diff --git a/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt b/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt index c20ab9d9d..55cfdf066 100644 --- a/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt @@ -316,7 +316,6 @@ internal class AstIdentifiersChecker(private val program: Program) : IAstModifyi override fun visit(addressOf: AddressOf): Expression { // register the scoped name of the referenced identifier val variable= addressOf.identifier.targetVarDecl(program.namespace) ?: return addressOf - addressOf.scopedname = variable.scopedname return super.visit(addressOf) } diff --git a/compiler/src/prog8/ast/processing/VarInitValueAndAddressOfCreator.kt b/compiler/src/prog8/ast/processing/VarInitValueAndAddressOfCreator.kt index c67d45875..653e33a9f 100644 --- a/compiler/src/prog8/ast/processing/VarInitValueAndAddressOfCreator.kt +++ b/compiler/src/prog8/ast/processing/VarInitValueAndAddressOfCreator.kt @@ -114,7 +114,6 @@ internal class VarInitValueAndAddressOfCreator(private val program: Program): IA val variable = idref.targetVarDecl(program.namespace) if(variable!=null && (variable.datatype in StringDatatypes || variable.datatype in ArrayDatatypes)) { val pointerExpr = AddressOf(idref, idref.position) - pointerExpr.scopedname = parent.makeScopedName(idref.nameInSource.single()) pointerExpr.linkParents(arglist[argparam.first.index].parent) arglist[argparam.first.index] = pointerExpr } @@ -127,7 +126,6 @@ internal class VarInitValueAndAddressOfCreator(private val program: Program): IA // replace the argument with &autovar val autoHeapvarRef = IdentifierReference(listOf(variable.name), strvalue.position) val pointerExpr = AddressOf(autoHeapvarRef, strvalue.position) - pointerExpr.scopedname = parent.makeScopedName(variable.name) pointerExpr.linkParents(arglist[argparam.first.index].parent) arglist[argparam.first.index] = pointerExpr } @@ -145,7 +143,6 @@ internal class VarInitValueAndAddressOfCreator(private val program: Program): IA throw CompilerException("pass-by-reference parameter isn't an identifier? $argvalue") val addrOf = AddressOf(argvalue, argvalue.position) args[arg.first.index] = addrOf - addrOf.scopedname = parent.makeScopedName(argvalue.nameInSource.single()) addrOf.linkParents(parent) } } diff --git a/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt b/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt index 4cf3c2766..792ddd244 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt @@ -1673,8 +1673,7 @@ $endLabel""") } is AddressOf -> { val identifier = (assign.value as AddressOf).identifier - val scopedname = (assign.value as AddressOf).scopedname!! - assignFromAddressOf(assign.target, identifier, scopedname) + assignFromAddressOf(assign.target, identifier) } is DirectMemoryRead -> { val read = (assign.value as DirectMemoryRead) @@ -2235,7 +2234,7 @@ $endLabel""") } } - private fun assignFromAddressOf(target: AssignTarget, name: IdentifierReference, scopedname: String) { + private fun assignFromAddressOf(target: AssignTarget, name: IdentifierReference) { val targetIdent = target.identifier val targetArrayIdx = target.arrayindexed val struct = name.memberOfStruct(program.namespace) @@ -2248,8 +2247,9 @@ $endLabel""") val firstVar = name.definingScope().lookup(firstVarName, name) as VarDecl firstVar.name } else { - fixNameSymbols(scopedname) + fixNameSymbols(name.nameInSource.joinToString (".")) } + when { targetIdent!=null -> { val targetName = asmIdentifierName(targetIdent) diff --git a/examples/test.p8 b/examples/test.p8 index 9790c8f10..b208e9e01 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -3,19 +3,38 @@ main { + str title="bla" + struct Color { + ubyte red + ubyte green + ubyte blue + } + sub start() { + str subtitle = "basdf" + Color rgb - for ubyte ax in 0 to 255 { - word wcosa = cos8(ax) as word - word wsina = sin8(ax) as word + derp.dop() - c64scr.print_ub(ax) - c64.CHROUT(':') - c64.CHROUT(' ') - c64scr.print_w(wcosa) - c64.CHROUT(',') - c64scr.print_w(wsina) - c64.CHROUT('\n') - } + uword zz = &title + zz=&main.title + zz=&subtitle + zz=&main.start.subtitle + +; uword addr = &derp.dop.name ; @todo strange error "pointer-of operand must be the name of a heap variable" +; c64scr.print(&derp.dop.name) + + zz=&rgb + } +} + + +derp { + + sub dop() { + ubyte zzz=33 + str name="irmen" + + A=54 } }