fixed scripts, type check bug fixed, improved some argument error messages

This commit is contained in:
Irmen de Jong 2019-01-30 23:51:46 +01:00
parent 32a9ab30fb
commit 9a8ada7e75
6 changed files with 30 additions and 30 deletions

View File

@ -46,11 +46,11 @@ enum class DataType {
STR_P -> targetType == STR_P || targetType==STR_PS || targetType == UWORD
STR_S -> targetType == STR || targetType==STR_S || targetType == UWORD
STR_PS -> targetType == STR_P || targetType==STR_PS || targetType == UWORD
ARRAY_UB -> targetType == UWORD
ARRAY_B -> targetType == UWORD
ARRAY_UW -> targetType == UWORD
ARRAY_W -> targetType == UWORD
ARRAY_F -> targetType == UWORD
ARRAY_UB -> targetType == UWORD || targetType==ARRAY_UB
ARRAY_B -> targetType == UWORD || targetType==ARRAY_B
ARRAY_UW -> targetType == UWORD || targetType==ARRAY_UW
ARRAY_W -> targetType == UWORD || targetType==ARRAY_W
ARRAY_F -> targetType == UWORD || targetType==ARRAY_F
}

View File

@ -791,7 +791,7 @@ private class AstChecker(private val namespace: INameScope,
for (arg in args.withIndex().zip(func.parameters)) {
val argDt=arg.first.value.resultingDatatype(namespace, heap)
if(argDt!=null && !argDt.assignableTo(arg.second.possibleDatatypes)) {
checkResult.add(ExpressionError("builtin function argument ${arg.first.index + 1} has invalid type $argDt, expected ${arg.second.possibleDatatypes}", position))
checkResult.add(ExpressionError("builtin function '${target.name}' argument ${arg.first.index + 1} has invalid type $argDt, expected ${arg.second.possibleDatatypes}", position))
}
}
if(target.name=="swap") {
@ -815,7 +815,7 @@ private class AstChecker(private val namespace: INameScope,
for (arg in args.withIndex().zip(target.parameters)) {
val argDt = arg.first.value.resultingDatatype(namespace, heap)
if(argDt!=null && !argDt.assignableTo(arg.second.type))
checkResult.add(ExpressionError("subroutine argument ${arg.first.index+1} has invalid type $argDt, expected ${arg.second.type}", position))
checkResult.add(ExpressionError("subroutine '${target.name}' argument ${arg.first.index+1} has invalid type $argDt, expected ${arg.second.type}", position))
if(target.isAsmSubroutine) {
if (target.asmParameterRegisters[arg.first.index].registerOrPair in setOf(RegisterOrPair.AX, RegisterOrPair.XY, RegisterOrPair.X)) {

View File

@ -1,35 +1,32 @@
%import c64utils
%import c64flt
%option enable_floats
~ main {
sub start() {
ubyte @zp ub = 22
byte @zp b = 22
word @zp w = 2222
uword @zp uw = 2222
byte[10] ba = [1,2,3,4,5,6,7,8,9,-88]
ubyte[10] uba = [1,2,3,4,5,6,7,8,9,10]
c64scr.print_w(sum(ba))
c64.CHROUT('\n')
c64scr.print_uw(sum(uba))
c64.CHROUT('\n')
c64scr.print_ub(X)
c64.CHROUT('\n')
byte nonzp1 = 42
byte nonzp2 = 42
byte nonzp3 = 42
foo.bar()
; c64scr.print_w(w2)
; c64.CHROUT('\n')
; c64scr.print_w(w3)
; c64.CHROUT('\n')
; c64scr.print_uw(uw2)
; c64.CHROUT('\n')
}
}
~ foo {
; @todo float & float -> nice error instead of crash
sub bar() {
ubyte @zp ub = 33
byte @zp b = 33
word @zp w = 3333
uword @zp uw = 3333
word nonzp1 = 4444
word nonzp2 = 4444
word nonzp3 = 4444
A=55
}
}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env sh
PROG8CLASSPATH=./out/production/compiler:./out/production/parser
PROG8CLASSPATH=./out/production/prog8.compiler.main:./out/production/prog8.parser.main
KOTLINPATH=${HOME}/.IntelliJIdea2018.3/config/plugins/Kotlin
LIBJARS=${KOTLINPATH}/lib/kotlin-stdlib.jar:${KOTLINPATH}/lib/kotlin-reflect.jar:./parser/antlr/lib/antlr-runtime-4.7.2.jar

View File

@ -1,6 +1,6 @@
#!/usr/bin/env sh
PROG8CLASSPATH=./out/production/compiler
PROG8CLASSPATH=./out/production/prog8.compiler.main
KOTLINPATH=${HOME}/.IntelliJIdea2018.3/config/plugins/Kotlin
LIBJARS=${KOTLINPATH}/lib/kotlin-stdlib.jar:${KOTLINPATH}/lib/kotlin-reflect.jar

View File

@ -9,7 +9,10 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/gradle" />
<excludeFolder url="file://$MODULE_DIR$/out" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />