conlang: Introduce as casting

Arbitrary primitive type conversion

Currently implemented as jankily as possible in the interpreter, but it works alright™️
This commit is contained in:
2024-07-26 05:26:08 -05:00
parent a8b8a91c79
commit e43847bbd4
10 changed files with 100 additions and 5 deletions

View File

@@ -365,6 +365,8 @@ pub enum ExprKind {
Binary(Binary),
/// A [Unary] expression: [`UnaryKind`]\* [`Expr`]
Unary(Unary),
/// A [Cast] expression: [`Expr`] `as` [`Ty`]
Cast(Cast),
/// A [Member] access expression: [`Expr`] [`MemberKind`]\*
Member(Member),
/// An Array [Index] expression: a[10, 20, 30]
@@ -484,6 +486,12 @@ pub enum UnaryKind {
Tilde,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Cast {
pub head: Box<ExprKind>,
pub ty: Ty,
}
/// A [Member] access expression: [`Expr`] [`MemberKind`]\*
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Member {