- implementation of <var> <op> = <expr> type statements such as `x +=
5` - implementation of logical and shift operations in parser and codegen. - implementation of sizeof keyword as unary operator in progress (non functional) - implementation of prefix and postfix inc/dec operators - array access by index (implemented, untested as arrays aren't implemented yet). essentially just a pointer write with offset. - struct/member access (parsing implemented, untested.)
This commit is contained in:
+17
-2
@@ -11,6 +11,7 @@ pub enum CompilerError {
|
||||
Generic(String),
|
||||
UnknownType,
|
||||
TypeMismatch(TypeId, TypeId),
|
||||
Unimplemented(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
@@ -130,6 +131,7 @@ pub enum Statement {
|
||||
},
|
||||
Assign {
|
||||
varname: String,
|
||||
operator: AssignmentOperator,
|
||||
value: Expression,
|
||||
},
|
||||
PtrWrite {
|
||||
@@ -308,6 +310,21 @@ impl Expression {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AssignmentOperator {
|
||||
Assign,
|
||||
AddAssign,
|
||||
SubAssign,
|
||||
MulAssign,
|
||||
DivAssign,
|
||||
ModAssign,
|
||||
AndAssign,
|
||||
OrAssign,
|
||||
XorAssign,
|
||||
LeftShiftAssign,
|
||||
RightShiftAssign,
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum BinaryOperator {
|
||||
@@ -371,7 +388,6 @@ pub enum UnaryOperator {
|
||||
Minus,
|
||||
AddressOf,
|
||||
Dereference,
|
||||
CastAs,
|
||||
BitwiseNot,
|
||||
LogicalNot,
|
||||
Increment,
|
||||
@@ -388,7 +404,6 @@ impl fmt::Display for UnaryOperator {
|
||||
Self::Minus => write!(f, "-"),
|
||||
Self::Dereference => write!(f, "*"),
|
||||
Self::AddressOf => write!(f, "&"),
|
||||
Self::CastAs => write!(f, "as"),
|
||||
Self::BitwiseNot => write!(f, "~"),
|
||||
Self::LogicalNot => write!(f, "!"),
|
||||
Self::SizeOf => write!(f, "sizeof"),
|
||||
|
||||
Reference in New Issue
Block a user