Compare commits

...

3 Commits

Author SHA1 Message Date
682295b04a Fix casting from the same size of integer 2025-07-22 21:05:52 +03:00
e5f6b37210 Fix std 2025-07-22 21:02:14 +03:00
5c5c9c5f7b Improve error for statement-failure 2025-07-22 20:54:06 +03:00
3 changed files with 14 additions and 13 deletions

View File

@ -629,14 +629,17 @@ impl Type {
}
(I32 | U32, I16 | U16 | I8 | U8) => Some(Instr::Trunc(value, other.clone())),
(I16 | U16, I8 | U8) => Some(Instr::Trunc(value, other.clone())),
(U8 | I8, U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128) => {
(U8 | I8, U8 | I8 | U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128) => {
Some(Instr::ZExt(value, other.clone()))
}
(U16 | I16, U32 | I32 | U64 | I64 | U128 | I128) => {
(U16 | I16, U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128) => {
Some(Instr::ZExt(value, other.clone()))
}
(U32 | I32, U64 | I64 | U128 | I128) => Some(Instr::ZExt(value, other.clone())),
(U64 | I64, U128 | I128) => Some(Instr::ZExt(value, other.clone())),
(U32 | I32, U32 | I32 | U64 | I64 | U128 | I128) => {
Some(Instr::ZExt(value, other.clone()))
}
(U64 | I64, U64 | I64 | U128 | I128) => Some(Instr::ZExt(value, other.clone())),
(U128 | I128, U128 | I128) => Some(Instr::ZExt(value, other.clone())),
(U8 | U16 | U32 | U64 | U128, F16 | F32 | F32B | F64 | F80 | F128 | F128PPC) => {
Some(Instr::UIToFP(value, other.clone()))
}

View File

@ -224,7 +224,7 @@ impl Parse for PrimaryExpression {
stream.expect(Token::BracketClose)?;
Expression(Kind::Array(expressions), stream.get_range().unwrap())
}
_ => Err(stream.expected_err("expression")?)?,
_ => Err(stream.expected_err("expression inner")?)?,
}
} else {
Err(stream.expected_err("expression")?)?
@ -662,14 +662,11 @@ impl Parse for BlockLevelStatement {
if let Ok(SetStatement(ident, expr, range)) = stream.parse() {
Stmt::Set(ident, expr, range)
} else {
if let Ok(e) = stream.parse() {
if stream.expect(Token::Semi).is_ok() {
Stmt::Expression(e)
} else {
Stmt::Return(ReturnType::Soft, e)
}
let e = stream.parse()?;
if stream.expect(Token::Semi).is_ok() {
Stmt::Expression(e)
} else {
Err(stream.expecting_err("expression")?)?
Stmt::Return(ReturnType::Soft, e)
}
}
}

View File

@ -1085,7 +1085,8 @@ impl mir::Expression {
},
(TypeKind::UserPtr(_), TypeKind::UserPtr(_))
| (TypeKind::Char, TypeKind::U8)
| (TypeKind::U8, TypeKind::Char) => Some(StackValue(
| (TypeKind::U8, TypeKind::Char)
| (TypeKind::U8, TypeKind::I8) => Some(StackValue(
val.0.derive(
scope
.block