mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
remove no longer needed asmSymbol scoping prefixing, now asmSymbolName are identical to asmVarName
This commit is contained in:
parent
f965804e6d
commit
e773be2f58
@ -617,30 +617,6 @@ class AsmGen(private val program: Program,
|
|||||||
return newName
|
return newName
|
||||||
}
|
}
|
||||||
|
|
||||||
fun asmSymbolName(identifier: IdentifierReference): String {
|
|
||||||
fun internalName(): String {
|
|
||||||
if (identifier.nameInSource.size == 2 && identifier.nameInSource[0] == "prog8_slabs")
|
|
||||||
return identifier.nameInSource.joinToString(".")
|
|
||||||
|
|
||||||
val tgt2 = identifier.targetStatement(program)
|
|
||||||
if (tgt2 == null && (identifier.nameInSource[0].startsWith("prog8")))
|
|
||||||
return identifier.nameInSource.joinToString(".")
|
|
||||||
|
|
||||||
val target = identifier.targetStatement(program)!!
|
|
||||||
val targetScope = target.definingSubroutine
|
|
||||||
val identScope = identifier.definingSubroutine
|
|
||||||
return if (targetScope !== identScope)
|
|
||||||
fixNameSymbols((target as INamedStatement).scopedName.joinToString("."))
|
|
||||||
else
|
|
||||||
fixNameSymbols(identifier.nameInSource.joinToString("."))
|
|
||||||
}
|
|
||||||
|
|
||||||
return fixNameSymbols(internalName())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun asmVariableName(identifier: IdentifierReference) =
|
|
||||||
fixNameSymbols(identifier.nameInSource.joinToString("."))
|
|
||||||
|
|
||||||
fun asmSymbolName(regs: RegisterOrPair): String =
|
fun asmSymbolName(regs: RegisterOrPair): String =
|
||||||
if (regs in Cx16VirtualRegisters)
|
if (regs in Cx16VirtualRegisters)
|
||||||
"cx16." + regs.toString().lowercase()
|
"cx16." + regs.toString().lowercase()
|
||||||
@ -651,6 +627,8 @@ class AsmGen(private val program: Program,
|
|||||||
fun asmVariableName(name: String) = fixNameSymbols(name)
|
fun asmVariableName(name: String) = fixNameSymbols(name)
|
||||||
fun asmSymbolName(name: Iterable<String>) = fixNameSymbols(name.joinToString("."))
|
fun asmSymbolName(name: Iterable<String>) = fixNameSymbols(name.joinToString("."))
|
||||||
fun asmVariableName(name: Iterable<String>) = fixNameSymbols(name.joinToString("."))
|
fun asmVariableName(name: Iterable<String>) = fixNameSymbols(name.joinToString("."))
|
||||||
|
fun asmSymbolName(identifier: IdentifierReference) = asmSymbolName(identifier.nameInSource)
|
||||||
|
fun asmVariableName(identifier: IdentifierReference) = asmVariableName(identifier.nameInSource)
|
||||||
|
|
||||||
fun getTempVarName(dt: DataType): List<String> {
|
fun getTempVarName(dt: DataType): List<String> {
|
||||||
return when(dt) {
|
return when(dt) {
|
||||||
|
@ -95,7 +95,6 @@ class TestAsmGenSymbols: StringSpec({
|
|||||||
val asmgen = createTestAsmGen(program)
|
val asmgen = createTestAsmGen(program)
|
||||||
val sub = program.entrypoint
|
val sub = program.entrypoint
|
||||||
|
|
||||||
// local variable
|
|
||||||
val localvarIdent = sub.statements.asSequence().filterIsInstance<Assignment>().first { it.value is IdentifierReference }.value as IdentifierReference
|
val localvarIdent = sub.statements.asSequence().filterIsInstance<Assignment>().first { it.value is IdentifierReference }.value as IdentifierReference
|
||||||
asmgen.asmSymbolName(localvarIdent) shouldBe "localvar"
|
asmgen.asmSymbolName(localvarIdent) shouldBe "localvar"
|
||||||
asmgen.asmVariableName(localvarIdent) shouldBe "localvar"
|
asmgen.asmVariableName(localvarIdent) shouldBe "localvar"
|
||||||
@ -103,10 +102,8 @@ class TestAsmGenSymbols: StringSpec({
|
|||||||
asmgen.asmSymbolName(localvarIdentScoped) shouldBe "main.start.localvar"
|
asmgen.asmSymbolName(localvarIdentScoped) shouldBe "main.start.localvar"
|
||||||
asmgen.asmVariableName(localvarIdentScoped) shouldBe "main.start.localvar"
|
asmgen.asmVariableName(localvarIdentScoped) shouldBe "main.start.localvar"
|
||||||
|
|
||||||
// variable from outer scope (note that for Variables, no scoping prefix symbols are required,
|
|
||||||
// because they're not outputted as locally scoped symbols for the assembler
|
|
||||||
val scopedVarIdent = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("var_outside") }.value as AddressOf).identifier
|
val scopedVarIdent = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("var_outside") }.value as AddressOf).identifier
|
||||||
asmgen.asmSymbolName(scopedVarIdent) shouldBe "main.var_outside"
|
asmgen.asmSymbolName(scopedVarIdent) shouldBe "var_outside"
|
||||||
asmgen.asmVariableName(scopedVarIdent) shouldBe "var_outside"
|
asmgen.asmVariableName(scopedVarIdent) shouldBe "var_outside"
|
||||||
val scopedVarIdentScoped = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("main", "var_outside") }.value as AddressOf).identifier
|
val scopedVarIdentScoped = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("main", "var_outside") }.value as AddressOf).identifier
|
||||||
asmgen.asmSymbolName(scopedVarIdentScoped) shouldBe "main.var_outside"
|
asmgen.asmSymbolName(scopedVarIdentScoped) shouldBe "main.var_outside"
|
||||||
@ -118,7 +115,6 @@ class TestAsmGenSymbols: StringSpec({
|
|||||||
val asmgen = createTestAsmGen(program)
|
val asmgen = createTestAsmGen(program)
|
||||||
val sub = program.entrypoint
|
val sub = program.entrypoint
|
||||||
|
|
||||||
// local label
|
|
||||||
val localLabelIdent = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("locallabel") }.value as AddressOf).identifier
|
val localLabelIdent = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("locallabel") }.value as AddressOf).identifier
|
||||||
asmgen.asmSymbolName(localLabelIdent) shouldBe "locallabel"
|
asmgen.asmSymbolName(localLabelIdent) shouldBe "locallabel"
|
||||||
asmgen.asmVariableName(localLabelIdent) shouldBe "locallabel"
|
asmgen.asmVariableName(localLabelIdent) shouldBe "locallabel"
|
||||||
@ -126,9 +122,8 @@ class TestAsmGenSymbols: StringSpec({
|
|||||||
asmgen.asmSymbolName(localLabelIdentScoped) shouldBe "main.start.locallabel"
|
asmgen.asmSymbolName(localLabelIdentScoped) shouldBe "main.start.locallabel"
|
||||||
asmgen.asmVariableName(localLabelIdentScoped) shouldBe "main.start.locallabel"
|
asmgen.asmVariableName(localLabelIdentScoped) shouldBe "main.start.locallabel"
|
||||||
|
|
||||||
// label from outer scope needs sope prefixes because it is outputted as a locally scoped symbol for the assembler
|
|
||||||
val scopedLabelIdent = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("label_outside") }.value as AddressOf).identifier
|
val scopedLabelIdent = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("label_outside") }.value as AddressOf).identifier
|
||||||
asmgen.asmSymbolName(scopedLabelIdent) shouldBe "main.label_outside"
|
asmgen.asmSymbolName(scopedLabelIdent) shouldBe "label_outside"
|
||||||
asmgen.asmVariableName(scopedLabelIdent) shouldBe "label_outside"
|
asmgen.asmVariableName(scopedLabelIdent) shouldBe "label_outside"
|
||||||
val scopedLabelIdentScoped = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("main","label_outside") }.value as AddressOf).identifier
|
val scopedLabelIdentScoped = (sub.statements.asSequence().filterIsInstance<Assignment>().first { (it.value as? AddressOf)?.identifier?.nameInSource==listOf("main","label_outside") }.value as AddressOf).identifier
|
||||||
asmgen.asmSymbolName(scopedLabelIdentScoped) shouldBe "main.label_outside"
|
asmgen.asmSymbolName(scopedLabelIdentScoped) shouldBe "main.label_outside"
|
||||||
|
@ -6,7 +6,6 @@ For next release
|
|||||||
- Fix: don't report as recursion if code assigns address of its own subroutine to something, rather than calling it
|
- Fix: don't report as recursion if code assigns address of its own subroutine to something, rather than calling it
|
||||||
- nameInAssemblyCode() should search smarter (only labels in column 0? only full words, not part of a larger word? use regex? )
|
- nameInAssemblyCode() should search smarter (only labels in column 0? only full words, not part of a larger word? use regex? )
|
||||||
|
|
||||||
|
|
||||||
Need help with
|
Need help with
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
- c128 target: various machine specific things (free zp locations, how banking works, getting the floating point routines working, ...)
|
- c128 target: various machine specific things (free zp locations, how banking works, getting the floating point routines working, ...)
|
||||||
@ -22,12 +21,11 @@ Blocked by an official Commander-x16 r39 release
|
|||||||
|
|
||||||
Future Things and Ideas
|
Future Things and Ideas
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
- remove support for old @"screencodes" string encoding syntax (parser+code+docs)
|
||||||
- allow "xxx" * constexpr (where constexpr is not a number literal, now gives expression error not same type)
|
- allow "xxx" * constexpr (where constexpr is not a number literal, now gives expression error not same type)
|
||||||
- can we promise a left-to-right function call argument evaluation? without sacrificing performance. note: C/C++ don't guarantee anything about this
|
- can we promise a left-to-right function call argument evaluation? without sacrificing performance. note: C/C++ don't guarantee anything about this
|
||||||
- unify FunctioncallExpression + FunctioncallStatement and PipeExpression + Pipe statement, may require moving Expression/Statement into interfaces instead of abstract base classes
|
- unify FunctioncallExpression + FunctioncallStatement and PipeExpression + Pipe statement, may require moving Expression/Statement into interfaces instead of abstract base classes
|
||||||
- for the pipe operator: recognise a placeholder (``?`` or ``%`` or ``_``) in a non-unary function call to allow non-unary functions in the chain; ``4 |> mkword(?, $44) |> print_uw``
|
- for the pipe operator: recognise a placeholder (``?`` or ``%`` or ``_``) in a non-unary function call to allow non-unary functions in the chain; ``4 |> mkword(?, $44) |> print_uw``
|
||||||
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as ``v_``
|
|
||||||
then we can get rid of the instruction lists in the machinedefinitions as well?
|
|
||||||
- make it possible to inline non-asmsub routines that just contain a single statement (return, functioncall, assignment)
|
- make it possible to inline non-asmsub routines that just contain a single statement (return, functioncall, assignment)
|
||||||
but this requires all identifiers in the inlined expression to be changed to fully scoped names
|
but this requires all identifiers in the inlined expression to be changed to fully scoped names
|
||||||
- simplifyConditionalExpression() should not split expression if it still results in stack-based evaluation
|
- simplifyConditionalExpression() should not split expression if it still results in stack-based evaluation
|
||||||
@ -36,6 +34,8 @@ Future Things and Ideas
|
|||||||
- use more of Result<> and Either<> to handle errors/ nulls better?
|
- use more of Result<> and Either<> to handle errors/ nulls better?
|
||||||
- rethink the whole "isAugmentable" business. Because the way this is determined, should always also be exactly mirrorred in the AugmentableAssignmentAsmGen or you'll get a crash at code gen time.
|
- rethink the whole "isAugmentable" business. Because the way this is determined, should always also be exactly mirrorred in the AugmentableAssignmentAsmGen or you'll get a crash at code gen time.
|
||||||
- can we get rid of pieces of asmgen.AssignmentAsmGen by just reusing the AugmentableAssignment ? generated code should not suffer
|
- can we get rid of pieces of asmgen.AssignmentAsmGen by just reusing the AugmentableAssignment ? generated code should not suffer
|
||||||
|
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as ``p8v_``? Or not worth it (most 3 letter opcodes as variables are nonsensical anyway)
|
||||||
|
then we can get rid of the instruction lists in the machinedefinitions as well?
|
||||||
- c64: make the graphics.BITMAP_ADDRESS configurable (VIC banking)
|
- c64: make the graphics.BITMAP_ADDRESS configurable (VIC banking)
|
||||||
- optimize several inner loops in gfx2 even further?
|
- optimize several inner loops in gfx2 even further?
|
||||||
- add modes 2 and 3 to gfx2 (lowres 4 color and 16 color)?
|
- add modes 2 and 3 to gfx2 (lowres 4 color and 16 color)?
|
||||||
|
Loading…
Reference in New Issue
Block a user