mirror of
https://github.com/irmen/prog8.git
synced 2025-02-27 03:29:22 +00:00
label name from memory() no longer interned as string var
This commit is contained in:
parent
e5d7316e5d
commit
41b1c80492
@ -451,8 +451,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
||||
private fun funcMemory(fcall: IFunctionCall, discardResult: Boolean, resultToStack: Boolean, resultRegister: RegisterOrPair?) {
|
||||
if(discardResult || fcall !is FunctionCallExpression)
|
||||
throw AssemblyError("should not discard result of memory allocation at $fcall")
|
||||
val nameRef = fcall.args[0] as IdentifierReference
|
||||
val name = (nameRef.targetVarDecl(program)!!.value as StringLiteralValue).value
|
||||
val name = (fcall.args[0] as StringLiteralValue).value
|
||||
require(name.all { it.isLetterOrDigit() || it=='_' }) {"memory name should be a valid symbol name"}
|
||||
val size = (fcall.args[1] as NumericLiteralValue).number.toUInt()
|
||||
val align = (fcall.args[2] as NumericLiteralValue).number.toUInt()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package prog8.compiler.astprocessing
|
||||
|
||||
import prog8.ast.IFunctionCall
|
||||
import prog8.ast.Node
|
||||
import prog8.ast.Program
|
||||
import prog8.ast.base.DataType
|
||||
@ -20,6 +21,14 @@ internal class LiteralsToAutoVars(private val program: Program) : AstWalker() {
|
||||
&& string.parent !is WhenChoice
|
||||
&& (string.parent !is ContainmentCheck || string.value.length>ContainmentCheck.max_inlined_string_length)) {
|
||||
// replace the literal string by an identifier reference to the interned string
|
||||
|
||||
val parentFunc = (string.parent as? IFunctionCall)?.target
|
||||
if(parentFunc!=null) {
|
||||
if(parentFunc.nameInSource.size==1 && parentFunc.nameInSource[0]=="memory") {
|
||||
// memory() builtin function just uses the string as a label name
|
||||
return noModifications
|
||||
}
|
||||
}
|
||||
val scopedName = program.internString(string)
|
||||
val identifier = IdentifierReference(scopedName, string.position)
|
||||
return listOf(IAstModification.ReplaceNode(string, identifier, parent))
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- get rid of the interned string literals from memory() calls.
|
||||
- (newvaralloc) UnusedCodeRemover after(decl: VarDecl): fix that vars defined in a library can also safely be removed if unused. Currently this breaks programs such as textelite (due to diskio.save().end_address ?)
|
||||
- check that retval_interm_* are not in the varallocation if they're not used
|
||||
- make it so that subroutine parameters as variables can again be allocated in ZP, if there's still space
|
||||
|
@ -6,7 +6,7 @@ main {
|
||||
ubyte @zp mainglobal1=10
|
||||
float @shared fl1 = floats.TWOPI
|
||||
|
||||
uword @shared m1 = memory("eee", 200, 0)
|
||||
uword @shared m1 = memory("ee", 200, 0)
|
||||
|
||||
uword [2] nullwords
|
||||
ubyte [2] nullbytes
|
||||
|
Loading…
x
Reference in New Issue
Block a user