Skip to content

Commit

Permalink
std::jule::lex: minor naming refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 10, 2024
1 parent 71422ed commit 10602a1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 60 deletions.
8 changes: 4 additions & 4 deletions src/julec/opt/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ impl exprOptimizer {
| TokenId.Star:
ok, x := checkForBitShiftOpt(m.Left, m.Right)
if ok {
m.Op.Id = TokenId.Lshift
m.Op.Kind = TokenKind.Lshift
m.Op.Id = TokenId.Shl
m.Op.Kind = TokenKind.Shl
mut c := (&Const)(m.Right.Model)
c.SetU64(x)
ret
}
| TokenId.Solidus:
ok, x := checkForBitShiftOpt(m.Left, m.Right)
if ok {
m.Op.Id = TokenId.Rshift
m.Op.Kind = TokenKind.Rshift
m.Op.Id = TokenId.Shr
m.Op.Kind = TokenKind.Shr
mut c := (&Const)(m.Right.Model)
c.SetU64(x)
ret
Expand Down
12 changes: 6 additions & 6 deletions std/jule/lex/lex.jule
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ static basicOps: [...]kindPair = [
{TokenKind.StarEq, TokenId.StarEq},
{TokenKind.SolidusEq, TokenId.SolidusEq},
{TokenKind.PercentEq, TokenId.PercentEq},
{TokenKind.LshiftEq, TokenId.LshiftEq},
{TokenKind.RshiftEq, TokenId.RshiftEq},
{TokenKind.ShlEq, TokenId.ShlEq},
{TokenKind.ShrEq, TokenId.ShrEq},
{TokenKind.CaretEq, TokenId.CaretEq},
{TokenKind.AmperEq, TokenId.AmperEq},
{TokenKind.VlineEq, TokenId.VlineEq},
{TokenKind.Eqs, TokenId.Eqs},
{TokenKind.NotEq, TokenId.NotEq},
{TokenKind.GreatEq, TokenId.GreatEq},
{TokenKind.LessEq, TokenId.LessEq},
{TokenKind.GtEq, TokenId.GtEq},
{TokenKind.LtEq, TokenId.LtEq},
{TokenKind.DblAmper, TokenId.DblAmper},
{TokenKind.DblVline, TokenId.DblVline},
{TokenKind.Lshift, TokenId.Lshift},
{TokenKind.Rshift, TokenId.Rshift},
{TokenKind.Shl, TokenId.Shl},
{TokenKind.Shr, TokenId.Shr},
{TokenKind.DblPlus, TokenId.DblPlus},
{TokenKind.DblMinus, TokenId.DblMinus},
{TokenKind.Plus, TokenId.Plus},
Expand Down
44 changes: 22 additions & 22 deletions std/jule/lex/token.jule
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ static BinOps: [...]TokenId = [
TokenId.Amper,
TokenId.Vline,
TokenId.Caret,
TokenId.Lshift,
TokenId.Rshift,
TokenId.Shl,
TokenId.Shr,
TokenId.Lt,
TokenId.Gt,
TokenId.LessEq,
TokenId.GreatEq,
TokenId.LtEq,
TokenId.GtEq,
TokenId.DblAmper,
TokenId.DblVline,
TokenId.Eqs,
Expand Down Expand Up @@ -106,8 +106,8 @@ static AssignOps: [...]TokenId = [
TokenId.SolidusEq,
TokenId.StarEq,
TokenId.PercentEq,
TokenId.RshiftEq,
TokenId.LshiftEq,
TokenId.ShrEq,
TokenId.ShlEq,
TokenId.VlineEq,
TokenId.AmperEq,
TokenId.CaretEq,
Expand Down Expand Up @@ -166,19 +166,19 @@ enum TokenId: uint {
StarEq,
SolidusEq,
PercentEq,
LshiftEq,
RshiftEq,
ShlEq,
ShrEq,
CaretEq,
AmperEq,
VlineEq,
Eqs,
NotEq,
GreatEq,
LessEq,
GtEq,
LtEq,
DblAmper,
DblVline,
Lshift,
Rshift,
Shl,
Shr,
DblPlus,
DblMinus,
Plus,
Expand Down Expand Up @@ -214,19 +214,19 @@ enum TokenKind: str {
StarEq: "*=",
SolidusEq: "/=",
PercentEq: "%=",
LshiftEq: "<<=",
RshiftEq: ">>=",
ShlEq: "<<=",
ShrEq: ">>=",
CaretEq: "^=",
AmperEq: "&=",
VlineEq: "|=",
Eqs: "==",
NotEq: "!=",
GreatEq: ">=",
LessEq: "<=",
GtEq: ">=",
LtEq: "<=",
DblAmper: "&&",
DblVline: "||",
Lshift: "<<",
Rshift: ">>",
Shl: "<<",
Shr: ">>",
DblPlus: "++",
DblMinus: "--",
Plus: "+",
Expand Down Expand Up @@ -303,8 +303,8 @@ impl Token {
| TokenId.Star
| TokenId.Percent
| TokenId.Solidus
| TokenId.Rshift
| TokenId.Lshift
| TokenId.Shr
| TokenId.Shl
| TokenId.Amper:
ret 5
| TokenId.Plus
Expand All @@ -316,9 +316,9 @@ impl Token {
| TokenId.NotEq
| TokenId.Eq
| TokenId.Lt
| TokenId.LessEq
| TokenId.LtEq
| TokenId.Gt
| TokenId.GreatEq:
| TokenId.GtEq:
ret 3
| TokenId.DblAmper:
ret 2
Expand Down
44 changes: 22 additions & 22 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -3362,9 +3362,9 @@ impl binaryEval {
fn checkStructCommonOperatorCompatibility(mut self): bool {
let mut overload: &FnIns = nil
match self.op.Id {
| TokenId.Lshift:
| TokenId.Shl:
overload = self.l.Kind.Struct().Operators.Shl
| TokenId.Rshift:
| TokenId.Shr:
overload = self.l.Kind.Struct().Operators.Shr
| TokenId.Plus:
overload = self.l.Kind.Struct().Operators.Add
Expand Down Expand Up @@ -3467,8 +3467,8 @@ impl binaryEval {
match self.op.Id {
| TokenId.Gt
| TokenId.Lt
| TokenId.GreatEq
| TokenId.LessEq:
| TokenId.GtEq
| TokenId.LtEq:
if !types::IsNum(enm.Kind.Kind.Str()) {
self.e.pushErr(self.op, LogMsg.OperatorNotForJuleType, self.op.Kind, enm.Ident)
ret nil
Expand Down Expand Up @@ -3550,8 +3550,8 @@ impl binaryEval {
| TokenId.NotEq
| TokenId.Lt
| TokenId.Gt
| TokenId.LessEq
| TokenId.GreatEq:
| TokenId.LtEq
| TokenId.GtEq:
if !self.checkTypeCompatibility() {
ret nil
}
Expand Down Expand Up @@ -3621,7 +3621,7 @@ impl binaryEval {
ret &Data{
Kind: primBool,
}
| TokenId.GreatEq:
| TokenId.GtEq:
if self.l.Kind.Struct().Operators.GtEq == nil {
self.e.pushErr(self.op, LogMsg.OperatorNotForJuleType, self.op.Kind, self.l.Kind.Str())
ret nil
Expand All @@ -3637,7 +3637,7 @@ impl binaryEval {
ret &Data{
Kind: primBool,
}
| TokenId.LessEq:
| TokenId.LtEq:
if self.l.Kind.Struct().Operators.LtEq == nil {
self.e.pushErr(self.op, LogMsg.OperatorNotForJuleType, self.op.Kind, self.l.Kind.Str())
ret nil
Expand Down Expand Up @@ -3722,8 +3722,8 @@ impl binaryEval {
| TokenId.NotEq
| TokenId.Lt
| TokenId.Gt
| TokenId.GreatEq
| TokenId.LessEq:
| TokenId.GtEq
| TokenId.LtEq:
ret &Data{
Kind: primBool,
}
Expand Down Expand Up @@ -3823,8 +3823,8 @@ impl binaryEval {
}

match self.op.Id {
| TokenId.Lshift
| TokenId.Rshift:
| TokenId.Shl
| TokenId.Shr:
if !self.l.IsConst() || !intAssignable(PrimKind.I64, self.l) {
self.e.pushErr(self.op, LogMsg.IncompatibleTypes, lk, rk)
ret nil
Expand All @@ -3848,8 +3848,8 @@ impl binaryEval {
| TokenId.NotEq
| TokenId.Lt
| TokenId.Gt
| TokenId.GreatEq
| TokenId.LessEq:
| TokenId.GtEq
| TokenId.LtEq:
self.setTypeToGreater()
ret &Data{
Kind: primBool,
Expand Down Expand Up @@ -3883,8 +3883,8 @@ impl binaryEval {
rk := self.r.Kind.Prim().Kind // Primitive guaranteed.

match self.op.Id {
| TokenId.Lshift
| TokenId.Rshift:
| TokenId.Shl
| TokenId.Shr:
if !types::IsInt(lk) || !types::IsInt(rk) {
self.e.pushErr(self.op, LogMsg.IncompatibleTypes, lk, rk)
ret nil
Expand All @@ -3907,8 +3907,8 @@ impl binaryEval {
| TokenId.NotEq
| TokenId.Lt
| TokenId.Gt
| TokenId.GreatEq
| TokenId.LessEq:
| TokenId.GtEq
| TokenId.LtEq:
ret &Data{
Kind: primBool,
}
Expand Down Expand Up @@ -4052,9 +4052,9 @@ impl binaryEval {
d.Constant = Const.NewBool(self.l.Constant.Gt(*self.r.Constant))
| TokenId.Lt:
d.Constant = Const.NewBool(self.l.Constant.Lt(*self.r.Constant))
| TokenId.GreatEq:
| TokenId.GtEq:
d.Constant = Const.NewBool(self.l.Constant.GtEq(*self.r.Constant))
| TokenId.LessEq:
| TokenId.LtEq:
d.Constant = Const.NewBool(self.l.Constant.LtEq(*self.r.Constant))
| TokenId.Plus:
_ = self.l.Constant.Add(*self.r.Constant)
Expand Down Expand Up @@ -4093,10 +4093,10 @@ impl binaryEval {
| TokenId.Caret:
_ = self.l.Constant.Xor(*self.r.Constant)
d.Constant = self.l.Constant
| TokenId.Lshift:
| TokenId.Shl:
_ = self.l.Constant.Lshift(*self.r.Constant)
d.Constant = self.l.Constant
| TokenId.Rshift:
| TokenId.Shr:
_ = self.l.Constant.Rshift(*self.r.Constant)
d.Constant = self.l.Constant
}
Expand Down
12 changes: 6 additions & 6 deletions std/jule/sema/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1289,9 +1289,9 @@ impl scopeChecker {
overload = s.Operators.MulAssign
| TokenId.PercentEq:
overload = s.Operators.ModAssign
| TokenId.LshiftEq:
| TokenId.ShlEq:
overload = s.Operators.ShlAssign
| TokenId.RshiftEq:
| TokenId.ShrEq:
overload = s.Operators.ShrAssign
| TokenId.VlineEq:
overload = s.Operators.BitOrAssign
Expand Down Expand Up @@ -2219,10 +2219,10 @@ fn removeEqFromOp(op: TokenId): TokenId {
ret TokenId.Solidus
| TokenId.PercentEq:
ret TokenId.Percent
| TokenId.LshiftEq:
ret TokenId.Lshift
| TokenId.RshiftEq:
ret TokenId.Rshift
| TokenId.ShlEq:
ret TokenId.Shl
| TokenId.ShrEq:
ret TokenId.Shr
| TokenId.CaretEq:
ret TokenId.Caret
| TokenId.AmperEq:
Expand Down

0 comments on commit 10602a1

Please sign in to comment.