Fix bug
This commit is contained in:
parent
06be5bc35e
commit
a53b294392
@ -134,6 +134,8 @@ func castPrimitiveWAT(from PrimitiveType, to PrimitiveType) (string, error) {
|
||||
if getBits(to) < getBits(from) {
|
||||
return getTypeCast(to), nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
if getBits(from) < 64 && getBits(to) == 64 {
|
||||
@ -334,7 +336,6 @@ func compileStatementWAT(stmt Statement, block *Block) (string, error) {
|
||||
}
|
||||
|
||||
// TODO: upcast to return type for non-primitive types
|
||||
|
||||
return wat + "return\n", nil
|
||||
case Statement_DeclareLocalVariable:
|
||||
dlv := stmt.Value.(DeclareLocalVariableStatement)
|
||||
@ -347,7 +348,15 @@ func compileStatementWAT(stmt Statement, block *Block) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// TODO: make sure to upcast to target type
|
||||
if dlv.VariableType.Type == Type_Primitive {
|
||||
castWAT, err := castPrimitiveWAT(dlv.Initializer.ValueType.Value.(PrimitiveType), dlv.VariableType.Value.(PrimitiveType))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
wat += castWAT
|
||||
}
|
||||
|
||||
return wat + "local.set $" + strconv.Itoa(block.Locals[dlv.Variable].Index) + "\n", nil
|
||||
case Statement_If:
|
||||
ifS := stmt.Value.(IfStatement)
|
||||
|
@ -8,6 +8,7 @@ void a() {
|
||||
|
||||
(u8, u8) doNothing(u8 a, u8 b) {
|
||||
a = b;
|
||||
u16 c = 1u8;
|
||||
return a, b;
|
||||
}
|
||||
|
||||
|
3
example/test.lang
Normal file
3
example/test.lang
Normal file
@ -0,0 +1,3 @@
|
||||
void doNothing() {
|
||||
u64 sus = 1u8;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user