mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
compiler was confused about resulting expression type
This commit is contained in:
parent
96ecbc9fe4
commit
b8ae808b65
@ -62,8 +62,10 @@ task fatJar(type: Jar) {
|
||||
attributes 'Main-Class': 'prog8.CompilerMainKt'
|
||||
}
|
||||
archiveBaseName = 'prog8compiler'
|
||||
destinationDir = rootProject.projectDir
|
||||
from { project.configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
destinationDirectory = rootProject.projectDir
|
||||
from {
|
||||
project.configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
with jar
|
||||
}
|
||||
// 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")
|
||||
}
|
||||
DataType.UWORD -> when(rightDt) {
|
||||
in ByteDatatypes -> DataType.UWORD
|
||||
in WordDatatypes -> DataType.WORD
|
||||
DataType.UBYTE, DataType.UWORD -> DataType.UWORD
|
||||
DataType.BYTE, DataType.WORD -> DataType.WORD
|
||||
DataType.FLOAT -> DataType.FLOAT
|
||||
else -> throw FatalAstException("arithmetic operation on incompatible datatypes: $leftDt and $rightDt")
|
||||
}
|
||||
|
@ -3317,44 +3317,7 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
||||
null
|
||||
},
|
||||
|
||||
// 16 bit addition avoiding excessive stack usage
|
||||
// @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
|
||||
"""
|
||||
},
|
||||
// @todo optimize 8 and 16 bit adds and subs (avoid stack use altogether on most common operations)
|
||||
|
||||
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)
|
||||
|
@ -74,7 +74,7 @@ val BuiltinFunctions = mapOf(
|
||||
"memcopy" to FunctionSignature(false, listOf(
|
||||
BuiltinFunctionParam("from", 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(
|
||||
BuiltinFunctionParam("address", IterableDatatypes + 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
|
||||
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] 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] blockT = [1, 4, 5, 6]
|
||||
ubyte[4] blockZ = [0, 1, 5, 6]
|
||||
@ -454,7 +454,7 @@ waitkey:
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -3,40 +3,12 @@
|
||||
|
||||
~ main {
|
||||
|
||||
; @todo test memset/memcopy (there's a bug in memcopy?)
|
||||
|
||||
; @todo see problem in looplabelproblem.p8
|
||||
|
||||
; @todo add docs for '@zp' tag in variable datatype declarations (including forloop loopvars)
|
||||
; @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() {
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user