fix compiler crash, rasterbars alignment, docs.

This commit is contained in:
Irmen de Jong 2019-01-25 01:35:46 +01:00
parent 163c6bc628
commit 1ff68b06da
8 changed files with 40 additions and 22 deletions

1
compiler/res/version.txt Normal file
View File

@ -0,0 +1 @@
1.0 (beta)

View File

@ -25,17 +25,21 @@ fun main(args: Array<String>) {
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<String>) {
var emulatorToStart = ""
var moduleFile = ""

View File

@ -10,10 +10,7 @@ fun main(args: Array<String>) {
}
fun stackVmMain(args: Array<String>) {
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")

View File

@ -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)
}
}

View File

@ -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

View File

@ -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

View File

@ -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
--------------

View File

@ -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
}
}
}