2023-07-26 11:21:20 -07:00
|
|
|
// This is the non-bootstraped version of the EOperator. This will be obsolete once bootstrap is stress tested.
|
|
|
|
|
|
|
|
namespace EOperator
|
|
|
|
{
|
|
|
|
# define Define_Operators \
|
2023-07-27 14:12:58 -07:00
|
|
|
Entry( Invalid, INVALID ) \
|
2023-07-26 11:21:20 -07:00
|
|
|
Entry( Assign, = ) \
|
|
|
|
Entry( Assign_Add, += ) \
|
|
|
|
Entry( Assign_Subtract, -= ) \
|
|
|
|
Entry( Assign_Multiply, *= ) \
|
|
|
|
Entry( Assign_Divide, /= ) \
|
|
|
|
Entry( Assign_Modulo, %= ) \
|
|
|
|
Entry( Assign_BAnd, &= ) \
|
|
|
|
Entry( Assign_BOr, |= ) \
|
|
|
|
Entry( Assign_BXOr, ^= ) \
|
|
|
|
Entry( Assign_LShift, <<= ) \
|
|
|
|
Entry( Assign_RShift, >>= ) \
|
|
|
|
Entry( Increment, ++ ) \
|
|
|
|
Entry( Decrement, -- ) \
|
|
|
|
Entry( Unary_Plus, + ) \
|
|
|
|
Entry( Unary_Minus, - ) \
|
|
|
|
Entry( UnaryNot, ! ) \
|
|
|
|
Entry( Add, + ) \
|
|
|
|
Entry( Subtract, - ) \
|
|
|
|
Entry( Multiply, * ) \
|
|
|
|
Entry( Divide, / ) \
|
|
|
|
Entry( Modulo, % ) \
|
|
|
|
Entry( BNot, ~ ) \
|
|
|
|
Entry( BAnd, & ) \
|
|
|
|
Entry( BOr, | ) \
|
|
|
|
Entry( BXOr, ^ ) \
|
|
|
|
Entry( LShift, << ) \
|
|
|
|
Entry( RShift, >> ) \
|
|
|
|
Entry( LAnd, && ) \
|
|
|
|
Entry( LOr, || ) \
|
|
|
|
Entry( LEqual, == ) \
|
|
|
|
Entry( LNot, != ) \
|
|
|
|
Entry( Lesser, < ) \
|
|
|
|
Entry( Greater, > ) \
|
|
|
|
Entry( LesserEqual, <= ) \
|
|
|
|
Entry( GreaterEqual, >= ) \
|
|
|
|
Entry( Subscript, [] ) \
|
|
|
|
Entry( Indirection, * ) \
|
|
|
|
Entry( AddressOf, & ) \
|
|
|
|
Entry( MemberOfPointer, -> ) \
|
|
|
|
Entry( PtrToMemOfPtr, ->* ) \
|
|
|
|
Entry( FunctionCall, () )
|
|
|
|
|
|
|
|
enum Type : u32
|
|
|
|
{
|
|
|
|
# define Entry( Type_, Token_ ) Type_,
|
|
|
|
Define_Operators
|
|
|
|
# undef Entry
|
|
|
|
Comma,
|
|
|
|
|
|
|
|
Num_Ops,
|
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
2023-08-04 13:12:13 -07:00
|
|
|
StrC to_str( Type op )
|
2023-07-26 11:21:20 -07:00
|
|
|
{
|
|
|
|
local_persist
|
2023-08-04 13:12:13 -07:00
|
|
|
StrC lookup[ Num_Ops ] = {
|
|
|
|
# define Entry( Type_, Token_ ) { sizeof(stringize(Token_)), stringize(Token_) },
|
2023-07-26 11:21:20 -07:00
|
|
|
Define_Operators
|
|
|
|
# undef Entry
|
2023-08-09 15:47:59 -07:00
|
|
|
txt(",")
|
2023-07-26 11:21:20 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
return lookup[ op ];
|
|
|
|
}
|
|
|
|
|
|
|
|
# undef Define_Operators
|
|
|
|
}
|
2023-07-29 02:52:06 -07:00
|
|
|
using OperatorT = EOperator::Type;
|
2023-08-09 15:47:59 -07:00
|
|
|
using EOperator::to_str;
|
2023-08-03 08:01:43 -07:00
|
|
|
|