mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-03-24 15:32:58 +00:00
Added support for silent truncation from int/long to char. Closes #684
This commit is contained in:
parent
d6179a0b3c
commit
7dbb73e8bd
@ -190,6 +190,18 @@ public class SymbolTypeConversion {
|
||||
return true;
|
||||
if(lValueType.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.BYTE.equals(lValueType) && SymbolType.WORD.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.BYTE.equals(lValueType) && SymbolType.SWORD.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.BYTE.equals(lValueType) && SymbolType.DWORD.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.BYTE.equals(lValueType) && SymbolType.SDWORD.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.SBYTE.equals(lValueType) && SymbolType.SWORD.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.SBYTE.equals(lValueType) && SymbolType.SDWORD.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.WORD.equals(lValueType) && SymbolType.BYTE.equals(rValueType))
|
||||
return true;
|
||||
if(SymbolType.DWORD.equals(lValueType) && SymbolType.BYTE.equals(rValueType))
|
||||
|
@ -3481,8 +3481,8 @@ public class TestProgramsFast extends TestPrograms {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastNotNeeded2() throws IOException {
|
||||
compileAndCompare("cast-not-needed-2.c");
|
||||
public void testCastNotNeeded4() throws IOException {
|
||||
compileAndCompare("cast-not-needed-4.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -3490,6 +3490,11 @@ public class TestProgramsFast extends TestPrograms {
|
||||
compileAndCompare("cast-not-needed-3.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastNotNeeded2() throws IOException {
|
||||
compileAndCompare("cast-not-needed-2.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastNotNeeded() throws IOException {
|
||||
compileAndCompare("cast-not-needed.c");
|
||||
@ -4663,8 +4668,8 @@ public class TestProgramsFast extends TestPrograms {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeMismatch() throws IOException {
|
||||
assertError("typemismatch.c", "Type mismatch (byte) cannot be assigned from (word)");
|
||||
public void testTypeTruncate() throws IOException {
|
||||
compileAndCompare("type-truncate.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
12
src/test/kc/cast-not-needed-4.c
Normal file
12
src/test/kc/cast-not-needed-4.c
Normal file
@ -0,0 +1,12 @@
|
||||
// Tests a cast that is not needed
|
||||
// When assigning a char from an integer
|
||||
|
||||
|
||||
void main() {
|
||||
char * screen = (char*)0x0400;
|
||||
for(int i=-1000;i<1000;i++) {
|
||||
char c = i;
|
||||
*(screen++) = c;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// Type mismatch - should fail gracefully
|
||||
// Type match bytes can be assigned from integers without issue
|
||||
void main() {
|
||||
word w = 5000;
|
||||
byte b = w;
|
52
src/test/ref/cast-not-needed-4.asm
Normal file
52
src/test/ref/cast-not-needed-4.asm
Normal file
@ -0,0 +1,52 @@
|
||||
// Tests a cast that is not needed
|
||||
// When assigning a char from an integer
|
||||
// Commodore 64 PRG executable file
|
||||
.file [name="cast-not-needed-4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$0801]
|
||||
.segmentdef Code [start=$80d]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
:BasicUpstart(main)
|
||||
.segment Code
|
||||
main: {
|
||||
.label screen = 4
|
||||
.label i = 2
|
||||
lda #<$400
|
||||
sta.z screen
|
||||
lda #>$400
|
||||
sta.z screen+1
|
||||
lda #<-$3e8
|
||||
sta.z i
|
||||
lda #>-$3e8
|
||||
sta.z i+1
|
||||
__b1:
|
||||
// for(int i=-1000;i<1000;i++)
|
||||
lda.z i
|
||||
cmp #<$3e8
|
||||
lda.z i+1
|
||||
sbc #>$3e8
|
||||
bvc !+
|
||||
eor #$80
|
||||
!:
|
||||
bmi __b2
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// char c = i
|
||||
lda.z i
|
||||
// *(screen++) = c
|
||||
ldy #0
|
||||
sta (screen),y
|
||||
// *(screen++) = c;
|
||||
inc.z screen
|
||||
bne !+
|
||||
inc.z screen+1
|
||||
!:
|
||||
// for(int i=-1000;i<1000;i++)
|
||||
inc.z i
|
||||
bne !+
|
||||
inc.z i+1
|
||||
!:
|
||||
jmp __b1
|
||||
}
|
19
src/test/ref/cast-not-needed-4.cfg
Normal file
19
src/test/ref/cast-not-needed-4.cfg
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
void main()
|
||||
main: scope:[main] from
|
||||
[0] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[1] main::screen#2 = phi( main/(byte*) 1024, main::@2/main::screen#1 )
|
||||
[1] main::i#2 = phi( main/-$3e8, main::@2/main::i#1 )
|
||||
[2] if(main::i#2<$3e8) goto main::@2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[3] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[4] main::c#0 = (byte)main::i#2
|
||||
[5] *main::screen#2 = main::c#0
|
||||
[6] main::screen#1 = ++ main::screen#2
|
||||
[7] main::i#1 = ++ main::i#2
|
||||
to:main::@1
|
320
src/test/ref/cast-not-needed-4.log
Normal file
320
src/test/ref/cast-not-needed-4.log
Normal file
@ -0,0 +1,320 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
|
||||
void main()
|
||||
main: scope:[main] from __start
|
||||
main::screen#0 = (byte*)$400
|
||||
main::i#0 = -$3e8
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
main::screen#3 = phi( main/main::screen#0, main::@2/main::screen#1 )
|
||||
main::i#2 = phi( main/main::i#0, main::@2/main::i#1 )
|
||||
main::$0 = main::i#2 < $3e8
|
||||
if(main::$0) goto main::@2
|
||||
to:main::@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
main::screen#2 = phi( main::@1/main::screen#3 )
|
||||
main::i#3 = phi( main::@1/main::i#2 )
|
||||
main::c#0 = (byte)main::i#3
|
||||
*main::screen#2 = main::c#0
|
||||
main::screen#1 = ++ main::screen#2
|
||||
main::i#1 = ++ main::i#3
|
||||
to:main::@1
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
|
||||
void __start()
|
||||
__start: scope:[__start] from
|
||||
call main
|
||||
to:__start::@1
|
||||
__start::@1: scope:[__start] from __start
|
||||
to:__start::@return
|
||||
__start::@return: scope:[__start] from __start::@1
|
||||
return
|
||||
to:@return
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
void __start()
|
||||
void main()
|
||||
bool~ main::$0
|
||||
byte main::c
|
||||
byte main::c#0
|
||||
signed word main::i
|
||||
signed word main::i#0
|
||||
signed word main::i#1
|
||||
signed word main::i#2
|
||||
signed word main::i#3
|
||||
byte* main::screen
|
||||
byte* main::screen#0
|
||||
byte* main::screen#1
|
||||
byte* main::screen#2
|
||||
byte* main::screen#3
|
||||
|
||||
Adding number conversion cast (snumber) $3e8 in main::$0 = main::i#2 < $3e8
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant integer cast $3e8
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized signed number type (signed word) $3e8
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Alias main::i#2 = main::i#3
|
||||
Alias main::screen#2 = main::screen#3
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Simple Condition main::$0 [4] if(main::i#2<$3e8) goto main::@2
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant main::screen#0 = (byte*) 1024
|
||||
Constant main::i#0 = -$3e8
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Removing unused procedure __start
|
||||
Removing unused procedure block __start
|
||||
Removing unused procedure block __start::@1
|
||||
Removing unused procedure block __start::@return
|
||||
Successful SSA optimization PassNEliminateEmptyStart
|
||||
Inlining constant with var siblings main::screen#0
|
||||
Inlining constant with var siblings main::i#0
|
||||
Constant inlined main::screen#0 = (byte*) 1024
|
||||
Constant inlined main::i#0 = -$3e8
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
|
||||
Created 2 initial phi equivalence classes
|
||||
Coalesced [8] main::i#4 = main::i#1
|
||||
Coalesced [9] main::screen#4 = main::screen#1
|
||||
Coalesced down to 2 phi equivalence classes
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
|
||||
void main()
|
||||
main: scope:[main] from
|
||||
[0] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[1] main::screen#2 = phi( main/(byte*) 1024, main::@2/main::screen#1 )
|
||||
[1] main::i#2 = phi( main/-$3e8, main::@2/main::i#1 )
|
||||
[2] if(main::i#2<$3e8) goto main::@2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[3] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[4] main::c#0 = (byte)main::i#2
|
||||
[5] *main::screen#2 = main::c#0
|
||||
[6] main::screen#1 = ++ main::screen#2
|
||||
[7] main::i#1 = ++ main::i#2
|
||||
to:main::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
void main()
|
||||
byte main::c
|
||||
byte main::c#0 22.0
|
||||
signed word main::i
|
||||
signed word main::i#1 22.0
|
||||
signed word main::i#2 6.6000000000000005
|
||||
byte* main::screen
|
||||
byte* main::screen#1 11.0
|
||||
byte* main::screen#2 8.25
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::screen#2 main::screen#1 ]
|
||||
Added variable main::c#0 to live range equivalence class [ main::c#0 ]
|
||||
Complete equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::screen#2 main::screen#1 ]
|
||||
[ main::c#0 ]
|
||||
Allocated zp[2]:2 [ main::i#2 main::i#1 ]
|
||||
Allocated zp[2]:4 [ main::screen#2 main::screen#1 ]
|
||||
Allocated zp[1]:6 [ main::c#0 ]
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [2] if(main::i#2<$3e8) goto main::@2 [ main::i#2 main::screen#2 ] ( [ main::i#2 main::screen#2 ] { } ) always clobbers reg byte a
|
||||
Statement [4] main::c#0 = (byte)main::i#2 [ main::i#2 main::screen#2 main::c#0 ] ( [ main::i#2 main::screen#2 main::c#0 ] { } ) always clobbers reg byte a
|
||||
Statement [5] *main::screen#2 = main::c#0 [ main::i#2 main::screen#2 ] ( [ main::i#2 main::screen#2 ] { } ) always clobbers reg byte y
|
||||
Potential registers zp[2]:2 [ main::i#2 main::i#1 ] : zp[2]:2 ,
|
||||
Potential registers zp[2]:4 [ main::screen#2 main::screen#1 ] : zp[2]:4 ,
|
||||
Potential registers zp[1]:6 [ main::c#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 28.6: zp[2]:2 [ main::i#2 main::i#1 ] 22: zp[1]:6 [ main::c#0 ] 19.25: zp[2]:4 [ main::screen#2 main::screen#1 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 826 combination zp[2]:2 [ main::i#2 main::i#1 ] reg byte a [ main::c#0 ] zp[2]:4 [ main::screen#2 main::screen#1 ]
|
||||
Uplifting [] best 826 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Tests a cast that is not needed
|
||||
// When assigning a char from an integer
|
||||
// Upstart
|
||||
// Commodore 64 PRG executable file
|
||||
.file [name="cast-not-needed-4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$0801]
|
||||
.segmentdef Code [start=$80d]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
:BasicUpstart(main)
|
||||
// Global Constants & labels
|
||||
.segment Code
|
||||
// main
|
||||
main: {
|
||||
.label screen = 4
|
||||
.label i = 2
|
||||
// [1] phi from main to main::@1 [phi:main->main::@1]
|
||||
__b1_from_main:
|
||||
// [1] phi main::screen#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1
|
||||
lda #<$400
|
||||
sta.z screen
|
||||
lda #>$400
|
||||
sta.z screen+1
|
||||
// [1] phi main::i#2 = -$3e8 [phi:main->main::@1#1] -- vwsz1=vwsc1
|
||||
lda #<-$3e8
|
||||
sta.z i
|
||||
lda #>-$3e8
|
||||
sta.z i+1
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [2] if(main::i#2<$3e8) goto main::@2 -- vwsz1_lt_vwsc1_then_la1
|
||||
lda.z i
|
||||
cmp #<$3e8
|
||||
lda.z i+1
|
||||
sbc #>$3e8
|
||||
bvc !+
|
||||
eor #$80
|
||||
!:
|
||||
bmi __b2
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [3] return
|
||||
rts
|
||||
// main::@2
|
||||
__b2:
|
||||
// [4] main::c#0 = (byte)main::i#2 -- vbuaa=_byte_vwsz1
|
||||
lda.z i
|
||||
// [5] *main::screen#2 = main::c#0 -- _deref_pbuz1=vbuaa
|
||||
ldy #0
|
||||
sta (screen),y
|
||||
// [6] main::screen#1 = ++ main::screen#2 -- pbuz1=_inc_pbuz1
|
||||
inc.z screen
|
||||
bne !+
|
||||
inc.z screen+1
|
||||
!:
|
||||
// [7] main::i#1 = ++ main::i#2 -- vwsz1=_inc_vwsz1
|
||||
inc.z i
|
||||
bne !+
|
||||
inc.z i+1
|
||||
!:
|
||||
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
__b1_from___b2:
|
||||
// [1] phi main::screen#2 = main::screen#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
// [1] phi main::i#2 = main::i#1 [phi:main::@2->main::@1#1] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction __b1_from_main:
|
||||
Removing instruction __breturn:
|
||||
Removing instruction __b1_from___b2:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
void main()
|
||||
byte main::c
|
||||
byte main::c#0 reg byte a 22.0
|
||||
signed word main::i
|
||||
signed word main::i#1 i zp[2]:2 22.0
|
||||
signed word main::i#2 i zp[2]:2 6.6000000000000005
|
||||
byte* main::screen
|
||||
byte* main::screen#1 screen zp[2]:4 11.0
|
||||
byte* main::screen#2 screen zp[2]:4 8.25
|
||||
|
||||
zp[2]:2 [ main::i#2 main::i#1 ]
|
||||
zp[2]:4 [ main::screen#2 main::screen#1 ]
|
||||
reg byte a [ main::c#0 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 766
|
||||
|
||||
// File Comments
|
||||
// Tests a cast that is not needed
|
||||
// When assigning a char from an integer
|
||||
// Upstart
|
||||
// Commodore 64 PRG executable file
|
||||
.file [name="cast-not-needed-4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$0801]
|
||||
.segmentdef Code [start=$80d]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
:BasicUpstart(main)
|
||||
// Global Constants & labels
|
||||
.segment Code
|
||||
// main
|
||||
main: {
|
||||
.label screen = 4
|
||||
.label i = 2
|
||||
// [1] phi from main to main::@1 [phi:main->main::@1]
|
||||
// [1] phi main::screen#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1
|
||||
lda #<$400
|
||||
sta.z screen
|
||||
lda #>$400
|
||||
sta.z screen+1
|
||||
// [1] phi main::i#2 = -$3e8 [phi:main->main::@1#1] -- vwsz1=vwsc1
|
||||
lda #<-$3e8
|
||||
sta.z i
|
||||
lda #>-$3e8
|
||||
sta.z i+1
|
||||
// main::@1
|
||||
__b1:
|
||||
// for(int i=-1000;i<1000;i++)
|
||||
// [2] if(main::i#2<$3e8) goto main::@2 -- vwsz1_lt_vwsc1_then_la1
|
||||
lda.z i
|
||||
cmp #<$3e8
|
||||
lda.z i+1
|
||||
sbc #>$3e8
|
||||
bvc !+
|
||||
eor #$80
|
||||
!:
|
||||
bmi __b2
|
||||
// main::@return
|
||||
// }
|
||||
// [3] return
|
||||
rts
|
||||
// main::@2
|
||||
__b2:
|
||||
// char c = i
|
||||
// [4] main::c#0 = (byte)main::i#2 -- vbuaa=_byte_vwsz1
|
||||
lda.z i
|
||||
// *(screen++) = c
|
||||
// [5] *main::screen#2 = main::c#0 -- _deref_pbuz1=vbuaa
|
||||
ldy #0
|
||||
sta (screen),y
|
||||
// *(screen++) = c;
|
||||
// [6] main::screen#1 = ++ main::screen#2 -- pbuz1=_inc_pbuz1
|
||||
inc.z screen
|
||||
bne !+
|
||||
inc.z screen+1
|
||||
!:
|
||||
// for(int i=-1000;i<1000;i++)
|
||||
// [7] main::i#1 = ++ main::i#2 -- vwsz1=_inc_vwsz1
|
||||
inc.z i
|
||||
bne !+
|
||||
inc.z i+1
|
||||
!:
|
||||
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
// [1] phi main::screen#2 = main::screen#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
// [1] phi main::i#2 = main::i#1 [phi:main::@2->main::@1#1] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
13
src/test/ref/cast-not-needed-4.sym
Normal file
13
src/test/ref/cast-not-needed-4.sym
Normal file
@ -0,0 +1,13 @@
|
||||
void main()
|
||||
byte main::c
|
||||
byte main::c#0 reg byte a 22.0
|
||||
signed word main::i
|
||||
signed word main::i#1 i zp[2]:2 22.0
|
||||
signed word main::i#2 i zp[2]:2 6.6000000000000005
|
||||
byte* main::screen
|
||||
byte* main::screen#1 screen zp[2]:4 11.0
|
||||
byte* main::screen#2 screen zp[2]:4 8.25
|
||||
|
||||
zp[2]:2 [ main::i#2 main::i#1 ]
|
||||
zp[2]:4 [ main::screen#2 main::screen#1 ]
|
||||
reg byte a [ main::c#0 ]
|
@ -115,6 +115,10 @@ testSimpleTypes: {
|
||||
ldy #TYPEID_SIGNED_DWORD
|
||||
ldx #TYPEID_SIGNED_DWORD
|
||||
jsr assertType
|
||||
// assertType(typeid(12u), typeid(unsigned word))
|
||||
ldy #TYPEID_WORD
|
||||
ldx #TYPEID_WORD
|
||||
jsr assertType
|
||||
// }
|
||||
rts
|
||||
}
|
||||
|
@ -79,28 +79,32 @@ testSimpleTypes::@13: scope:[testSimpleTypes] from testSimpleTypes::@12
|
||||
testSimpleTypes::@14: scope:[testSimpleTypes] from testSimpleTypes::@13
|
||||
[36] phi()
|
||||
[37] call assertType
|
||||
to:testSimpleTypes::@15
|
||||
testSimpleTypes::@15: scope:[testSimpleTypes] from testSimpleTypes::@14
|
||||
[38] phi()
|
||||
[39] call assertType
|
||||
to:testSimpleTypes::@return
|
||||
testSimpleTypes::@return: scope:[testSimpleTypes] from testSimpleTypes::@14
|
||||
[38] return
|
||||
testSimpleTypes::@return: scope:[testSimpleTypes] from testSimpleTypes::@15
|
||||
[40] return
|
||||
to:@return
|
||||
|
||||
void assertType(byte assertType::t1 , byte assertType::t2)
|
||||
assertType: scope:[assertType] from testSimpleTypes testSimpleTypes::@1 testSimpleTypes::@10 testSimpleTypes::@11 testSimpleTypes::@12 testSimpleTypes::@13 testSimpleTypes::@14 testSimpleTypes::@2 testSimpleTypes::@3 testSimpleTypes::@4 testSimpleTypes::@5 testSimpleTypes::@6 testSimpleTypes::@7 testSimpleTypes::@8 testSimpleTypes::@9
|
||||
[39] idx#42 = phi( testSimpleTypes/0, testSimpleTypes::@1/idx#19, testSimpleTypes::@10/idx#19, testSimpleTypes::@11/idx#19, testSimpleTypes::@12/idx#19, testSimpleTypes::@13/idx#19, testSimpleTypes::@14/idx#19, testSimpleTypes::@2/idx#19, testSimpleTypes::@3/idx#19, testSimpleTypes::@4/idx#19, testSimpleTypes::@5/idx#19, testSimpleTypes::@6/idx#19, testSimpleTypes::@7/idx#19, testSimpleTypes::@8/idx#19, testSimpleTypes::@9/idx#19 )
|
||||
[39] assertType::t2#15 = phi( testSimpleTypes/TYPEID_BYTE, testSimpleTypes::@1/TYPEID_BYTE, testSimpleTypes::@10/TYPEID_DWORD, testSimpleTypes::@11/TYPEID_DWORD, testSimpleTypes::@12/TYPEID_SIGNED_DWORD, testSimpleTypes::@13/TYPEID_SIGNED_DWORD, testSimpleTypes::@14/TYPEID_SIGNED_DWORD, testSimpleTypes::@2/TYPEID_SIGNED_BYTE, testSimpleTypes::@3/TYPEID_SIGNED_BYTE, testSimpleTypes::@4/TYPEID_WORD, testSimpleTypes::@5/TYPEID_WORD, testSimpleTypes::@6/TYPEID_WORD, testSimpleTypes::@7/TYPEID_SIGNED_WORD, testSimpleTypes::@8/TYPEID_SIGNED_WORD, testSimpleTypes::@9/TYPEID_SIGNED_WORD )
|
||||
[39] assertType::t1#15 = phi( testSimpleTypes/TYPEID_BYTE, testSimpleTypes::@1/TYPEID_BYTE, testSimpleTypes::@10/TYPEID_DWORD, testSimpleTypes::@11/TYPEID_DWORD, testSimpleTypes::@12/TYPEID_SIGNED_DWORD, testSimpleTypes::@13/TYPEID_SIGNED_DWORD, testSimpleTypes::@14/TYPEID_SIGNED_DWORD, testSimpleTypes::@2/TYPEID_SIGNED_BYTE, testSimpleTypes::@3/TYPEID_SIGNED_BYTE, testSimpleTypes::@4/TYPEID_WORD, testSimpleTypes::@5/TYPEID_WORD, testSimpleTypes::@6/TYPEID_WORD, testSimpleTypes::@7/TYPEID_SIGNED_WORD, testSimpleTypes::@8/TYPEID_SIGNED_WORD, testSimpleTypes::@9/TYPEID_SIGNED_WORD )
|
||||
[40] if(assertType::t1#15==assertType::t2#15) goto assertType::@1
|
||||
assertType: scope:[assertType] from testSimpleTypes testSimpleTypes::@1 testSimpleTypes::@10 testSimpleTypes::@11 testSimpleTypes::@12 testSimpleTypes::@13 testSimpleTypes::@14 testSimpleTypes::@15 testSimpleTypes::@2 testSimpleTypes::@3 testSimpleTypes::@4 testSimpleTypes::@5 testSimpleTypes::@6 testSimpleTypes::@7 testSimpleTypes::@8 testSimpleTypes::@9
|
||||
[41] idx#44 = phi( testSimpleTypes/0, testSimpleTypes::@1/idx#20, testSimpleTypes::@10/idx#20, testSimpleTypes::@11/idx#20, testSimpleTypes::@12/idx#20, testSimpleTypes::@13/idx#20, testSimpleTypes::@14/idx#20, testSimpleTypes::@15/idx#20, testSimpleTypes::@2/idx#20, testSimpleTypes::@3/idx#20, testSimpleTypes::@4/idx#20, testSimpleTypes::@5/idx#20, testSimpleTypes::@6/idx#20, testSimpleTypes::@7/idx#20, testSimpleTypes::@8/idx#20, testSimpleTypes::@9/idx#20 )
|
||||
[41] assertType::t2#16 = phi( testSimpleTypes/TYPEID_BYTE, testSimpleTypes::@1/TYPEID_BYTE, testSimpleTypes::@10/TYPEID_DWORD, testSimpleTypes::@11/TYPEID_DWORD, testSimpleTypes::@12/TYPEID_SIGNED_DWORD, testSimpleTypes::@13/TYPEID_SIGNED_DWORD, testSimpleTypes::@14/TYPEID_SIGNED_DWORD, testSimpleTypes::@15/TYPEID_WORD, testSimpleTypes::@2/TYPEID_SIGNED_BYTE, testSimpleTypes::@3/TYPEID_SIGNED_BYTE, testSimpleTypes::@4/TYPEID_WORD, testSimpleTypes::@5/TYPEID_WORD, testSimpleTypes::@6/TYPEID_WORD, testSimpleTypes::@7/TYPEID_SIGNED_WORD, testSimpleTypes::@8/TYPEID_SIGNED_WORD, testSimpleTypes::@9/TYPEID_SIGNED_WORD )
|
||||
[41] assertType::t1#16 = phi( testSimpleTypes/TYPEID_BYTE, testSimpleTypes::@1/TYPEID_BYTE, testSimpleTypes::@10/TYPEID_DWORD, testSimpleTypes::@11/TYPEID_DWORD, testSimpleTypes::@12/TYPEID_SIGNED_DWORD, testSimpleTypes::@13/TYPEID_SIGNED_DWORD, testSimpleTypes::@14/TYPEID_SIGNED_DWORD, testSimpleTypes::@15/TYPEID_WORD, testSimpleTypes::@2/TYPEID_SIGNED_BYTE, testSimpleTypes::@3/TYPEID_SIGNED_BYTE, testSimpleTypes::@4/TYPEID_WORD, testSimpleTypes::@5/TYPEID_WORD, testSimpleTypes::@6/TYPEID_WORD, testSimpleTypes::@7/TYPEID_SIGNED_WORD, testSimpleTypes::@8/TYPEID_SIGNED_WORD, testSimpleTypes::@9/TYPEID_SIGNED_WORD )
|
||||
[42] if(assertType::t1#16==assertType::t2#16) goto assertType::@1
|
||||
to:assertType::@3
|
||||
assertType::@3: scope:[assertType] from assertType
|
||||
[41] COLS[idx#42] = RED
|
||||
[43] COLS[idx#44] = RED
|
||||
to:assertType::@2
|
||||
assertType::@2: scope:[assertType] from assertType::@1 assertType::@3
|
||||
[42] SCREEN[idx#42] = assertType::t1#15
|
||||
[43] idx#19 = ++ idx#42
|
||||
[44] SCREEN[idx#44] = assertType::t1#16
|
||||
[45] idx#20 = ++ idx#44
|
||||
to:assertType::@return
|
||||
assertType::@return: scope:[assertType] from assertType::@2
|
||||
[44] return
|
||||
[46] return
|
||||
to:@return
|
||||
assertType::@1: scope:[assertType] from assertType
|
||||
[45] COLS[idx#42] = GREEN
|
||||
[47] COLS[idx#44] = GREEN
|
||||
to:assertType::@2
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,12 +10,12 @@ constant byte TYPEID_SIGNED_WORD = 4
|
||||
constant byte TYPEID_WORD = 3
|
||||
void assertType(byte assertType::t1 , byte assertType::t2)
|
||||
byte assertType::t1
|
||||
byte assertType::t1#15 reg byte x 50.5
|
||||
byte assertType::t1#16 reg byte x 50.5
|
||||
byte assertType::t2
|
||||
byte assertType::t2#15 reg byte y 101.0
|
||||
byte assertType::t2#16 reg byte y 101.0
|
||||
byte idx
|
||||
byte idx#19 idx zp[1]:4 8.499999999999998
|
||||
byte idx#42 idx zp[1]:4 111.6
|
||||
byte idx#20 idx zp[1]:4 8.3125
|
||||
byte idx#44 idx zp[1]:4 113.8
|
||||
void main()
|
||||
byte* main::s
|
||||
byte* main::s#1 s zp[2]:2 22.0
|
||||
@ -23,6 +23,6 @@ byte* main::s#2 s zp[2]:2 14.666666666666666
|
||||
void testSimpleTypes()
|
||||
|
||||
zp[2]:2 [ main::s#2 main::s#1 ]
|
||||
reg byte x [ assertType::t1#15 ]
|
||||
reg byte y [ assertType::t2#15 ]
|
||||
zp[1]:4 [ idx#42 idx#19 ]
|
||||
reg byte x [ assertType::t1#16 ]
|
||||
reg byte y [ assertType::t2#16 ]
|
||||
zp[1]:4 [ idx#44 idx#20 ]
|
||||
|
@ -1,12 +1,20 @@
|
||||
// Type mismatch - should fail gracefully
|
||||
.pc = $801 "Basic"
|
||||
// Commodore 64 PRG executable file
|
||||
.file [name="typemismatch.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$0801]
|
||||
.segmentdef Code [start=$80d]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.segment Code
|
||||
main: {
|
||||
.label screen = $400
|
||||
.const w = $1388
|
||||
.const b = $ff&w
|
||||
.label screen = $400
|
||||
// screen[0] = b
|
||||
lda #b
|
||||
sta screen
|
||||
// }
|
||||
rts
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user