mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-20 02:32:36 +00:00
Fixed type inference error message. Closes #260
This commit is contained in:
parent
c9a3f33773
commit
8d7b0385cb
@ -50,7 +50,7 @@ public class SymbolTypeInference {
|
||||
} else if(pointerType.equals(SymbolType.STRING)) {
|
||||
return SymbolType.BYTE;
|
||||
} else {
|
||||
throw new InternalError("Cannot infer pointer element type from pointer type " + pointerType);
|
||||
throw new CompileError("Cannot infer pointer element type from type: " + pointerType);
|
||||
}
|
||||
} else if(rValue instanceof ConstantArrayList) {
|
||||
return new SymbolTypeArray(((ConstantArrayList) rValue).getElementType());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.model.CompileError;
|
||||
import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.iterator.ProgramExpressionBinary;
|
||||
import dk.camelot64.kickc.model.iterator.ProgramExpressionIterator;
|
||||
@ -31,8 +32,14 @@ public class PassNAddTypeConversionAssignment extends Pass2SsaOptimization {
|
||||
ProgramExpressionBinary binary = (ProgramExpressionBinary) programExpression;
|
||||
RValue left = binary.getLeft();
|
||||
RValue right = binary.getRight();
|
||||
SymbolType leftType = SymbolTypeInference.inferType(getProgram().getScope(), left);
|
||||
SymbolType rightType = SymbolTypeInference.inferType(getProgram().getScope(), right);
|
||||
SymbolType leftType;
|
||||
SymbolType rightType;
|
||||
try {
|
||||
leftType = SymbolTypeInference.inferType(getProgram().getScope(), left);
|
||||
rightType = SymbolTypeInference.inferType(getProgram().getScope(), right);
|
||||
} catch(CompileError e) {
|
||||
throw new CompileError(e.getMessage(), currentStmt.getSource());
|
||||
}
|
||||
if(!SymbolTypeConversion.assignmentTypeMatch(leftType, rightType) || SymbolType.VAR.equals(rightType)) {
|
||||
// Assigning a pointer from an unsigned word
|
||||
if(programExpression instanceof ProgramExpressionBinary.ProgramExpressionBinaryAssignmentLValue || programExpression instanceof ProgramExpressionBinary.ProgramExpressionBinaryCallParameter) {
|
||||
@ -43,33 +50,33 @@ public class PassNAddTypeConversionAssignment extends Pass2SsaOptimization {
|
||||
modified.set(true);
|
||||
} else if((leftType instanceof SymbolTypePointer) && rightType instanceof SymbolTypePointer && SymbolType.VOID.equals(((SymbolTypePointer) leftType).getElementType())) {
|
||||
if(pass2 || getLog().isVerbosePass1CreateSsa())
|
||||
getLog().append("Adding void pointer type conversion cast (" + leftType + ") " + binary.getRight().toString() + " in " + currentStmt.toString(getProgram(), false));
|
||||
getLog().append("Adding void pointer type conversion cast (" + leftType + ") " + binary.getRight().toString() + " in " + currentStmt.toString(getProgram(), false));
|
||||
binary.addRightCast(leftType, stmtIt, currentBlock.getScope(), getScope());
|
||||
modified.set(true);
|
||||
} else if((leftType instanceof SymbolTypePointer) && rightType instanceof SymbolTypePointer && SymbolType.VOID.equals(((SymbolTypePointer) rightType).getElementType())) {
|
||||
if(pass2 || getLog().isVerbosePass1CreateSsa())
|
||||
getLog().append("Adding pointer type conversion cast to void pointer (" + leftType + ") " + binary.getRight().toString() + " in " + currentStmt.toString(getProgram(), false));
|
||||
getLog().append("Adding pointer type conversion cast to void pointer (" + leftType + ") " + binary.getRight().toString() + " in " + currentStmt.toString(getProgram(), false));
|
||||
binary.addRightCast(leftType, stmtIt, currentBlock.getScope(), getScope());
|
||||
modified.set(true);
|
||||
} else if(SymbolType.WORD.equals(leftType) && isLiteralWordCandidate(right)) {
|
||||
// Detect word literal constructor
|
||||
SymbolType conversionType = SymbolType.WORD;
|
||||
if(pass2 || getLog().isVerbosePass1CreateSsa())
|
||||
getLog().append("Identified literal word (" + conversionType + ") " + binary.getRight().toString() + " in " + (currentStmt == null ? "" : currentStmt.toString(getProgram(), false)));
|
||||
getLog().append("Identified literal word (" + conversionType + ") " + binary.getRight().toString() + " in " + (currentStmt == null ? "" : currentStmt.toString(getProgram(), false)));
|
||||
binary.addRightCast(conversionType, stmtIt, currentBlock == null ? null : currentBlock.getScope(), getScope());
|
||||
modified.set(true);
|
||||
} else if(leftType instanceof SymbolTypePointer && !(leftType instanceof SymbolTypeArray) && isLiteralWordCandidate(right)) {
|
||||
// Detect word literal constructor
|
||||
SymbolType conversionType = SymbolType.WORD;
|
||||
if(pass2 || getLog().isVerbosePass1CreateSsa())
|
||||
getLog().append("Identified literal word (" + conversionType + ") " + binary.getRight().toString() + " in " + (currentStmt == null ? "" : currentStmt.toString(getProgram(), false)));
|
||||
getLog().append("Identified literal word (" + conversionType + ") " + binary.getRight().toString() + " in " + (currentStmt == null ? "" : currentStmt.toString(getProgram(), false)));
|
||||
binary.addRightCast(conversionType, stmtIt, currentBlock == null ? null : currentBlock.getScope(), getScope());
|
||||
modified.set(true);
|
||||
} else if(SymbolType.DWORD.equals(leftType) && isLiteralWordCandidate(right)) {
|
||||
// Detect dword literal constructor
|
||||
SymbolType conversionType = SymbolType.DWORD;
|
||||
if(pass2 || getLog().isVerbosePass1CreateSsa())
|
||||
getLog().append("Identified literal word (" + conversionType + ") " + binary.getRight().toString() + " in " + (currentStmt == null ? "" : currentStmt.toString(getProgram(), false)));
|
||||
getLog().append("Identified literal word (" + conversionType + ") " + binary.getRight().toString() + " in " + (currentStmt == null ? "" : currentStmt.toString(getProgram(), false)));
|
||||
binary.addRightCast(conversionType, stmtIt, currentBlock == null ? null : currentBlock.getScope(), getScope());
|
||||
modified.set(true);
|
||||
}
|
||||
|
@ -41,6 +41,11 @@ public class TestPrograms {
|
||||
compileAndCompare("switch-0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastError() throws IOException, URISyntaxException {
|
||||
assertError("cast-error", "Cannot infer pointer element type from type");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineAsmParam() throws IOException, URISyntaxException {
|
||||
compileAndCompare("inline-asm-param");
|
||||
@ -580,6 +585,11 @@ public class TestPrograms {
|
||||
public void testStructError0() throws IOException, URISyntaxException {
|
||||
assertError("struct-err-0", "Unknown struct type");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStruct11() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-11");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStruct10() throws IOException, URISyntaxException {
|
||||
|
24
src/test/kc/struct-11.kc
Normal file
24
src/test/kc/struct-11.kc
Normal file
@ -0,0 +1,24 @@
|
||||
// Example of a struct containing an array
|
||||
|
||||
import "stdlib"
|
||||
import "print"
|
||||
|
||||
struct Person {
|
||||
unsigned long id;
|
||||
char[2] initials;
|
||||
};
|
||||
|
||||
struct Person jesper = { 111172, "jg" };
|
||||
struct Person henry = { 280173, "hg" };
|
||||
|
||||
void main() {
|
||||
print_person(jesper);
|
||||
print_person(henry);
|
||||
}
|
||||
|
||||
void print_person(struct Person person) {
|
||||
print_dword_decimal(person.id);
|
||||
print_char(' ');
|
||||
print_str(person.initials);
|
||||
print_ln();
|
||||
}
|
281
src/test/ref/struct-11.asm
Normal file
281
src/test/ref/struct-11.asm
Normal file
@ -0,0 +1,281 @@
|
||||
// Example of a struct containing an array
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.const jesper_id = $1b244
|
||||
.const henry_id = $4466d
|
||||
.label print_char_cursor = $a
|
||||
.label print_line_cursor = 8
|
||||
main: {
|
||||
lda #<$400
|
||||
sta.z print_line_cursor
|
||||
lda #>$400
|
||||
sta.z print_line_cursor+1
|
||||
lda #<jesper_initials
|
||||
sta.z print_person.person_initials
|
||||
lda #>jesper_initials
|
||||
sta.z print_person.person_initials+1
|
||||
lda #<$400
|
||||
sta.z print_char_cursor
|
||||
lda #>$400
|
||||
sta.z print_char_cursor+1
|
||||
lda #<jesper_id
|
||||
sta.z print_person.person_id
|
||||
lda #>jesper_id
|
||||
sta.z print_person.person_id+1
|
||||
lda #<jesper_id>>$10
|
||||
sta.z print_person.person_id+2
|
||||
lda #>jesper_id>>$10
|
||||
sta.z print_person.person_id+3
|
||||
jsr print_person
|
||||
lda.z print_line_cursor
|
||||
sta.z print_char_cursor
|
||||
lda.z print_line_cursor+1
|
||||
sta.z print_char_cursor+1
|
||||
lda #<henry_initials
|
||||
sta.z print_person.person_initials
|
||||
lda #>henry_initials
|
||||
sta.z print_person.person_initials+1
|
||||
lda #<henry_id
|
||||
sta.z print_person.person_id
|
||||
lda #>henry_id
|
||||
sta.z print_person.person_id+1
|
||||
lda #<henry_id>>$10
|
||||
sta.z print_person.person_id+2
|
||||
lda #>henry_id>>$10
|
||||
sta.z print_person.person_id+3
|
||||
jsr print_person
|
||||
rts
|
||||
}
|
||||
// print_person(dword zeropage(2) person_id, byte[2] zeropage(6) person_initials)
|
||||
print_person: {
|
||||
.label person_id = 2
|
||||
.label person_initials = 6
|
||||
jsr print_dword_decimal
|
||||
jsr print_char
|
||||
lda.z person_initials
|
||||
sta.z print_str.str
|
||||
lda.z person_initials+1
|
||||
sta.z print_str.str+1
|
||||
jsr print_str
|
||||
jsr print_ln
|
||||
rts
|
||||
}
|
||||
// Print a newline
|
||||
print_ln: {
|
||||
b1:
|
||||
lda #$28
|
||||
clc
|
||||
adc.z print_line_cursor
|
||||
sta.z print_line_cursor
|
||||
bcc !+
|
||||
inc.z print_line_cursor+1
|
||||
!:
|
||||
lda.z print_line_cursor+1
|
||||
cmp.z print_char_cursor+1
|
||||
bcc b1
|
||||
bne !+
|
||||
lda.z print_line_cursor
|
||||
cmp.z print_char_cursor
|
||||
bcc b1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
// Print a zero-terminated string
|
||||
// print_str(byte* zeropage($d) str)
|
||||
print_str: {
|
||||
.label str = $d
|
||||
b1:
|
||||
ldy #0
|
||||
lda (str),y
|
||||
cmp #0
|
||||
bne b2
|
||||
rts
|
||||
b2:
|
||||
ldy #0
|
||||
lda (str),y
|
||||
sta (print_char_cursor),y
|
||||
inc.z print_char_cursor
|
||||
bne !+
|
||||
inc.z print_char_cursor+1
|
||||
!:
|
||||
inc.z str
|
||||
bne !+
|
||||
inc.z str+1
|
||||
!:
|
||||
jmp b1
|
||||
}
|
||||
// Print a single char
|
||||
print_char: {
|
||||
.const ch = ' '
|
||||
lda #ch
|
||||
ldy #0
|
||||
sta (print_char_cursor),y
|
||||
inc.z print_char_cursor
|
||||
bne !+
|
||||
inc.z print_char_cursor+1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
// Print a dword as DECIMAL
|
||||
// print_dword_decimal(dword zeropage(2) w)
|
||||
print_dword_decimal: {
|
||||
.label w = 2
|
||||
jsr ultoa
|
||||
lda #<decimal_digits_long
|
||||
sta.z print_str.str
|
||||
lda #>decimal_digits_long
|
||||
sta.z print_str.str+1
|
||||
jsr print_str
|
||||
rts
|
||||
}
|
||||
// Converts unsigned number value to a string representing it in RADIX format.
|
||||
// If the leading digits are zero they are not included in the string.
|
||||
// - value : The number to be converted to RADIX
|
||||
// - buffer : receives the string representing the number and zero-termination.
|
||||
// - radix : The radix to convert the number to (from the enum RADIX)
|
||||
// ultoa(dword zeropage(2) value, byte* zeropage($d) buffer)
|
||||
ultoa: {
|
||||
.const max_digits = $a
|
||||
.label digit_value = $f
|
||||
.label buffer = $d
|
||||
.label digit = $c
|
||||
.label value = 2
|
||||
lda RADIX_DECIMAL_VALUES_LONG
|
||||
sta.z digit_value
|
||||
lda RADIX_DECIMAL_VALUES_LONG+1
|
||||
sta.z digit_value+1
|
||||
lda RADIX_DECIMAL_VALUES_LONG+2
|
||||
sta.z digit_value+2
|
||||
lda RADIX_DECIMAL_VALUES_LONG+3
|
||||
sta.z digit_value+3
|
||||
lda #<decimal_digits_long
|
||||
sta.z buffer
|
||||
lda #>decimal_digits_long
|
||||
sta.z buffer+1
|
||||
ldx #0
|
||||
txa
|
||||
sta.z digit
|
||||
b7:
|
||||
lda.z value+3
|
||||
cmp.z digit_value+3
|
||||
bcc !+
|
||||
bne b5
|
||||
lda.z value+2
|
||||
cmp.z digit_value+2
|
||||
bcc !+
|
||||
bne b5
|
||||
lda.z value+1
|
||||
cmp.z digit_value+1
|
||||
bcc !+
|
||||
bne b5
|
||||
lda.z value
|
||||
cmp.z digit_value
|
||||
bcs b5
|
||||
!:
|
||||
b4:
|
||||
inc.z digit
|
||||
lda.z digit
|
||||
cmp #max_digits-1
|
||||
bcc b2
|
||||
lda.z value
|
||||
tay
|
||||
lda DIGITS,y
|
||||
ldy #0
|
||||
sta (buffer),y
|
||||
inc.z buffer
|
||||
bne !+
|
||||
inc.z buffer+1
|
||||
!:
|
||||
lda #0
|
||||
tay
|
||||
sta (buffer),y
|
||||
rts
|
||||
b2:
|
||||
lda.z digit
|
||||
asl
|
||||
asl
|
||||
tay
|
||||
lda RADIX_DECIMAL_VALUES_LONG,y
|
||||
sta.z digit_value
|
||||
lda RADIX_DECIMAL_VALUES_LONG+1,y
|
||||
sta.z digit_value+1
|
||||
lda RADIX_DECIMAL_VALUES_LONG+2,y
|
||||
sta.z digit_value+2
|
||||
lda RADIX_DECIMAL_VALUES_LONG+3,y
|
||||
sta.z digit_value+3
|
||||
cpx #0
|
||||
bne b5
|
||||
jmp b7
|
||||
b5:
|
||||
jsr ultoa_append
|
||||
inc.z buffer
|
||||
bne !+
|
||||
inc.z buffer+1
|
||||
!:
|
||||
ldx #1
|
||||
jmp b4
|
||||
}
|
||||
// Used to convert a single digit of an unsigned number value to a string representation
|
||||
// Counts a single digit up from '0' as long as the value is larger than sub.
|
||||
// Each time the digit is increased sub is subtracted from value.
|
||||
// - buffer : pointer to the char that receives the digit
|
||||
// - value : The value where the digit will be derived from
|
||||
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
|
||||
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
|
||||
// returns : the value reduced by sub * digit so that it is less than sub.
|
||||
// ultoa_append(byte* zeropage($d) buffer, dword zeropage(2) value, dword zeropage($f) sub)
|
||||
ultoa_append: {
|
||||
.label buffer = $d
|
||||
.label value = 2
|
||||
.label sub = $f
|
||||
.label return = 2
|
||||
ldx #0
|
||||
b1:
|
||||
lda.z value+3
|
||||
cmp.z sub+3
|
||||
bcc !+
|
||||
bne b2
|
||||
lda.z value+2
|
||||
cmp.z sub+2
|
||||
bcc !+
|
||||
bne b2
|
||||
lda.z value+1
|
||||
cmp.z sub+1
|
||||
bcc !+
|
||||
bne b2
|
||||
lda.z value
|
||||
cmp.z sub
|
||||
bcs b2
|
||||
!:
|
||||
lda DIGITS,x
|
||||
ldy #0
|
||||
sta (buffer),y
|
||||
rts
|
||||
b2:
|
||||
inx
|
||||
lda.z value
|
||||
sec
|
||||
sbc.z sub
|
||||
sta.z value
|
||||
lda.z value+1
|
||||
sbc.z sub+1
|
||||
sta.z value+1
|
||||
lda.z value+2
|
||||
sbc.z sub+2
|
||||
sta.z value+2
|
||||
lda.z value+3
|
||||
sbc.z sub+3
|
||||
sta.z value+3
|
||||
jmp b1
|
||||
}
|
||||
// The digits used for numbers
|
||||
DIGITS: .text "0123456789abcdef"
|
||||
// Values of decimal digits
|
||||
RADIX_DECIMAL_VALUES_LONG: .dword $3b9aca00, $5f5e100, $989680, $f4240, $186a0, $2710, $3e8, $64, $a
|
||||
// Digits used for storing the decimal word
|
||||
decimal_digits_long: .fill $b, 0
|
||||
jesper_initials: .text "jg"
|
||||
.byte 0
|
||||
henry_initials: .text "hg"
|
||||
.byte 0
|
160
src/test/ref/struct-11.cfg
Normal file
160
src/test/ref/struct-11.cfg
Normal file
@ -0,0 +1,160 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
[5] call print_person
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[6] (byte*~) print_char_cursor#49 ← (byte*) print_line_cursor#1
|
||||
[7] call print_person
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[8] return
|
||||
to:@return
|
||||
print_person: scope:[print_person] from main main::@1
|
||||
[9] (byte*) print_line_cursor#20 ← phi( main/(byte*) 1024 main::@1/(byte*) print_line_cursor#1 )
|
||||
[9] (byte[2]) print_person::person_initials#2 ← phi( main/(const byte[2]) jesper_initials#0 main::@1/(const byte[2]) henry_initials#0 )
|
||||
[9] (byte*) print_char_cursor#39 ← phi( main/(byte*) 1024 main::@1/(byte*~) print_char_cursor#49 )
|
||||
[9] (dword) print_person::person_id#2 ← phi( main/(const dword) jesper_id#0 main::@1/(const dword) henry_id#0 )
|
||||
[10] (dword) print_dword_decimal::w#0 ← (dword) print_person::person_id#2
|
||||
[11] call print_dword_decimal
|
||||
to:print_person::@1
|
||||
print_person::@1: scope:[print_person] from print_person
|
||||
[12] phi()
|
||||
[13] call print_char
|
||||
to:print_person::@2
|
||||
print_person::@2: scope:[print_person] from print_person::@1
|
||||
[14] (byte*) print_str::str#2 ← (byte[2]) print_person::person_initials#2
|
||||
[15] call print_str
|
||||
to:print_person::@3
|
||||
print_person::@3: scope:[print_person] from print_person::@2
|
||||
[16] phi()
|
||||
[17] call print_ln
|
||||
to:print_person::@return
|
||||
print_person::@return: scope:[print_person] from print_person::@3
|
||||
[18] return
|
||||
to:@return
|
||||
print_ln: scope:[print_ln] from print_person::@3
|
||||
[19] phi()
|
||||
to:print_ln::@1
|
||||
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
||||
[20] (byte*) print_line_cursor#9 ← phi( print_ln/(byte*) print_line_cursor#20 print_ln::@1/(byte*) print_line_cursor#1 )
|
||||
[21] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#9 + (byte) $28
|
||||
[22] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#18) goto print_ln::@1
|
||||
to:print_ln::@return
|
||||
print_ln::@return: scope:[print_ln] from print_ln::@1
|
||||
[23] return
|
||||
to:@return
|
||||
print_str: scope:[print_str] from print_dword_decimal::@1 print_person::@2
|
||||
[24] (byte*) print_char_cursor#41 ← phi( print_dword_decimal::@1/(byte*) print_char_cursor#39 print_person::@2/(byte*) print_char_cursor#25 )
|
||||
[24] (byte*) print_str::str#5 ← phi( print_dword_decimal::@1/(const byte[$b]) decimal_digits_long#0 print_person::@2/(byte*) print_str::str#2 )
|
||||
to:print_str::@1
|
||||
print_str::@1: scope:[print_str] from print_str print_str::@2
|
||||
[25] (byte*) print_char_cursor#18 ← phi( print_str/(byte*) print_char_cursor#41 print_str::@2/(byte*) print_char_cursor#1 )
|
||||
[25] (byte*) print_str::str#3 ← phi( print_str/(byte*) print_str::str#5 print_str::@2/(byte*) print_str::str#0 )
|
||||
[26] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2
|
||||
to:print_str::@return
|
||||
print_str::@return: scope:[print_str] from print_str::@1
|
||||
[27] return
|
||||
to:@return
|
||||
print_str::@2: scope:[print_str] from print_str::@1
|
||||
[28] *((byte*) print_char_cursor#18) ← *((byte*) print_str::str#3)
|
||||
[29] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#18
|
||||
[30] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#3
|
||||
to:print_str::@1
|
||||
print_char: scope:[print_char] from print_person::@1
|
||||
[31] *((byte*) print_char_cursor#18) ← (const byte) print_char::ch#0
|
||||
[32] (byte*) print_char_cursor#25 ← ++ (byte*) print_char_cursor#18
|
||||
to:print_char::@return
|
||||
print_char::@return: scope:[print_char] from print_char
|
||||
[33] return
|
||||
to:@return
|
||||
print_dword_decimal: scope:[print_dword_decimal] from print_person
|
||||
[34] (dword) ultoa::value#1 ← (dword) print_dword_decimal::w#0
|
||||
[35] call ultoa
|
||||
to:print_dword_decimal::@1
|
||||
print_dword_decimal::@1: scope:[print_dword_decimal] from print_dword_decimal
|
||||
[36] phi()
|
||||
[37] call print_str
|
||||
to:print_dword_decimal::@return
|
||||
print_dword_decimal::@return: scope:[print_dword_decimal] from print_dword_decimal::@1
|
||||
[38] return
|
||||
to:@return
|
||||
ultoa: scope:[ultoa] from print_dword_decimal
|
||||
[39] phi()
|
||||
to:ultoa::@19_1
|
||||
ultoa::@19_1: scope:[ultoa] from ultoa
|
||||
[40] (dword) ultoa::digit_value#4 ← *((const dword[]) RADIX_DECIMAL_VALUES_LONG#0)
|
||||
to:ultoa::@7
|
||||
ultoa::@7: scope:[ultoa] from ultoa::@19_1 ultoa::@2
|
||||
[41] (dword) ultoa::digit_value#3 ← phi( ultoa::@2/(dword) ultoa::digit_value#0 ultoa::@19_1/(dword) ultoa::digit_value#4 )
|
||||
[41] (byte*) ultoa::buffer#28 ← phi( ultoa::@2/(byte*) ultoa::buffer#11 ultoa::@19_1/(const byte[$b]) decimal_digits_long#0 )
|
||||
[41] (byte) ultoa::started#8 ← phi( ultoa::@2/(byte) ultoa::started#2 ultoa::@19_1/(byte) 0 )
|
||||
[41] (dword) ultoa::value#21 ← phi( ultoa::@2/(dword) ultoa::value#16 ultoa::@19_1/(dword) ultoa::value#1 )
|
||||
[41] (byte) ultoa::digit#15 ← phi( ultoa::@2/(byte) ultoa::digit#1 ultoa::@19_1/(byte) 0 )
|
||||
[42] if((dword) ultoa::value#21>=(dword) ultoa::digit_value#3) goto ultoa::@5
|
||||
to:ultoa::@4
|
||||
ultoa::@4: scope:[ultoa] from ultoa::@6 ultoa::@7
|
||||
[43] (byte) ultoa::digit#13 ← phi( ultoa::@6/(byte) ultoa::digit#14 ultoa::@7/(byte) ultoa::digit#15 )
|
||||
[43] (byte*) ultoa::buffer#11 ← phi( ultoa::@7/(byte*) ultoa::buffer#28 ultoa::@6/(byte*) ultoa::buffer#4 )
|
||||
[43] (byte) ultoa::started#2 ← phi( ultoa::@7/(byte) ultoa::started#8 ultoa::@6/(byte) 1 )
|
||||
[43] (dword) ultoa::value#16 ← phi( ultoa::@7/(dword) ultoa::value#21 ultoa::@6/(dword) ultoa::value#0 )
|
||||
[44] (byte) ultoa::digit#1 ← ++ (byte) ultoa::digit#13
|
||||
to:ultoa::@1
|
||||
ultoa::@1: scope:[ultoa] from ultoa::@4
|
||||
[45] if((byte) ultoa::digit#1<(const byte) ultoa::max_digits#1-(byte) 1) goto ultoa::@2
|
||||
to:ultoa::@3
|
||||
ultoa::@3: scope:[ultoa] from ultoa::@1
|
||||
[46] (byte~) ultoa::$4 ← (byte)(dword) ultoa::value#16
|
||||
[47] *((byte*) ultoa::buffer#11) ← *((const byte[]) DIGITS#0 + (byte~) ultoa::$4)
|
||||
[48] (byte*) ultoa::buffer#3 ← ++ (byte*) ultoa::buffer#11
|
||||
[49] *((byte*) ultoa::buffer#3) ← (byte) 0
|
||||
to:ultoa::@return
|
||||
ultoa::@return: scope:[ultoa] from ultoa::@3
|
||||
[50] return
|
||||
to:@return
|
||||
ultoa::@2: scope:[ultoa] from ultoa::@1
|
||||
[51] (byte~) ultoa::$11 ← (byte) ultoa::digit#1 << (byte) 2
|
||||
[52] (dword) ultoa::digit_value#0 ← *((const dword[]) RADIX_DECIMAL_VALUES_LONG#0 + (byte~) ultoa::$11)
|
||||
[53] if((byte) 0!=(byte) ultoa::started#2) goto ultoa::@5
|
||||
to:ultoa::@7
|
||||
ultoa::@5: scope:[ultoa] from ultoa::@2 ultoa::@7
|
||||
[54] (dword) ultoa::digit_value#2 ← phi( ultoa::@2/(dword) ultoa::digit_value#0 ultoa::@7/(dword) ultoa::digit_value#3 )
|
||||
[54] (byte*) ultoa::buffer#29 ← phi( ultoa::@2/(byte*) ultoa::buffer#11 ultoa::@7/(byte*) ultoa::buffer#28 )
|
||||
[54] (dword) ultoa::value#22 ← phi( ultoa::@2/(dword) ultoa::value#16 ultoa::@7/(dword) ultoa::value#21 )
|
||||
[54] (byte) ultoa::digit#14 ← phi( ultoa::@2/(byte) ultoa::digit#1 ultoa::@7/(byte) ultoa::digit#15 )
|
||||
[55] (byte*) ultoa_append::buffer#0 ← (byte*) ultoa::buffer#29
|
||||
[56] (dword) ultoa_append::value#0 ← (dword) ultoa::value#22
|
||||
[57] (dword) ultoa_append::sub#0 ← (dword) ultoa::digit_value#2
|
||||
[58] call ultoa_append
|
||||
[59] (dword) ultoa_append::return#0 ← (dword) ultoa_append::value#2
|
||||
to:ultoa::@6
|
||||
ultoa::@6: scope:[ultoa] from ultoa::@5
|
||||
[60] (dword) ultoa::value#0 ← (dword) ultoa_append::return#0
|
||||
[61] (byte*) ultoa::buffer#4 ← ++ (byte*) ultoa::buffer#29
|
||||
to:ultoa::@4
|
||||
ultoa_append: scope:[ultoa_append] from ultoa::@5
|
||||
[62] phi()
|
||||
to:ultoa_append::@1
|
||||
ultoa_append::@1: scope:[ultoa_append] from ultoa_append ultoa_append::@2
|
||||
[63] (byte) ultoa_append::digit#2 ← phi( ultoa_append/(byte) 0 ultoa_append::@2/(byte) ultoa_append::digit#1 )
|
||||
[63] (dword) ultoa_append::value#2 ← phi( ultoa_append/(dword) ultoa_append::value#0 ultoa_append::@2/(dword) ultoa_append::value#1 )
|
||||
[64] if((dword) ultoa_append::value#2>=(dword) ultoa_append::sub#0) goto ultoa_append::@2
|
||||
to:ultoa_append::@3
|
||||
ultoa_append::@3: scope:[ultoa_append] from ultoa_append::@1
|
||||
[65] *((byte*) ultoa_append::buffer#0) ← *((const byte[]) DIGITS#0 + (byte) ultoa_append::digit#2)
|
||||
to:ultoa_append::@return
|
||||
ultoa_append::@return: scope:[ultoa_append] from ultoa_append::@3
|
||||
[66] return
|
||||
to:@return
|
||||
ultoa_append::@2: scope:[ultoa_append] from ultoa_append::@1
|
||||
[67] (byte) ultoa_append::digit#1 ← ++ (byte) ultoa_append::digit#2
|
||||
[68] (dword) ultoa_append::value#1 ← (dword) ultoa_append::value#2 - (dword) ultoa_append::sub#0
|
||||
to:ultoa_append::@1
|
3534
src/test/ref/struct-11.log
Normal file
3534
src/test/ref/struct-11.log
Normal file
File diff suppressed because it is too large
Load Diff
143
src/test/ref/struct-11.sym
Normal file
143
src/test/ref/struct-11.sym
Normal file
@ -0,0 +1,143 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte[]) DIGITS
|
||||
(const byte[]) DIGITS#0 DIGITS = (string) "0123456789abcdef"z
|
||||
(dword) Person::id
|
||||
(byte[2]) Person::initials
|
||||
(const byte) RADIX::BINARY BINARY = (number) 2
|
||||
(const byte) RADIX::DECIMAL DECIMAL = (number) $a
|
||||
(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10
|
||||
(const byte) RADIX::OCTAL OCTAL = (number) 8
|
||||
(dword[]) RADIX_BINARY_VALUES_LONG
|
||||
(dword[]) RADIX_DECIMAL_VALUES_LONG
|
||||
(const dword[]) RADIX_DECIMAL_VALUES_LONG#0 RADIX_DECIMAL_VALUES_LONG = { (dword) $3b9aca00, (dword) $5f5e100, (dword) $989680, (dword) $f4240, (dword) $186a0, (dword) $2710, (dword) $3e8, (dword) $64, (dword) $a }
|
||||
(dword[]) RADIX_HEXADECIMAL_VALUES_LONG
|
||||
(dword[]) RADIX_OCTAL_VALUES_LONG
|
||||
(byte[$b]) decimal_digits_long
|
||||
(const byte[$b]) decimal_digits_long#0 decimal_digits_long = { fill( $b, 0) }
|
||||
(dword) henry_id
|
||||
(const dword) henry_id#0 henry_id = (dword) $4466d
|
||||
(byte[2]) henry_initials
|
||||
(const byte[2]) henry_initials#0 henry_initials = (string) "hg"
|
||||
(dword) jesper_id
|
||||
(const dword) jesper_id#0 jesper_id = (dword) $1b244
|
||||
(byte[2]) jesper_initials
|
||||
(const byte[2]) jesper_initials#0 jesper_initials = (string) "jg"
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(void()) print_char((byte) print_char::ch)
|
||||
(label) print_char::@return
|
||||
(byte) print_char::ch
|
||||
(const byte) print_char::ch#0 ch = (byte) ' '
|
||||
(byte*) print_char_cursor
|
||||
(byte*) print_char_cursor#1 print_char_cursor zp ZP_WORD:10 11.0
|
||||
(byte*) print_char_cursor#18 print_char_cursor zp ZP_WORD:10 3.333333333333333
|
||||
(byte*) print_char_cursor#25 print_char_cursor zp ZP_WORD:10 1.0
|
||||
(byte*) print_char_cursor#39 print_char_cursor zp ZP_WORD:10 0.8
|
||||
(byte*) print_char_cursor#41 print_char_cursor zp ZP_WORD:10 6.0
|
||||
(byte*~) print_char_cursor#49 print_char_cursor zp ZP_WORD:10 4.0
|
||||
(void()) print_dword_decimal((dword) print_dword_decimal::w)
|
||||
(label) print_dword_decimal::@1
|
||||
(label) print_dword_decimal::@return
|
||||
(dword) print_dword_decimal::w
|
||||
(dword) print_dword_decimal::w#0 w zp ZP_DWORD:2 4.0
|
||||
(byte*) print_line_cursor
|
||||
(byte*) print_line_cursor#1 print_line_cursor zp ZP_WORD:8 5.285714285714286
|
||||
(byte*) print_line_cursor#20 print_line_cursor zp ZP_WORD:8 0.4444444444444444
|
||||
(byte*) print_line_cursor#9 print_line_cursor zp ZP_WORD:8 24.0
|
||||
(void()) print_ln()
|
||||
(label) print_ln::@1
|
||||
(label) print_ln::@return
|
||||
(void()) print_person((dword) print_person::person_id , (byte[2]) print_person::person_initials)
|
||||
(label) print_person::@1
|
||||
(label) print_person::@2
|
||||
(label) print_person::@3
|
||||
(label) print_person::@return
|
||||
(struct Person) print_person::person
|
||||
(dword) print_person::person_id
|
||||
(dword) print_person::person_id#2 person_id zp ZP_DWORD:2 2.0
|
||||
(byte[2]) print_person::person_initials
|
||||
(byte[2]) print_person::person_initials#2 person_initials zp ZP_WORD:6 0.4
|
||||
(byte*) print_screen
|
||||
(void()) print_str((byte*) print_str::str)
|
||||
(label) print_str::@1
|
||||
(label) print_str::@2
|
||||
(label) print_str::@return
|
||||
(byte*) print_str::str
|
||||
(byte*) print_str::str#0 str zp ZP_WORD:13 22.0
|
||||
(byte*) print_str::str#2 str zp ZP_WORD:13 4.0
|
||||
(byte*) print_str::str#3 str zp ZP_WORD:13 11.5
|
||||
(byte*) print_str::str#5 str zp ZP_WORD:13 4.0
|
||||
(void()) ultoa((dword) ultoa::value , (byte*) ultoa::buffer , (byte) ultoa::radix)
|
||||
(byte~) ultoa::$11 reg byte a 22.0
|
||||
(byte~) ultoa::$4 reg byte a 4.0
|
||||
(label) ultoa::@1
|
||||
(label) ultoa::@19_1
|
||||
(label) ultoa::@2
|
||||
(label) ultoa::@3
|
||||
(label) ultoa::@4
|
||||
(label) ultoa::@5
|
||||
(label) ultoa::@6
|
||||
(label) ultoa::@7
|
||||
(label) ultoa::@return
|
||||
(byte*) ultoa::buffer
|
||||
(byte*) ultoa::buffer#11 buffer zp ZP_WORD:13 6.0
|
||||
(byte*) ultoa::buffer#28 buffer zp ZP_WORD:13 16.5
|
||||
(byte*) ultoa::buffer#29 buffer zp ZP_WORD:13 6.285714285714286
|
||||
(byte*) ultoa::buffer#3 buffer zp ZP_WORD:13 4.0
|
||||
(byte*) ultoa::buffer#4 buffer zp ZP_WORD:13 22.0
|
||||
(byte) ultoa::digit
|
||||
(byte) ultoa::digit#1 digit zp ZP_BYTE:12 11.0
|
||||
(byte) ultoa::digit#13 digit zp ZP_BYTE:12 33.0
|
||||
(byte) ultoa::digit#14 digit zp ZP_BYTE:12 4.125
|
||||
(byte) ultoa::digit#15 digit zp ZP_BYTE:12 16.5
|
||||
(dword) ultoa::digit_value
|
||||
(dword) ultoa::digit_value#0 digit_value zp ZP_DWORD:15 16.5
|
||||
(dword) ultoa::digit_value#2 digit_value zp ZP_DWORD:15 11.0
|
||||
(dword) ultoa::digit_value#3 digit_value zp ZP_DWORD:15 17.5
|
||||
(dword) ultoa::digit_value#4 digit_value zp ZP_DWORD:15 4.0
|
||||
(dword*) ultoa::digit_values
|
||||
(byte) ultoa::max_digits
|
||||
(const byte) ultoa::max_digits#1 max_digits = (byte) $a
|
||||
(byte) ultoa::radix
|
||||
(byte) ultoa::started
|
||||
(byte) ultoa::started#2 reg byte x 5.5
|
||||
(byte) ultoa::started#8 reg byte x 11.0
|
||||
(dword) ultoa::value
|
||||
(dword) ultoa::value#0 value zp ZP_DWORD:2 11.0
|
||||
(dword) ultoa::value#1 value zp ZP_DWORD:2 1.3333333333333333
|
||||
(dword) ultoa::value#16 value zp ZP_DWORD:2 7.333333333333333
|
||||
(dword) ultoa::value#21 value zp ZP_DWORD:2 23.0
|
||||
(dword) ultoa::value#22 value zp ZP_DWORD:2 16.5
|
||||
(dword()) ultoa_append((byte*) ultoa_append::buffer , (dword) ultoa_append::value , (dword) ultoa_append::sub)
|
||||
(label) ultoa_append::@1
|
||||
(label) ultoa_append::@2
|
||||
(label) ultoa_append::@3
|
||||
(label) ultoa_append::@return
|
||||
(byte*) ultoa_append::buffer
|
||||
(byte*) ultoa_append::buffer#0 buffer zp ZP_WORD:13 1.625
|
||||
(byte) ultoa_append::digit
|
||||
(byte) ultoa_append::digit#1 reg byte x 101.0
|
||||
(byte) ultoa_append::digit#2 reg byte x 102.0
|
||||
(dword) ultoa_append::return
|
||||
(dword) ultoa_append::return#0 return zp ZP_DWORD:2 22.0
|
||||
(dword) ultoa_append::sub
|
||||
(dword) ultoa_append::sub#0 sub zp ZP_DWORD:15 35.5
|
||||
(dword) ultoa_append::value
|
||||
(dword) ultoa_append::value#0 value zp ZP_DWORD:2 4.333333333333333
|
||||
(dword) ultoa_append::value#1 value zp ZP_DWORD:2 202.0
|
||||
(dword) ultoa_append::value#2 value zp ZP_DWORD:2 52.66666666666666
|
||||
|
||||
zp ZP_DWORD:2 [ print_person::person_id#2 print_dword_decimal::w#0 ultoa::value#22 ultoa::value#21 ultoa::value#16 ultoa::value#1 ultoa::value#0 ultoa_append::value#2 ultoa_append::value#0 ultoa_append::value#1 ultoa_append::return#0 ]
|
||||
zp ZP_WORD:6 [ print_person::person_initials#2 ]
|
||||
zp ZP_WORD:8 [ print_line_cursor#9 print_line_cursor#20 print_line_cursor#1 ]
|
||||
zp ZP_WORD:10 [ print_char_cursor#18 print_char_cursor#41 print_char_cursor#39 print_char_cursor#49 print_char_cursor#25 print_char_cursor#1 ]
|
||||
reg byte x [ ultoa::started#8 ultoa::started#2 ]
|
||||
zp ZP_BYTE:12 [ ultoa::digit#13 ultoa::digit#14 ultoa::digit#15 ultoa::digit#1 ]
|
||||
zp ZP_WORD:13 [ ultoa::buffer#29 ultoa::buffer#28 ultoa::buffer#11 ultoa::buffer#4 ultoa::buffer#3 ultoa_append::buffer#0 print_str::str#3 print_str::str#5 print_str::str#2 print_str::str#0 ]
|
||||
zp ZP_DWORD:15 [ ultoa::digit_value#2 ultoa::digit_value#3 ultoa::digit_value#0 ultoa::digit_value#4 ultoa_append::sub#0 ]
|
||||
reg byte x [ ultoa_append::digit#2 ultoa_append::digit#1 ]
|
||||
reg byte a [ ultoa::$4 ]
|
||||
reg byte a [ ultoa::$11 ]
|
Loading…
Reference in New Issue
Block a user