mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-23 13:31:12 +00:00
Fixed problem where SymbolTypeInference gave error messages without any line number - by removing all error messages - and leaving the responsibility with the caller.
This commit is contained in:
parent
ce8e34b16a
commit
8c27abb7e0
2162
src/main/fragment/cache/fragment-cache-csg65ce02.asm
vendored
2162
src/main/fragment/cache/fragment-cache-csg65ce02.asm
vendored
File diff suppressed because it is too large
Load Diff
6103
src/main/fragment/cache/fragment-cache-mos6502x.asm
vendored
6103
src/main/fragment/cache/fragment-cache-mos6502x.asm
vendored
File diff suppressed because it is too large
Load Diff
398
src/main/fragment/cache/fragment-cache-rom6502x.asm
vendored
398
src/main/fragment/cache/fragment-cache-rom6502x.asm
vendored
@ -792,3 +792,401 @@ iny
|
||||
tax
|
||||
//FRAGMENT vbuyy=vbuaa
|
||||
tay
|
||||
//FRAGMENT vbuz1=vbuz2_band_vbuc1
|
||||
lda #{c1}
|
||||
and {z2}
|
||||
sta {z1}
|
||||
//FRAGMENT _deref_pbuc1=_dec__deref_pbuc1
|
||||
dec {c1}
|
||||
//FRAGMENT pbuz1=pbuc1_plus_vbuz2
|
||||
lda {z2}
|
||||
clc
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda #>{c1}
|
||||
adc #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT pvoz1=pvoz2
|
||||
lda {z2}
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
sta {z1}+1
|
||||
//FRAGMENT vbuz1=vbuz1_plus_2
|
||||
lda {z1}
|
||||
clc
|
||||
adc #2
|
||||
sta {z1}
|
||||
//FRAGMENT vbuz1=pbuz2_derefidx_vbuc1
|
||||
ldy #{c1}
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
//FRAGMENT pbuz1=pbuz2_plus_vbuc1
|
||||
lda #{c1}
|
||||
clc
|
||||
adc {z2}
|
||||
sta {z1}
|
||||
lda #0
|
||||
adc {z2}+1
|
||||
sta {z1}+1
|
||||
//FRAGMENT pbuz1_neq_pbuc1_then_la1
|
||||
lda {z1}+1
|
||||
cmp #>{c1}
|
||||
bne {la1}
|
||||
lda {z1}
|
||||
cmp #<{c1}
|
||||
bne {la1}
|
||||
//FRAGMENT _deref_pbuz1=_deref_pbuz2
|
||||
ldy #0
|
||||
lda ({z2}),y
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT vbuz1=vbuaa_band_vbuc1
|
||||
and #{c1}
|
||||
sta {z1}
|
||||
//FRAGMENT vbuz1=vbuxx_band_vbuc1
|
||||
lda #{c1}
|
||||
sax {z1}
|
||||
//FRAGMENT vbuz1=vbuyy_band_vbuc1
|
||||
tya
|
||||
and #{c1}
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=vbuz1_band_vbuc1
|
||||
lda #{c1}
|
||||
and {z1}
|
||||
//FRAGMENT vbuaa=vbuaa_band_vbuc1
|
||||
and #{c1}
|
||||
//FRAGMENT vbuaa=vbuxx_band_vbuc1
|
||||
txa
|
||||
and #{c1}
|
||||
//FRAGMENT vbuaa=vbuyy_band_vbuc1
|
||||
tya
|
||||
and #{c1}
|
||||
//FRAGMENT vbuxx=vbuz1_band_vbuc1
|
||||
lda #{c1}
|
||||
and {z1}
|
||||
tax
|
||||
//FRAGMENT vbuxx=vbuaa_band_vbuc1
|
||||
ldx #{c1}
|
||||
axs #0
|
||||
//FRAGMENT vbuyy=vbuz1_band_vbuc1
|
||||
lda #{c1}
|
||||
and {z1}
|
||||
tay
|
||||
//FRAGMENT pbuz1=pbuc1_plus_vbuaa
|
||||
clc
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda #>{c1}
|
||||
adc #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT pbuz1=pbuc1_plus_vbuxx
|
||||
txa
|
||||
clc
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda #>{c1}
|
||||
adc #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT pbuz1=pbuc1_plus_vbuyy
|
||||
tya
|
||||
clc
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda #>{c1}
|
||||
adc #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT vbuxx=vbuxx_plus_2
|
||||
inx
|
||||
inx
|
||||
//FRAGMENT vbuaa=pbuz1_derefidx_vbuc1
|
||||
ldy #{c1}
|
||||
lda ({z1}),y
|
||||
//FRAGMENT vbuxx=pbuz1_derefidx_vbuc1
|
||||
ldy #{c1}
|
||||
lda ({z1}),y
|
||||
tax
|
||||
//FRAGMENT vbuyy=pbuz1_derefidx_vbuc1
|
||||
ldy #{c1}
|
||||
lda ({z1}),y
|
||||
tay
|
||||
//FRAGMENT pbuz1=pbuz1_plus_vbuc1
|
||||
lda #{c1}
|
||||
clc
|
||||
adc {z1}
|
||||
sta {z1}
|
||||
bcc !+
|
||||
inc {z1}+1
|
||||
!:
|
||||
//FRAGMENT vbuz1=_dec_vbuz1
|
||||
dec {z1}
|
||||
//FRAGMENT pbuz1=pbuz2
|
||||
lda {z2}
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
sta {z1}+1
|
||||
//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuz2
|
||||
ldy {z2}
|
||||
lda {c1},y
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT pbuz1=_inc_pbuz2
|
||||
clc
|
||||
lda {z2}
|
||||
adc #1
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
adc #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT _deref_pbuz1=vbuc1
|
||||
lda #{c1}
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2
|
||||
ldy {z2}
|
||||
lda {c1},y
|
||||
sta {z1}
|
||||
//FRAGMENT vbuz1_ge_vbuz2_then_la1
|
||||
lda {z1}
|
||||
cmp {z2}
|
||||
bcs {la1}
|
||||
//FRAGMENT vbuz1=vbuz1_minus_vbuz2
|
||||
lda {z1}
|
||||
sec
|
||||
sbc {z2}
|
||||
sta {z1}
|
||||
//FRAGMENT vwuz1=_word_vbuz2
|
||||
lda {z2}
|
||||
sta {z1}
|
||||
lda #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT vwuz1=vwuz2_rol_5
|
||||
lda {z2}
|
||||
asl
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
rol
|
||||
sta {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
//FRAGMENT pbuz1=pbuc1_plus_vwuz2
|
||||
lda {z2}
|
||||
clc
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
adc #>{c1}
|
||||
sta {z1}+1
|
||||
//FRAGMENT pbuz1=pbuz2_plus_vbuz3
|
||||
lda {z3}
|
||||
clc
|
||||
adc {z2}
|
||||
sta {z1}
|
||||
lda #0
|
||||
adc {z2}+1
|
||||
sta {z1}+1
|
||||
//FRAGMENT pbuz1=pbuz1_minus_vbuc1
|
||||
sec
|
||||
lda {z1}
|
||||
sbc #{c1}
|
||||
sta {z1}
|
||||
lda {z1}+1
|
||||
sbc #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT vbuz1=_deref_pbuc1
|
||||
lda {c1}
|
||||
sta {z1}
|
||||
//FRAGMENT _deref_pbuz1=vbuz2
|
||||
lda {z2}
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT vbuxx=vbuxx_band_vbuc1
|
||||
lda #{c1}
|
||||
axs #0
|
||||
//FRAGMENT vbuyy=vbuxx_band_vbuc1
|
||||
txa
|
||||
and #{c1}
|
||||
tay
|
||||
//FRAGMENT vbuxx=vbuyy_band_vbuc1
|
||||
ldx #{c1}
|
||||
tya
|
||||
axs #0
|
||||
//FRAGMENT vbuyy=vbuyy_band_vbuc1
|
||||
tya
|
||||
and #{c1}
|
||||
tay
|
||||
//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuaa
|
||||
tay
|
||||
lda {c1},y
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuxx
|
||||
lda {c1},x
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuyy
|
||||
lda {c1},y
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1
|
||||
ldy {z1}
|
||||
lda {c1},y
|
||||
//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1
|
||||
ldy {z1}
|
||||
ldx {c1},y
|
||||
//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1
|
||||
ldx {z1}
|
||||
ldy {c1},x
|
||||
//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa
|
||||
tay
|
||||
lda {c1},y
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa
|
||||
tay
|
||||
lda {c1},y
|
||||
//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa
|
||||
tay
|
||||
ldx {c1},y
|
||||
//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa
|
||||
tax
|
||||
ldy {c1},x
|
||||
//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx
|
||||
lda {c1},x
|
||||
sta {z1}
|
||||
//FRAGMENT 0_neq_vbuaa_then_la1
|
||||
cmp #0
|
||||
bne {la1}
|
||||
//FRAGMENT vbuaa_ge_vbuz1_then_la1
|
||||
cmp {z1}
|
||||
bcs {la1}
|
||||
//FRAGMENT vbuxx=vbuxx_minus_vbuz1
|
||||
txa
|
||||
sec
|
||||
sbc {z1}
|
||||
tax
|
||||
//FRAGMENT vbuz1=vbuz1_minus_vbuaa
|
||||
eor #$ff
|
||||
sec
|
||||
adc {z1}
|
||||
sta {z1}
|
||||
//FRAGMENT vbuxx=vbuxx_minus_vbuaa
|
||||
sta $ff
|
||||
txa
|
||||
sec
|
||||
sbc $ff
|
||||
tax
|
||||
//FRAGMENT vbuz1=vbuz1_minus_vbuxx
|
||||
txa
|
||||
eor #$ff
|
||||
sec
|
||||
adc {z1}
|
||||
sta {z1}
|
||||
//FRAGMENT vbuxx=vbuxx_minus_vbuxx
|
||||
lda #0
|
||||
tax
|
||||
//FRAGMENT vbuz1=vbuz1_minus_vbuyy
|
||||
tya
|
||||
eor #$ff
|
||||
sec
|
||||
adc {z1}
|
||||
sta {z1}
|
||||
//FRAGMENT vbuxx=vbuxx_minus_vbuyy
|
||||
txa
|
||||
sty $ff
|
||||
sec
|
||||
sbc $ff
|
||||
tax
|
||||
//FRAGMENT vwuz1=_word_vbuaa
|
||||
sta {z1}
|
||||
lda #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT vwuz1=_word_vbuxx
|
||||
txa
|
||||
sta {z1}
|
||||
lda #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT vwuz1=_word_vbuyy
|
||||
tya
|
||||
sta {z1}
|
||||
lda #0
|
||||
sta {z1}+1
|
||||
//FRAGMENT vbuaa_eq_vbuc1_then_la1
|
||||
cmp #{c1}
|
||||
beq {la1}
|
||||
//FRAGMENT vbuaa=_deref_pbuc1
|
||||
lda {c1}
|
||||
//FRAGMENT vbuxx=_deref_pbuc1
|
||||
ldx {c1}
|
||||
//FRAGMENT _deref_pbuz1=vbuaa
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT _deref_pbuz1=vbuxx
|
||||
txa
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT _deref_pbuz1=vbuyy
|
||||
tya
|
||||
ldy #0
|
||||
sta ({z1}),y
|
||||
//FRAGMENT vbuxx_ge_vbuz1_then_la1
|
||||
cpx {z1}
|
||||
bcs {la1}
|
||||
//FRAGMENT vbuxx_eq_vbuc1_then_la1
|
||||
cpx #{c1}
|
||||
beq {la1}
|
||||
//FRAGMENT vbuyy=_deref_pbuc1
|
||||
ldy {c1}
|
||||
//FRAGMENT vbuz1_ge_vbuxx_then_la1
|
||||
lda {z1}
|
||||
stx $ff
|
||||
cmp $ff
|
||||
bcs {la1}
|
||||
//FRAGMENT vbuz1_ge_vbuyy_then_la1
|
||||
lda {z1}
|
||||
sty $ff
|
||||
cmp $ff
|
||||
bcs {la1}
|
||||
//FRAGMENT vbuxx_ge_vbuyy_then_la1
|
||||
sty $ff
|
||||
cpx $ff
|
||||
bcs {la1}
|
||||
//FRAGMENT vbuaa=vbuxx
|
||||
txa
|
||||
//FRAGMENT vbuyy=vbuxx
|
||||
txa
|
||||
tay
|
||||
//FRAGMENT vbuyy_eq_vbuc1_then_la1
|
||||
cpy #{c1}
|
||||
beq {la1}
|
||||
//FRAGMENT vbuaa=vbuyy
|
||||
tya
|
||||
//FRAGMENT vbuxx=vbuyy
|
||||
tya
|
||||
tax
|
||||
//FRAGMENT vbuyy_ge_vbuz1_then_la1
|
||||
cpy {z1}
|
||||
bcs {la1}
|
||||
//FRAGMENT vwuz1=vwuz1_rol_5
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
asl {z1}
|
||||
rol {z1}+1
|
||||
//FRAGMENT pbuz1=pbuc1_plus_vwuz1
|
||||
lda {z1}
|
||||
clc
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda {z1}+1
|
||||
adc #>{c1}
|
||||
sta {z1}+1
|
||||
|
4216
src/main/fragment/cache/fragment-cache-wdc65c02.asm
vendored
4216
src/main/fragment/cache/fragment-cache-wdc65c02.asm
vendored
File diff suppressed because it is too large
Load Diff
@ -116,11 +116,11 @@ public class Initializers {
|
||||
initValue = new ConstantCastValue(typeSpec.getType(), (ConstantValue) initValue);
|
||||
} else {
|
||||
SymbolType inferredType = SymbolTypeInference.inferType(program.getScope(), initValue);
|
||||
if(!inferredType.equals(typeSpec.getType()) && !inferredType.equals(SymbolType.VAR)) {
|
||||
if(!typeSpec.getType().equals(inferredType) && !SymbolType.VAR.equals(inferredType)) {
|
||||
if(SymbolTypeConversion.assignmentTypeMatch(typeSpec.getType(), inferredType))
|
||||
initValue = new CastValue(typeSpec.getType(), initValue);
|
||||
else
|
||||
throw new CompileError("Type mismatch (" + typeSpec.getType().getTypeName() + ") cannot be assigned from (" + inferredType.getTypeName() + ").", source);
|
||||
throw new CompileError("Type mismatch (" + typeSpec.getType().getTypeName() + ") cannot be assigned from '" + initValue + "'.", source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package dk.camelot64.kickc.model.types;
|
||||
|
||||
import dk.camelot64.kickc.model.CompileError;
|
||||
import dk.camelot64.kickc.model.InternalError;
|
||||
import dk.camelot64.kickc.model.operators.OperatorBinary;
|
||||
import dk.camelot64.kickc.model.operators.OperatorUnary;
|
||||
import dk.camelot64.kickc.model.statements.StatementAssignment;
|
||||
@ -18,7 +16,7 @@ public class SymbolTypeInference {
|
||||
if(rValue instanceof SymbolVariableRef) {
|
||||
Variable variable = symbols.getVar((SymbolVariableRef) rValue);
|
||||
if(variable==null)
|
||||
throw new CompileError("Unknown variable "+rValue.toString());
|
||||
return null; // throw new CompileError("Unknown variable "+rValue.toString());
|
||||
type = variable.getType().getQualified(false, variable.getType().isNomodify());
|
||||
} else if(rValue instanceof Symbol) {
|
||||
Symbol rSymbol = (Symbol) rValue;
|
||||
@ -97,7 +95,7 @@ public class SymbolTypeInference {
|
||||
SymbolType rightType = inferType(symbols, rValue2);
|
||||
rValueType = ((OperatorBinary) assignment.getOperator()).inferType(leftType, rightType);
|
||||
} else {
|
||||
throw new InternalError("Cannot infer type of " + assignment.toString());
|
||||
return null; // throw new InternalError("Cannot infer type of " + assignment.toString());
|
||||
}
|
||||
return rValueType.getQualified(false, false);
|
||||
} else if(rValue instanceof StructMemberRef) {
|
||||
@ -108,12 +106,12 @@ public class SymbolTypeInference {
|
||||
StructDefinition structDefinition = symbols.getLocalStructDefinition(typeName);
|
||||
Variable structMember = structDefinition.getLocalVar(structMemberRef.getMemberName());
|
||||
if(structMember == null)
|
||||
throw new CompileError("Unknown struct member " + structMemberRef.getMemberName() + " in struct " + structType.getTypeName());
|
||||
return null; // throw new InternalError("Unknown struct member " + structMemberRef.getMemberName() + " in struct " + structType.getTypeName());
|
||||
return structMember.getType();
|
||||
} else if(structType.equals(SymbolType.VAR)) {
|
||||
} else if(SymbolType.VAR.equals(structType)) {
|
||||
return SymbolType.VAR;
|
||||
} else {
|
||||
throw new CompileError("Dot applied to non-struct "+ structMemberRef.getStruct().toString());
|
||||
return null; // throw new CompileError("Dot applied to non-struct "+ structMemberRef.getStruct().toString());
|
||||
}
|
||||
} else if(rValue instanceof StructZero) {
|
||||
return ((StructZero)rValue).getTypeStruct();
|
||||
@ -135,7 +133,7 @@ public class SymbolTypeInference {
|
||||
return ((StackPushValue) rValue).getType();
|
||||
}
|
||||
if(type == null) {
|
||||
throw new InternalError("Cannot infer type for " + rValue.toString());
|
||||
return null; // throw new InternalError("Cannot infer type for " + rValue.toString());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
@ -2266,7 +2266,7 @@ public class TestProgramsFast extends TestPrograms {
|
||||
|
||||
@Test
|
||||
public void testStructError7() throws IOException {
|
||||
assertError("struct-err-7.c", "Unknown struct member");
|
||||
assertError("struct-err-7.c", "Type mismatch (signed word) cannot be assigned from '*main::per.qwe'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user