mirror of
https://github.com/irmen/prog8.git
synced 2025-07-04 08:24:02 +00:00
compiler was confused about resulting expression type
This commit is contained in:
@ -62,8 +62,10 @@ task fatJar(type: Jar) {
|
|||||||
attributes 'Main-Class': 'prog8.CompilerMainKt'
|
attributes 'Main-Class': 'prog8.CompilerMainKt'
|
||||||
}
|
}
|
||||||
archiveBaseName = 'prog8compiler'
|
archiveBaseName = 'prog8compiler'
|
||||||
destinationDir = rootProject.projectDir
|
destinationDirectory = rootProject.projectDir
|
||||||
from { project.configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
|
from {
|
||||||
|
project.configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
|
||||||
|
}
|
||||||
with jar
|
with jar
|
||||||
}
|
}
|
||||||
// build.finalizedBy(fatJar)
|
// build.finalizedBy(fatJar)
|
||||||
|
@ -926,8 +926,8 @@ class BinaryExpression(var left: IExpression, var operator: String, var right: I
|
|||||||
else -> throw FatalAstException("arithmetic operation on incompatible datatypes: $leftDt and $rightDt")
|
else -> throw FatalAstException("arithmetic operation on incompatible datatypes: $leftDt and $rightDt")
|
||||||
}
|
}
|
||||||
DataType.UWORD -> when(rightDt) {
|
DataType.UWORD -> when(rightDt) {
|
||||||
in ByteDatatypes -> DataType.UWORD
|
DataType.UBYTE, DataType.UWORD -> DataType.UWORD
|
||||||
in WordDatatypes -> DataType.WORD
|
DataType.BYTE, DataType.WORD -> DataType.WORD
|
||||||
DataType.FLOAT -> DataType.FLOAT
|
DataType.FLOAT -> DataType.FLOAT
|
||||||
else -> throw FatalAstException("arithmetic operation on incompatible datatypes: $leftDt and $rightDt")
|
else -> throw FatalAstException("arithmetic operation on incompatible datatypes: $leftDt and $rightDt")
|
||||||
}
|
}
|
||||||
|
@ -3317,44 +3317,7 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
null
|
null
|
||||||
},
|
},
|
||||||
|
|
||||||
// 16 bit addition avoiding excessive stack usage
|
// @todo optimize 8 and 16 bit adds and subs (avoid stack use altogether on most common operations)
|
||||||
// @todo optimize 8 and 16 bit adds and subs even more with longer asmpatterns (avoid stack use altogether on most common operations)
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_WORD, Opcode.ADD_UW),
|
|
||||||
listOf(Opcode.PUSH_VAR_WORD, Opcode.ADD_W)) { segment ->
|
|
||||||
"""
|
|
||||||
clc
|
|
||||||
lda ${segment[0].callLabel}
|
|
||||||
adc ${(ESTACK_LO+1).toHex()},x
|
|
||||||
sta ${(ESTACK_LO+1).toHex()},x
|
|
||||||
lda ${segment[0].callLabel}+1
|
|
||||||
adc ${(ESTACK_HI+1).toHex()},x
|
|
||||||
sta ${(ESTACK_HI+1).toHex()},x
|
|
||||||
"""
|
|
||||||
},
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_UW, Opcode.ADD_UW),
|
|
||||||
listOf(Opcode.PUSH_MEM_W, Opcode.ADD_W)) { segment ->
|
|
||||||
"""
|
|
||||||
clc
|
|
||||||
lda ${hexVal(segment[0])}
|
|
||||||
adc ${(ESTACK_LO + 1).toHex()},x
|
|
||||||
sta ${(ESTACK_LO + 1).toHex()},x
|
|
||||||
lda ${hexValPlusOne(segment[0])}
|
|
||||||
adc ${(ESTACK_HI + 1).toHex()},x
|
|
||||||
sta ${(ESTACK_HI + 1).toHex()},x
|
|
||||||
"""
|
|
||||||
},
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_WORD, Opcode.ADD_UW),
|
|
||||||
listOf(Opcode.PUSH_WORD, Opcode.ADD_W)) { segment ->
|
|
||||||
"""
|
|
||||||
clc
|
|
||||||
lda #<${hexVal(segment[0])}
|
|
||||||
adc ${(ESTACK_LO+1).toHex()},x
|
|
||||||
sta ${(ESTACK_LO+1).toHex()},x
|
|
||||||
lda #>${hexVal(segment[0])}
|
|
||||||
adc ${(ESTACK_HI+1).toHex()},x
|
|
||||||
sta ${(ESTACK_HI+1).toHex()},x
|
|
||||||
"""
|
|
||||||
},
|
|
||||||
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_B), listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_UB)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_B), listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_UB)) { segment ->
|
||||||
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
||||||
|
@ -74,7 +74,7 @@ val BuiltinFunctions = mapOf(
|
|||||||
"memcopy" to FunctionSignature(false, listOf(
|
"memcopy" to FunctionSignature(false, listOf(
|
||||||
BuiltinFunctionParam("from", IterableDatatypes + setOf(DataType.UWORD)),
|
BuiltinFunctionParam("from", IterableDatatypes + setOf(DataType.UWORD)),
|
||||||
BuiltinFunctionParam("to", IterableDatatypes + setOf(DataType.UWORD)),
|
BuiltinFunctionParam("to", IterableDatatypes + setOf(DataType.UWORD)),
|
||||||
BuiltinFunctionParam("numbytes", IntegerDatatypes)), null),
|
BuiltinFunctionParam("numbytes", setOf(DataType.UBYTE))), null),
|
||||||
"memset" to FunctionSignature(false, listOf(
|
"memset" to FunctionSignature(false, listOf(
|
||||||
BuiltinFunctionParam("address", IterableDatatypes + setOf(DataType.UWORD)),
|
BuiltinFunctionParam("address", IterableDatatypes + setOf(DataType.UWORD)),
|
||||||
BuiltinFunctionParam("numbytes", setOf(DataType.UWORD)),
|
BuiltinFunctionParam("numbytes", setOf(DataType.UWORD)),
|
||||||
|
@ -204,10 +204,10 @@ waitkey:
|
|||||||
|
|
||||||
; block colors I, J, L, O, S, T, Z: cyan, blue, orange, yellow, green, purple, red
|
; block colors I, J, L, O, S, T, Z: cyan, blue, orange, yellow, green, purple, red
|
||||||
ubyte[7] blockColors = [3, 6, 8, 7, 5, 4, 2]
|
ubyte[7] blockColors = [3, 6, 8, 7, 5, 4, 2]
|
||||||
ubyte[4] blockI = [4, 5, 6, 7] ; note: special rotation
|
ubyte[4] blockI = [4, 5, 6, 7] ; note: special rotation (only 2 states)
|
||||||
ubyte[4] blockJ = [0, 4, 5, 6]
|
ubyte[4] blockJ = [0, 4, 5, 6]
|
||||||
ubyte[4] blockL = [2, 4, 5, 6]
|
ubyte[4] blockL = [2, 4, 5, 6]
|
||||||
ubyte[4] blockO = [1, 2, 5, 6] ; note: no rotation
|
ubyte[4] blockO = [1, 2, 5, 6] ; note: no rotation (square)
|
||||||
ubyte[4] blockS = [1, 2, 4, 5]
|
ubyte[4] blockS = [1, 2, 4, 5]
|
||||||
ubyte[4] blockT = [1, 4, 5, 6]
|
ubyte[4] blockT = [1, 4, 5, 6]
|
||||||
ubyte[4] blockZ = [0, 1, 5, 6]
|
ubyte[4] blockZ = [0, 1, 5, 6]
|
||||||
@ -454,7 +454,7 @@ waitkey:
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub canMoveDown(ubyte xpos, ubyte ypos) -> ubyte {
|
sub canMoveDown(ubyte xpos, ubyte ypos) -> ubyte {
|
||||||
return ypos<main.boardOffsetY+main.boardHeight-4 ; TODO deal with actual block/border collision
|
return ypos<main.boardOffsetY+main.boardHeight-4 ; TODO deal with actual block/border collision, use generic check routine
|
||||||
}
|
}
|
||||||
|
|
||||||
sub isGameOver() -> ubyte {
|
sub isGameOver() -> ubyte {
|
||||||
|
@ -3,40 +3,12 @@
|
|||||||
|
|
||||||
~ main {
|
~ main {
|
||||||
|
|
||||||
; @todo test memset/memcopy (there's a bug in memcopy?)
|
|
||||||
|
|
||||||
; @todo see problem in looplabelproblem.p8
|
; @todo see problem in looplabelproblem.p8
|
||||||
|
|
||||||
; @todo add docs for '@zp' tag in variable datatype declarations (including forloop loopvars)
|
; @todo add docs for '@zp' tag in variable datatype declarations (including forloop loopvars)
|
||||||
; @todo gradle fatJar should include the antlr runtime jar
|
; @todo gradle fatJar should include the antlr runtime jar
|
||||||
|
|
||||||
; uword x = sin8u(bb) as uword + 50 ; @todo fix "cannot assign word to uword"
|
|
||||||
; uword ypos=4; ypos += 5000 ; @todo fix "cannot assign word to uword"
|
|
||||||
|
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
uword ypos=4
|
|
||||||
|
|
||||||
byte bb=44
|
|
||||||
byte bb2
|
|
||||||
word ww=4444
|
|
||||||
word ww2
|
|
||||||
|
|
||||||
bb2 = bb*55
|
|
||||||
ww2 = ww*55
|
|
||||||
|
|
||||||
uword x = sin8u(bb) as uword + 50 ; @todo fix "cannot assign word to uword"
|
|
||||||
;ypos += 5000 ; @todo fix "cannot assign word to uword"
|
|
||||||
|
|
||||||
;
|
|
||||||
; memset($0400+(ypos+0)*40, 40, 1)
|
|
||||||
; memset($0400+(ypos+1)*40, 40, 2)
|
|
||||||
; memset($0400+(ypos+2)*40, 40, 3)
|
|
||||||
; memset($0400+(ypos+3)*40, 40, 4)
|
|
||||||
|
|
||||||
;memsetw($0400+(ypos+1)*40, 20, $4455)
|
|
||||||
;memsetw($0400+(ypos+3)*40, 20, $4455)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user