diff --git a/compiler/res/version.txt b/compiler/res/version.txt new file mode 100644 index 000000000..d2d07c19d --- /dev/null +++ b/compiler/res/version.txt @@ -0,0 +1 @@ +1.0 (beta) diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index c043f3ad8..62c12c093 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -25,17 +25,21 @@ fun main(args: Array) { return stackVmMain(newArgs.toTypedArray()) } - - println("\nProg8 compiler by Irmen de Jong (irmen@razorvine.net)") - // @todo software license string - // println("This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html\n") - println("**** This is a prerelease version. Please do not distribute! ****\n") + printSoftwareHeader("compiler") if (args.isEmpty()) usage() compileMain(args) } +fun printSoftwareHeader(what: String) { + val buildVersion = object {}.javaClass.getResource("/version.txt").readText().trim() + println("\nProg8 $what by Irmen de Jong (irmen@razorvine.net)") + println("Version: $buildVersion") + println("This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html\n") +} + + private fun compileMain(args: Array) { var emulatorToStart = "" var moduleFile = "" diff --git a/compiler/src/prog8/StackVmMain.kt b/compiler/src/prog8/StackVmMain.kt index a88f0767a..757972e19 100644 --- a/compiler/src/prog8/StackVmMain.kt +++ b/compiler/src/prog8/StackVmMain.kt @@ -10,10 +10,7 @@ fun main(args: Array) { } fun stackVmMain(args: Array) { - println("\nProg8 StackVM by Irmen de Jong (irmen@razorvine.net)") - // @todo decide on software license - // println("This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html\n") - println("**** This is a prerelease version. Please do not distribute! ****\n") + printSoftwareHeader("StackVM") if(args.size != 1) { System.err.println("requires one argument: name of stackvm sourcecode file") diff --git a/compiler/src/prog8/ast/StmtReorderer.kt b/compiler/src/prog8/ast/StmtReorderer.kt index fc87e6227..c75663bcd 100644 --- a/compiler/src/prog8/ast/StmtReorderer.kt +++ b/compiler/src/prog8/ast/StmtReorderer.kt @@ -78,7 +78,7 @@ private class StatementReorderer(private val namespace: INameScope, private val && stmtBeforeFirstSub !is Subroutine && stmtBeforeFirstSub !is BuiltinFunctionStatementPlaceholder) { val ret = Return(emptyList(), stmtBeforeFirstSub.position) - ret.linkParents(stmtBeforeFirstSub.parent) + ret.linkParents(block) block.statements.add(block.statements.size - numSubroutinesAtEnd, ret) } } diff --git a/docs/source/building.rst b/docs/source/building.rst index b4ef79e74..b6b2ac404 100644 --- a/docs/source/building.rst +++ b/docs/source/building.rst @@ -19,6 +19,8 @@ that can be loaded into memory anywhere. Compiling program code ---------------------- +Make sure you have installed the :ref:`requirements`. + Compilation of program code is done by telling the Prog8 compiler to compile a main source code module file. Other modules that this code needs will be loaded and processed via imports from within that file. The compiler will link everything together into one output program at the end. @@ -94,3 +96,12 @@ Examples -------- A couple of example programs can be found in the 'examples' directory of the source tree. +Make sure you have installed the :ref:`requirements`. Then, for instance, +to compile and run the rasterbars example program, use this command:: + + $ java -jar prog8compiler.jar -emu examples/rasterbars.p8 + +or:: + + $ ./p8compile.sh -emu examples/rasterbars.p8 + diff --git a/docs/source/conf.py b/docs/source/conf.py index 1f2c2e0f1..81760e85a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,7 +12,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os +import os # import sys # sys.path.insert(0, os.path.abspath('.')) @@ -20,13 +20,14 @@ # -- Project information ----------------------------------------------------- project = 'Prog8' -copyright = '2018, Irmen de Jong' +copyright = '2019, Irmen de Jong' author = 'Irmen de Jong' + # The short X.Y version -version = 'x.y' +version = open("../../compiler/res/version.txt").readline() # The full version, including alpha/beta/rc tags -release = 'x.y alpha' +release = version # -- extensions diff --git a/docs/source/index.rst b/docs/source/index.rst index 48a13ad80..931ad0737 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -106,6 +106,8 @@ Design principles and features the ability to easily write embedded assembly code directly in the program source code. +.. _requirements: + Required tools -------------- diff --git a/examples/rasterbars.p8 b/examples/rasterbars.p8 index f4ce5166f..3cf962efb 100644 --- a/examples/rasterbars.p8 +++ b/examples/rasterbars.p8 @@ -19,24 +19,26 @@ const ubyte barheight = 4 ubyte[13] colors = [6,2,4,5,15,7,1,13,3,12,8,11,9] - ubyte color =0 + ubyte color = 0 ubyte ypos = 0 sub irq() { - ubyte rasterpos=c64.RASTER - A*=2 ; delay for align - A*=2 ; delay for align - A*=2 ; delay for align + Y++ ; delay for alignment + Y++ ; delay for alignment + Y++ ; delay for alignment + ubyte rasterpos = c64.RASTER if color!=len(colors) { c64.EXTCOL = colors[color] c64.RASTER = rasterpos+barheight color++ } else { - ypos+=2 + Y++ ; delay for alignment + Y++ ; delay for alignment + ypos += 2 c64.EXTCOL = 0 - c64.RASTER=sin8u(ypos)/2+40 - color=0 + c64.RASTER = sin8u(ypos)/2+40 + color = 0 } } }