mirror of
https://github.com/irmen/prog8.git
synced 2024-09-08 10:55:08 +00:00
relaxed symbol shadowing
This commit is contained in:
parent
cc1fc869cf
commit
f29ec3b4e1
@ -1063,7 +1063,7 @@ _mod lda $ffff ; modified
|
|||||||
sub setcc (ubyte column, ubyte row, ubyte char, ubyte color) {
|
sub setcc (ubyte column, ubyte row, ubyte char, ubyte color) {
|
||||||
; ---- set char+color at the given position on the screen
|
; ---- set char+color at the given position on the screen
|
||||||
%asm {{
|
%asm {{
|
||||||
lda setcc_row
|
lda row
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
lda setchr._screenrows+1,y
|
lda setchr._screenrows+1,y
|
||||||
@ -1072,15 +1072,15 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte color) {
|
|||||||
sta _colormod+2
|
sta _colormod+2
|
||||||
lda setchr._screenrows,y
|
lda setchr._screenrows,y
|
||||||
clc
|
clc
|
||||||
adc setcc_column
|
adc column
|
||||||
sta _charmod+1
|
sta _charmod+1
|
||||||
sta _colormod+1
|
sta _colormod+1
|
||||||
bcc +
|
bcc +
|
||||||
inc _charmod+2
|
inc _charmod+2
|
||||||
inc _colormod+2
|
inc _colormod+2
|
||||||
+ lda setcc_char
|
+ lda char
|
||||||
_charmod sta $ffff ; modified
|
_charmod sta $ffff ; modified
|
||||||
lda setcc_color
|
lda color
|
||||||
_colormod sta $ffff ; modified
|
_colormod sta $ffff ; modified
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
|
@ -67,8 +67,6 @@ internal class AstIdentifiersChecker(private val program: Program) : IAstModifyi
|
|||||||
// the builtin functions can't be redefined
|
// the builtin functions can't be redefined
|
||||||
checkResult.add(NameError("builtin function cannot be redefined", decl.position))
|
checkResult.add(NameError("builtin function cannot be redefined", decl.position))
|
||||||
|
|
||||||
if(decl.name in AssemblyProgram.reservedNames)
|
|
||||||
checkResult.add(NameError("can't use a symbol name reserved by the assembler program", decl.position))
|
|
||||||
if(decl.name in AssemblyProgram.opcodeNames)
|
if(decl.name in AssemblyProgram.opcodeNames)
|
||||||
checkResult.add(NameError("can't use a cpu opcode name as a symbol", decl.position))
|
checkResult.add(NameError("can't use a cpu opcode name as a symbol", decl.position))
|
||||||
|
|
||||||
@ -106,7 +104,9 @@ internal class AstIdentifiersChecker(private val program: Program) : IAstModifyi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visit(subroutine: Subroutine): Statement {
|
override fun visit(subroutine: Subroutine): Statement {
|
||||||
if(subroutine.name in BuiltinFunctions) {
|
if(subroutine.name in AssemblyProgram.opcodeNames) {
|
||||||
|
checkResult.add(NameError("can't use a cpu opcode name as a symbol", subroutine.position))
|
||||||
|
} else if(subroutine.name in BuiltinFunctions) {
|
||||||
// the builtin functions can't be redefined
|
// the builtin functions can't be redefined
|
||||||
checkResult.add(NameError("builtin function cannot be redefined", subroutine.position))
|
checkResult.add(NameError("builtin function cannot be redefined", subroutine.position))
|
||||||
} else {
|
} else {
|
||||||
@ -162,6 +162,9 @@ internal class AstIdentifiersChecker(private val program: Program) : IAstModifyi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visit(label: Label): Statement {
|
override fun visit(label: Label): Statement {
|
||||||
|
if(label.name in AssemblyProgram.opcodeNames)
|
||||||
|
checkResult.add(NameError("can't use a cpu opcode name as a symbol", label.position))
|
||||||
|
|
||||||
if(label.name in BuiltinFunctions) {
|
if(label.name in BuiltinFunctions) {
|
||||||
// the builtin functions can't be redefined
|
// the builtin functions can't be redefined
|
||||||
checkResult.add(NameError("builtin function cannot be redefined", label.position))
|
checkResult.add(NameError("builtin function cannot be redefined", label.position))
|
||||||
|
@ -10,12 +10,7 @@ class AssemblyProgram(val name: String) {
|
|||||||
private val viceMonListFile = "$name.vice-mon-list"
|
private val viceMonListFile = "$name.vice-mon-list"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// reserved by the 64tass assembler (on top of prog8"s own reserved names)
|
// 6502 opcodes (including aliases and illegal opcodes), these cannot be used as variable or label names
|
||||||
val reservedNames = setOf("bits", "bool", "bytes", "code", "dict", "gap", "int", "list", "tuple", "type",
|
|
||||||
"trunc", " frac", "cbrt", "log10", "log", "exp", "pow", "asin", "sinh", "acos", "cosh", "tanh", "hypot",
|
|
||||||
"atan2", "sign", "binary", "format", "random", "range", "repr", "size", "sort")
|
|
||||||
|
|
||||||
// 6502 opcodes (including aliases and illegal opcodes), these cannot be used as variable names either
|
|
||||||
val opcodeNames = setOf("adc", "ahx", "alr", "anc", "and", "ane", "arr", "asl", "asr", "axs", "bcc", "bcs",
|
val opcodeNames = setOf("adc", "ahx", "alr", "anc", "and", "ane", "arr", "asl", "asr", "axs", "bcc", "bcs",
|
||||||
"beq", "bge", "bit", "blt", "bmi", "bne", "bpl", "brk", "bvc", "bvs", "clc",
|
"beq", "bge", "bit", "blt", "bmi", "bne", "bpl", "brk", "bvc", "bvs", "clc",
|
||||||
"cld", "cli", "clv", "cmp", "cpx", "cpy", "dcm", "dcp", "dec", "dex", "dey",
|
"cld", "cli", "clv", "cmp", "cpx", "cpy", "dcm", "dcp", "dec", "dex", "dey",
|
||||||
@ -30,8 +25,9 @@ class AssemblyProgram(val name: String) {
|
|||||||
|
|
||||||
fun assemble(options: CompilationOptions) {
|
fun assemble(options: CompilationOptions) {
|
||||||
// add "-Wlong-branch" to see warnings about conversion of branch instructions to jumps
|
// add "-Wlong-branch" to see warnings about conversion of branch instructions to jumps
|
||||||
val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch", "-Wall", "-Wno-strict-bool",
|
val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch",
|
||||||
"-Werror", "-Wno-error=long-branch", "--dump-labels", "--vice-labels", "-l", viceMonListFile, "--no-monitor")
|
"-Wall", "-Wno-strict-bool", "-Wno-shadow", "-Werror", "-Wno-error=long-branch",
|
||||||
|
"--dump-labels", "--vice-labels", "-l", viceMonListFile, "--no-monitor")
|
||||||
|
|
||||||
val outFile = when(options.output) {
|
val outFile = when(options.output) {
|
||||||
OutputType.PRG -> {
|
OutputType.PRG -> {
|
||||||
|
@ -6,7 +6,27 @@
|
|||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
memset(c64.Screen, 40, 1)
|
|
||||||
memset(c64.Screen+40, 80, 2)
|
ubyte x=3
|
||||||
|
ubyte y=2
|
||||||
|
ubyte a=1
|
||||||
|
ubyte s=0
|
||||||
|
float repr=4.4
|
||||||
|
;memset(c64.Screen, 40, 1)
|
||||||
|
;memset(c64.Screen+40, 80, 2)
|
||||||
|
A=x
|
||||||
|
A=y
|
||||||
|
Y=a
|
||||||
|
A=s
|
||||||
|
}
|
||||||
|
|
||||||
|
sub foo() {
|
||||||
|
|
||||||
|
x:
|
||||||
|
s:
|
||||||
|
y:
|
||||||
|
a:
|
||||||
|
A=3
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user