mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
strings of len 1 are no longer converted to byte value, plus some other tweaks
This commit is contained in:
parent
d1b750ea55
commit
43c99f1d89
@ -7,88 +7,40 @@
|
||||
|
||||
sub start() {
|
||||
|
||||
ubyte v1
|
||||
ubyte v2
|
||||
float f2
|
||||
uword address
|
||||
memory uword memaddr = $c000
|
||||
uword[2] wordarray
|
||||
ubyte[2] ubytearray
|
||||
byte b1
|
||||
memory byte mb1 = $c991
|
||||
memory ubyte mub1 = $c992
|
||||
|
||||
|
||||
str stringvar = "??????????\n\n\nnext line\r\r\rnext line after carriagereturn"
|
||||
ubyte secretnumber = 0
|
||||
memory uword freadstr_arg = $22 ; argument for FREADSTR
|
||||
uword testword
|
||||
ubyte char1 = "@" ; @todo don't put this on the heap
|
||||
ubyte char2 = "\n"; @todo don't put this on the heap
|
||||
ubyte char3 = "\r"; @todo don't put this on the heap
|
||||
ubyte char1b = '@'
|
||||
ubyte char2b = '\n'
|
||||
ubyte char3b = '\r'
|
||||
|
||||
testword = '@'
|
||||
testword = '\n'
|
||||
freadstr_arg = '@'
|
||||
freadstr_arg = '\n'
|
||||
secretnumber = '@'
|
||||
secretnumber = '\r'
|
||||
|
||||
testword = stringvar
|
||||
testword = wordarray
|
||||
freadstr_arg = stringvar
|
||||
freadstr_arg = wordarray
|
||||
wordarray[1] = stringvar
|
||||
wordarray[1] = wordarray
|
||||
wordarray[b1] = stringvar
|
||||
wordarray[b1] = wordarray
|
||||
wordarray[mb1] = stringvar
|
||||
wordarray[mb1] = wordarray
|
||||
testword = "stringstring" ; @todo asmgen for this
|
||||
freadstr_arg = "stringstring" ; @todo asmgen for this
|
||||
freadstr_arg = "stringstring2222" ; @todo asmgen for this
|
||||
wordarray[1] = "stringstring" ; @todo asmgen for this
|
||||
wordarray[b1] = "stringstring" ; @todo asmgen for this
|
||||
wordarray[mb1] = "stringstring" ; @todo asmgen for this
|
||||
|
||||
|
||||
|
||||
; address =c64.MEMBOT(1, 40000.w) ; ok!
|
||||
; address =c64.MEMBOT(1, address) ; ok!
|
||||
; address =c64.MEMBOT(1, memaddr) ; ok!
|
||||
;
|
||||
; A, Y =c64.GETADR() ; ok!
|
||||
; Y, A =c64.GETADR() ; ok!
|
||||
; address = c64flt.GETADRAY() ; ok!
|
||||
; memaddr = c64flt.GETADRAY() ; ok!
|
||||
; wordarray[1] = c64flt.GETADRAY() ; ok!
|
||||
; v1, v2 =c64.GETADR() ; ok!
|
||||
; address =c64.IOBASE() ; ok!
|
||||
; A = c64.CHRIN() ; ok !
|
||||
; X = c64.CHRIN() ; ok !
|
||||
; Y = c64.CHRIN() ; ok!
|
||||
; v1 = c64.CHRIN() ; ok !
|
||||
|
||||
ubyte ub1
|
||||
memory byte mb1 = $c000
|
||||
memory ubyte mub1 = $c001
|
||||
ubyte[10] ubytearray
|
||||
byte[10] bytearray
|
||||
memory ubyte[10] memubytearray = $c100
|
||||
memory byte[10] membytearray=$c200
|
||||
word[10] wordarray
|
||||
|
||||
c64.CHROUT(X)
|
||||
c64.CHROUT(b1) ; @todo fix compiler crash expression identifierref should be a vardef, not null
|
||||
c64.CHROUT(char1) ; @todo fix compiler crash "
|
||||
c64.CHROUT(ub1) ; @todo fix compiler crash expression identifierref should be a vardef, not null
|
||||
c64.CHROUT(mb1) ; @todo fix compiler crash "
|
||||
c64.CHROUT(mub1) ; @todo fix compiler crash "
|
||||
c64.CHROUT(bytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
||||
c64.CHROUT(ubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
||||
c64.CHROUT(membytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
||||
c64.CHROUT(memubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
||||
c64.CHROUT(ubytearray[X]) ; @todo fix compiler crash "
|
||||
c64.CHROUT(memubytearray[X]) ; @todo fix compiler crash "
|
||||
c64.CHROUT(wordarray[1]) ; @todo fix compiler crash "
|
||||
|
||||
testsub(X) ; @todo fix compiler crash
|
||||
testsub(b1) ; @todo fix compiler crash
|
||||
testsub(char1) ; @todo fix compiler crash
|
||||
testsub(ub1) ; @todo fix compiler crash
|
||||
testsub(mb1) ; @todo fix compiler crash
|
||||
testsub(mub1) ; @todo fix compiler crash
|
||||
testsub(bytearray[1]) ; @todo fix compiler crash
|
||||
testsub(ubytearray[1]) ; @todo fix compiler crash
|
||||
testsub(membytearray[1]) ; @todo fix compiler crash
|
||||
testsub(memubytearray[1]) ; @todo fix compiler crash
|
||||
testsub(ubytearray[X]) ; @todo fix compiler crash
|
||||
testsub(memubytearray[X]) ; @todo fix compiler crash
|
||||
testsub(wordarray[1]) ; @todo fix compiler crash
|
||||
|
||||
return
|
||||
|
@ -7,6 +7,6 @@ javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar @sourc
|
||||
@del sources.txt
|
||||
jar cf parser.jar -C compiled_java prog8
|
||||
|
||||
set KOTLINC=%USERPROFILE%\.IdeaIC2018.2\config\plugins\kotlin\kotlinc\bin\kotlinc.bat
|
||||
set KOTLINC=%USERPROFILE%\.IdeaIC2018.3\config\plugins\kotlin\kotlinc\bin\kotlinc.bat
|
||||
|
||||
%KOTLINC% -verbose -include-runtime -d prog8_kotlin.jar -cp ../antlr/lib/antlr-runtime-4.7.1.jar;parser.jar prog8
|
||||
|
@ -7,7 +7,7 @@ mkdir -p compiled_java
|
||||
javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar @javasources.txt
|
||||
rm javasources.txt
|
||||
|
||||
KOTLINC="bash ${HOME}/.IntelliJIdea2018.2/config/plugins/Kotlin/kotlinc/bin/kotlinc"
|
||||
KOTLINC="bash ${HOME}/.IntelliJIdea2018.3/config/plugins/Kotlin/kotlinc/bin/kotlinc"
|
||||
${KOTLINC} -verbose -include-runtime -d prog8_kotlin.jar -cp ../antlr/lib/antlr-runtime-4.7.1.jar:compiled_java prog8
|
||||
|
||||
jar uf prog8_kotlin.jar -C compiled_java prog8
|
||||
|
@ -42,15 +42,6 @@ class ConstantFolding(private val namespace: INameScope, private val heap: HeapV
|
||||
decl.value = newValue
|
||||
}
|
||||
}
|
||||
in IntegerDatatypes -> {
|
||||
// vardecl: for byte/word vars, convert char/string of length 1 initialization values to ubyte integer
|
||||
val literal = decl.value as? LiteralValue
|
||||
if (literal != null && literal.isString && literal.strvalue(heap).length == 1) {
|
||||
val petscii = Petscii.encodePetscii(literal.strvalue(heap), true)[0]
|
||||
val newValue = LiteralValue(DataType.UBYTE, bytevalue = petscii, position = literal.position)
|
||||
decl.value = newValue
|
||||
}
|
||||
}
|
||||
DataType.ARRAY_UB, DataType.ARRAY_B, DataType.ARRAY_UW, DataType.ARRAY_W -> {
|
||||
val litval = decl.value as? LiteralValue
|
||||
if(litval?.type==DataType.FLOAT)
|
||||
|
@ -1,16 +1,17 @@
|
||||
// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7
|
||||
// Generated from ../antlr/prog8.g4 by ANTLR 4.7.1
|
||||
package prog8.parser;
|
||||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.ATN;
|
||||
import org.antlr.v4.runtime.atn.ATNDeserializer;
|
||||
import org.antlr.v4.runtime.atn.LexerATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.PredictionContextCache;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class prog8Lexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
|
||||
static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
|
@ -1,19 +1,17 @@
|
||||
// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7
|
||||
// Generated from ../antlr/prog8.g4 by ANTLR 4.7.1
|
||||
package prog8.parser;
|
||||
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.ATN;
|
||||
import org.antlr.v4.runtime.atn.ATNDeserializer;
|
||||
import org.antlr.v4.runtime.atn.ParserATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.PredictionContextCache;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
import org.antlr.v4.runtime.tree.*;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class prog8Parser extends Parser {
|
||||
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
|
||||
static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
|
@ -26,8 +26,8 @@
|
||||
memory uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in
|
||||
memory uword IRQ_VEC = $FFFE ; 6502 interrupt vector, determined by the kernal if banked in
|
||||
|
||||
const uword Screen = $0400 ; default character screen matrix
|
||||
const uword Colors = $d800 ; character screen colors
|
||||
const uword Screen = $0400 ; default character screen matrix @todo matrix/array? needs to support array size > 255
|
||||
const uword Colors = $d800 ; character screen colors @todo matrix/array? needs to support array size > 255
|
||||
|
||||
|
||||
; ---- VIC-II registers ----
|
||||
|
@ -611,7 +611,7 @@ asmsub print_string (text: str @ XY) -> clobbers(A,Y) -> () {
|
||||
; ---- print null terminated string from X/Y
|
||||
; note: the compiler contains an optimization that will replace
|
||||
; a call to this subroutine with a string argument of just one char,
|
||||
; by just one call to c64.CHROUT of that single char.
|
||||
; by just one call to c64.CHROUT of that single char. @todo do this
|
||||
%asm {{
|
||||
stx c64.SCRATCH_ZP1
|
||||
sty c64.SCRATCH_ZP2
|
||||
|
Loading…
x
Reference in New Issue
Block a user