mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 22:30:46 +00:00
added warnshadow cli option to enable assembler warnings about symbol shadowing
This commit is contained in:
parent
72768e7fad
commit
ff35ba3696
@ -13,6 +13,7 @@ class CompilationOptions(val output: OutputType,
|
|||||||
val compTarget: ICompilationTarget,
|
val compTarget: ICompilationTarget,
|
||||||
// these are set later, based on command line arguments or options in the source code:
|
// these are set later, based on command line arguments or options in the source code:
|
||||||
var loadAddress: UInt,
|
var loadAddress: UInt,
|
||||||
|
var warnSymbolShadowing: Boolean = false,
|
||||||
var optimize: Boolean = false,
|
var optimize: Boolean = false,
|
||||||
var asmQuiet: Boolean = false,
|
var asmQuiet: Boolean = false,
|
||||||
var asmListfile: Boolean = false,
|
var asmListfile: Boolean = false,
|
||||||
|
@ -31,6 +31,11 @@ internal class AssemblyProgram(
|
|||||||
"--dump-labels", "--vice-labels", "--labels=$viceMonListFile", "--no-monitor"
|
"--dump-labels", "--vice-labels", "--labels=$viceMonListFile", "--no-monitor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(options.warnSymbolShadowing)
|
||||||
|
command.add("-Wshadow")
|
||||||
|
else
|
||||||
|
command.add("-Wno-shadow")
|
||||||
|
|
||||||
if(options.asmQuiet)
|
if(options.asmQuiet)
|
||||||
command.add("--quiet")
|
command.add("--quiet")
|
||||||
|
|
||||||
@ -59,10 +64,15 @@ internal class AssemblyProgram(
|
|||||||
|
|
||||||
// TODO are these options okay for atari?
|
// TODO are these options okay for atari?
|
||||||
val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch",
|
val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch",
|
||||||
"-Wall", "-Wno-strict-bool", "-Wno-shadow", // "-Werror",
|
"-Wall", // "-Werror", "-Wno-strict-bool"
|
||||||
"--no-monitor"
|
"--no-monitor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(options.warnSymbolShadowing)
|
||||||
|
command.add("-Wshadow")
|
||||||
|
else
|
||||||
|
command.add("-Wno-shadow")
|
||||||
|
|
||||||
if(options.asmQuiet)
|
if(options.asmQuiet)
|
||||||
command.add("--quiet")
|
command.add("--quiet")
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
val dontOptimize by cli.option(ArgType.Boolean, fullName = "noopt", description = "don't perform any optimizations")
|
val dontOptimize by cli.option(ArgType.Boolean, fullName = "noopt", description = "don't perform any optimizations")
|
||||||
val outputDir by cli.option(ArgType.String, fullName = "out", description = "directory for output files instead of current directory").default(".")
|
val outputDir by cli.option(ArgType.String, fullName = "out", description = "directory for output files instead of current directory").default(".")
|
||||||
val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results")
|
val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results")
|
||||||
|
val warnSymbolShadowing by cli.option(ArgType.Boolean, fullName = "warnshadow", description="show assembler warnings about symbol shadowing")
|
||||||
val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator)
|
val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator)
|
||||||
val includeSourcelines by cli.option(ArgType.Boolean, fullName = "sourcelines", description = "include original Prog8 source lines in generated asm code")
|
val includeSourcelines by cli.option(ArgType.Boolean, fullName = "sourcelines", description = "include original Prog8 source lines in generated asm code")
|
||||||
val splitWordArrays by cli.option(ArgType.Boolean, fullName = "splitarrays", description = "treat all word arrays as tagged with @split to make them lsb/msb split in memory")
|
val splitWordArrays by cli.option(ArgType.Boolean, fullName = "splitarrays", description = "treat all word arrays as tagged with @split to make them lsb/msb split in memory")
|
||||||
@ -113,6 +114,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
filepath,
|
filepath,
|
||||||
dontOptimize != true,
|
dontOptimize != true,
|
||||||
dontWriteAssembly != true,
|
dontWriteAssembly != true,
|
||||||
|
warnSymbolShadowing == true,
|
||||||
quietAssembler == true,
|
quietAssembler == true,
|
||||||
asmListfile == true,
|
asmListfile == true,
|
||||||
includeSourcelines == true,
|
includeSourcelines == true,
|
||||||
@ -180,6 +182,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
filepath,
|
filepath,
|
||||||
dontOptimize != true,
|
dontOptimize != true,
|
||||||
dontWriteAssembly != true,
|
dontWriteAssembly != true,
|
||||||
|
warnSymbolShadowing == true,
|
||||||
quietAssembler == true,
|
quietAssembler == true,
|
||||||
asmListfile == true,
|
asmListfile == true,
|
||||||
includeSourcelines == true,
|
includeSourcelines == true,
|
||||||
|
@ -30,6 +30,7 @@ class CompilationResult(val compilerAst: Program, // deprecated, use codegenAs
|
|||||||
class CompilerArguments(val filepath: Path,
|
class CompilerArguments(val filepath: Path,
|
||||||
val optimize: Boolean,
|
val optimize: Boolean,
|
||||||
val writeAssembly: Boolean,
|
val writeAssembly: Boolean,
|
||||||
|
val warnSymbolShadowing: Boolean,
|
||||||
val quietAssembler: Boolean,
|
val quietAssembler: Boolean,
|
||||||
val asmListfile: Boolean,
|
val asmListfile: Boolean,
|
||||||
val includeSourcelines: Boolean,
|
val includeSourcelines: Boolean,
|
||||||
@ -67,6 +68,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
|||||||
compilationOptions = options
|
compilationOptions = options
|
||||||
|
|
||||||
with(compilationOptions) {
|
with(compilationOptions) {
|
||||||
|
warnSymbolShadowing = args.warnSymbolShadowing
|
||||||
optimize = args.optimize
|
optimize = args.optimize
|
||||||
asmQuiet = args.quietAssembler
|
asmQuiet = args.quietAssembler
|
||||||
asmListfile = args.asmListfile
|
asmListfile = args.asmListfile
|
||||||
|
@ -27,6 +27,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
|
|||||||
filepath,
|
filepath,
|
||||||
optimize,
|
optimize,
|
||||||
writeAssembly = true,
|
writeAssembly = true,
|
||||||
|
warnSymbolShadowing = false,
|
||||||
quietAssembler = true,
|
quietAssembler = true,
|
||||||
asmListfile = false,
|
asmListfile = false,
|
||||||
includeSourcelines = false,
|
includeSourcelines = false,
|
||||||
|
@ -44,6 +44,7 @@ class TestCompilerOptionSourcedirs: FunSpec({
|
|||||||
filepath = filePath,
|
filepath = filePath,
|
||||||
optimize = false,
|
optimize = false,
|
||||||
writeAssembly = true,
|
writeAssembly = true,
|
||||||
|
warnSymbolShadowing = false,
|
||||||
quietAssembler = true,
|
quietAssembler = true,
|
||||||
asmListfile = false,
|
asmListfile = false,
|
||||||
includeSourcelines = false,
|
includeSourcelines = false,
|
||||||
|
@ -24,6 +24,7 @@ internal fun compileFile(
|
|||||||
filepath,
|
filepath,
|
||||||
optimize,
|
optimize,
|
||||||
writeAssembly = writeAssembly,
|
writeAssembly = writeAssembly,
|
||||||
|
warnSymbolShadowing = false,
|
||||||
quietAssembler = true,
|
quietAssembler = true,
|
||||||
asmListfile = false,
|
asmListfile = false,
|
||||||
includeSourcelines = false,
|
includeSourcelines = false,
|
||||||
|
@ -151,6 +151,15 @@ One or more .p8 module files
|
|||||||
Note that it is possible to use the watch mode with multiple modules as well, but it will
|
Note that it is possible to use the watch mode with multiple modules as well, but it will
|
||||||
recompile everything in that list even if only one of the files got updated.
|
recompile everything in that list even if only one of the files got updated.
|
||||||
|
|
||||||
|
``-warnshadow``
|
||||||
|
Tells the assembler to issue warning messages about symbol shadowing.
|
||||||
|
These *can* be problematic, but usually aren't because prog8 has different scoping rules
|
||||||
|
than the assembler has.
|
||||||
|
You may want to watch out for shadowing of builtin names though. Especially 'a', 'x' and 'y'
|
||||||
|
as those are the cpu register names and if you shadow those, the assembler might
|
||||||
|
interpret certain instructions differently and produce unexpected opcodes (like LDA X getting
|
||||||
|
turned into TXA, or not, depending on the symbol 'x' being defined in your own assembly code or not)
|
||||||
|
|
||||||
``-quietasm``
|
``-quietasm``
|
||||||
Don't print assembler output results.
|
Don't print assembler output results.
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
- [on branch: shadowing-fixes] add shadowing warning to asm and fix shadowing errors
|
||||||
|
- prefix prog8 subroutines with p8s_ instead of p8_ to not let them clash with variables in the asm
|
||||||
|
|
||||||
- allow 'chained' array indexing for expressions: value = ptrarray[0][0]
|
- allow 'chained' array indexing for expressions: value = ptrarray[0][0]
|
||||||
- allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression
|
- allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression
|
||||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||||
- [on branch: shadowing-fixes] add shadowing warning to asm and fix shadowing errors
|
|
||||||
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
||||||
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import string
|
|
||||||
%import floats
|
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
float fl = floats.parse_f("-123.45678e20")
|
thing()
|
||||||
floats.print_f(fl)
|
}
|
||||||
|
sub thing() {
|
||||||
|
ubyte start=22
|
||||||
|
txt.print_ub(start)
|
||||||
|
txt.print_uw(&main.start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ class RequestParser : Take {
|
|||||||
Path(a),
|
Path(a),
|
||||||
optimize = true,
|
optimize = true,
|
||||||
writeAssembly = true,
|
writeAssembly = true,
|
||||||
|
warnSymbolShadowing = false,
|
||||||
compilationTarget = "c64",
|
compilationTarget = "c64",
|
||||||
symbolDefs = emptyMap(),
|
symbolDefs = emptyMap(),
|
||||||
quietAssembler = false,
|
quietAssembler = false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user