Skip to content

Commit

Permalink
std: rename binop as binary
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 9, 2024
1 parent 8e71502 commit 71422ed
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
18 changes: 9 additions & 9 deletions src/julec/obj/cxx/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use env
use opt::{
RefExprModel,
UnsafeBinopExprModel,
UnsafeBinaryExprModel,
UnsafeIndexingExprModel,
PushToSliceExprModel,
AppendToSliceExprModel,
Expand All @@ -27,7 +27,7 @@ use std::jule::sema::{
Data,
Value,
ExprModel,
BinopExprModel,
BinaryExprModel,
UnaryExprModel,
StructLitExprModel,
AllocStructLitExprModel,
Expand Down Expand Up @@ -90,7 +90,7 @@ type PrimKind: types::TypeKind
enum compExprModel: type {
ExprModel: ExprModel,
str, // For built-in expressions.
&UnsafeBinopExprModel,
&UnsafeBinaryExprModel,
&UnsafeIndexingExprModel,
&StrCompExprModel,
&RefExprModel,
Expand Down Expand Up @@ -232,7 +232,7 @@ impl exprCoder {
self.oc.write(")")
}

fn unsafeBinary(mut &self, mut m: &BinopExprModel) {
fn unsafeBinary(mut &self, mut m: &BinaryExprModel) {
if m.Op.Id == TokenId.Eqs || m.Op.Id == TokenId.NotEq {
// If this binary operator comparing <any> type.
// The m.Left is will be <any> one always.
Expand Down Expand Up @@ -263,7 +263,7 @@ impl exprCoder {
self.oc.write(")")
}

fn binary(mut &self, mut m: &BinopExprModel) {
fn binary(mut &self, mut m: &BinaryExprModel) {
match m.Op.Id {
| TokenId.Solidus | TokenId.Percent:
// Do not check division of structures safety.
Expand Down Expand Up @@ -1325,10 +1325,10 @@ impl exprCoder {
self.structureIns((&StructIns)(m))
| &FnIns:
self.funcInsCommon((&FnIns)(m))
| &UnsafeBinopExprModel:
self.unsafeBinary((&UnsafeBinopExprModel)(m).Node)
| &BinopExprModel:
self.binary((&BinopExprModel)(m))
| &UnsafeBinaryExprModel:
self.unsafeBinary((&UnsafeBinaryExprModel)(m).Node)
| &BinaryExprModel:
self.binary((&BinaryExprModel)(m))
| &UnaryExprModel:
self.unary((&UnaryExprModel)(m))
| &StructLitExprModel:
Expand Down
8 changes: 4 additions & 4 deletions src/julec/opt/deadcode/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::jule::sema::{
Data,
ExprModel,
BinopExprModel,
BinaryExprModel,
OperandExprModel,
UnaryExprModel,
StructLitExprModel,
Expand Down Expand Up @@ -51,7 +51,7 @@ impl exprDeadCode {
}
}

fn binary(self, mut m: &BinopExprModel) {
fn binary(self, mut m: &BinaryExprModel) {
self.optimize(m.Left.Model)
self.optimize(m.Right.Model)
}
Expand Down Expand Up @@ -214,8 +214,8 @@ impl exprDeadCode {

fn optimize(self, mut &model: ExprModel) {
match type model {
| &BinopExprModel:
self.binary((&BinopExprModel)(model))
| &BinaryExprModel:
self.binary((&BinaryExprModel)(model))
| &UnaryExprModel:
self.unary((&UnaryExprModel)(model))
| &StructLitExprModel:
Expand Down
8 changes: 4 additions & 4 deletions src/julec/opt/equal.jule
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::jule::sema::{
CastingExprModel,
UnaryExprModel,
IndexingExprModel,
BinopExprModel,
BinaryExprModel,
StructSubIdentExprModel,
}

Expand Down Expand Up @@ -56,7 +56,7 @@ fn equalIndexing(l: &IndexingExprModel, r: &IndexingExprModel): bool {
equalModels(l.Index.Model, r.Index.Model)
}

fn equalBinary(l: &BinopExprModel, r: &BinopExprModel): bool {
fn equalBinary(l: &BinaryExprModel, r: &BinaryExprModel): bool {
if l.Op.Id != r.Op.Id || l.Op.Kind != r.Op.Kind {
ret false
}
Expand Down Expand Up @@ -86,8 +86,8 @@ fn equalModels(l: ExprModel, r: ExprModel): bool {
ret equalUnary((&UnaryExprModel)(l), (&UnaryExprModel)(r))
| &IndexingExprModel:
ret equalIndexing((&IndexingExprModel)(l), (&IndexingExprModel)(r))
| &BinopExprModel:
ret equalBinary((&BinopExprModel)(l), (&BinopExprModel)(r))
| &BinaryExprModel:
ret equalBinary((&BinaryExprModel)(l), (&BinaryExprModel)(r))
|:
ret false
}
Expand Down
12 changes: 6 additions & 6 deletions src/julec/opt/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::jule::sema::{
Var,
FnIns,
ExprModel,
BinopExprModel,
BinaryExprModel,
OperandExprModel,
UnaryExprModel,
StructLitExprModel,
Expand Down Expand Up @@ -63,7 +63,7 @@ impl exprOptimizer {
}
}

fn strCond(self, mut m: &BinopExprModel): bool {
fn strCond(self, mut m: &BinaryExprModel): bool {
lp := m.Left.Kind.Prim()
if lp == nil || !lp.IsStr() {
ret false
Expand Down Expand Up @@ -119,7 +119,7 @@ impl exprOptimizer {
ret true
}

fn binary(self, mut m: &BinopExprModel) {
fn binary(self, mut m: &BinaryExprModel) {
exprOptimizer.optimize(m.Left.Model)
exprOptimizer.optimize(m.Right.Model)

Expand Down Expand Up @@ -165,7 +165,7 @@ impl exprOptimizer {
c.SetI64(1)
}
}
mut model := any(&UnsafeBinopExprModel{Node: m})
mut model := any(&UnsafeBinaryExprModel{Node: m})
*self.model = unsafe { *(*ExprModel)(&model) }
}

Expand Down Expand Up @@ -383,8 +383,8 @@ impl exprOptimizer {

fn do(self) {
match type *self.model {
| &BinopExprModel:
self.binary((&BinopExprModel)(*self.model))
| &BinaryExprModel:
self.binary((&BinaryExprModel)(*self.model))
| &UnaryExprModel:
self.unary((&UnaryExprModel)(*self.model))
| &StructLitExprModel:
Expand Down
6 changes: 3 additions & 3 deletions src/julec/opt/model.jule
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::jule::sema::{
Var,
TypeKind,
ExprModel,
BinopExprModel,
BinaryExprModel,
IndexingExprModel,
BuiltinAppendCallExprModel,
SliceExprModel,
Expand Down Expand Up @@ -42,8 +42,8 @@ struct MutSlicingExprModel {
Right: ExprModel
}

struct UnsafeBinopExprModel {
Node: &BinopExprModel
struct UnsafeBinaryExprModel {
Node: &BinaryExprModel
}

struct UnsafeIndexingExprModel {
Expand Down
10 changes: 5 additions & 5 deletions src/julec/opt/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sema for std::jule::sema::{
InfIter,
MultiAssign,
RetSt,
BinopExprModel,
BinaryExprModel,
OperandExprModel,
BuiltinAppendCallExprModel,
SliceExprModel,
Expand Down Expand Up @@ -310,14 +310,14 @@ impl scopeOptimizer {
// Do not check division of structures safety.
if Math && assign.L.Kind.Struct() == nil {
assign.Op.Kind = assign.Op.Kind[:len(assign.Op.Kind)-1]
mut model := ExprModel(&BinopExprModel{
mut model := ExprModel(&BinaryExprModel{
Op: assign.Op,
Left: assign.L,
Right: assign.R,
})
exprOptimizer.optimize(model)
match type model {
| &BinopExprModel:
| &BinaryExprModel:
assign.R = new(OperandExprModel, *assign.R)
assign.Op.Id = TokenId.Eq
assign.Op.Kind = TokenKind.Eq
Expand Down Expand Up @@ -466,8 +466,8 @@ fn isUnreachableExpr(&expr: ExprModel): bool {
| &Const:
c := (&Const)(expr)
ret c.IsBool() && !c.ReadBool()
| &BinopExprModel:
m := (&BinopExprModel)(expr)
| &BinaryExprModel:
m := (&BinaryExprModel)(expr)
if m.Op.Id == TokenId.DblAmper {
ret isUnreachableExpr(m.Left.Model) ||
isUnreachableExpr(m.Right.Model)
Expand Down
4 changes: 2 additions & 2 deletions std/jule/ast/node.jule
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ enum ExprData: type {
&BraceLit,
&SlicingExpr,
&SliceExpr,
&BinopExpr,
&BinaryExpr,
&UnsafeExpr,
&IndexingExpr,
&FnDecl,
Expand Down Expand Up @@ -235,7 +235,7 @@ struct SubIdentExpr {
}

// Binary operation.
struct BinopExpr {
struct BinaryExpr {
Left: &Expr
Right: &Expr
Op: &Token
Expand Down
2 changes: 1 addition & 1 deletion std/jule/build/log.jule
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ enum LogMsg: str {
NoFileInEntryPackage: `there is no Jule source code in package: @`,
NoMemberInEnum: `enum @ have no field`,
InternalTypeNotSupportsClone: `type @ has internally types which is not supports cloning`,
InvalidExprForBinop: `invalid expression used for binary operation`,
InvalidExprForBinary: `invalid expression used for binary operation`,
BindedStructForRef: `binded structures cannot supports reference counting`,
TraitMethodHasGenerics: `trait methods cannot have generics`,
EnumAsMapVal: `maps do not support enums as map key type`,
Expand Down
8 changes: 4 additions & 4 deletions std/jule/parser/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::jule::ast::{
SliceExpr,
IndexingExpr,
SlicingExpr,
BinopExpr,
BinaryExpr,
ScopeTree,
RangeExpr,
}
Expand Down Expand Up @@ -818,7 +818,7 @@ impl exprBuilder {
ret nil
}

fn buildBinop(mut self, mut &tokens: []&Token, i: int): ExprData {
fn buildBinary(mut self, mut &tokens: []&Token, i: int): ExprData {
mut op := tokens[i]
mut leftTokens := tokens[:i]
if isTypeOp(op.Id) && isTypeRange(leftTokens) {
Expand All @@ -836,7 +836,7 @@ impl exprBuilder {
self.pushSuggestion(LogMsg.ExpectedRightOperand)
ret nil
}
ret &BinopExpr{
ret &BinaryExpr{
Left: self.buildFromTokens(leftTokens),
Right: self.buildFromTokens(rightTokens),
Op: op,
Expand All @@ -851,7 +851,7 @@ impl exprBuilder {
if i == -1 {
ret self.buildData(tokens)
}
ret self.buildBinop(tokens, i)
ret self.buildBinary(tokens, i)
}

fn buildKind(mut self, mut &tokens: []&Token): ExprData {
Expand Down
14 changes: 7 additions & 7 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ast for std::jule::ast::{
SliceExpr,
ExprData,
FnDecl,
BinopExpr,
BinaryExpr,
BraceLit,
TupleExpr,
SubIdentExpr,
Expand Down Expand Up @@ -2892,7 +2892,7 @@ impl Eval {
}
}

fn evalBinop(mut &self, mut op: &BinopExpr): &Data {
fn evalBinary(mut &self, mut op: &BinaryExpr): &Data {
mut bs := binaryEval.newPlain(self)
// Apply prefix for just numericals.
if self.prefix != nil {
Expand Down Expand Up @@ -2946,8 +2946,8 @@ impl Eval {
ret self.evalBraceLit((&BraceLit)(kind))
| &FnDecl:
ret self.evalAnonFunc((&FnDecl)(kind))
| &BinopExpr:
ret self.evalBinop((&BinopExpr)(kind))
| &BinaryExpr:
ret self.evalBinary((&BinaryExpr)(kind))
|:
ret nil
}
Expand Down Expand Up @@ -4107,7 +4107,7 @@ impl binaryEval {
fn checkData(mut self, mut &d: &Data) {
f := d.Kind.Fn()
if f != nil && f.Decl != nil && f.Decl.IsMethod() {
self.e.pushErr(self.op, LogMsg.InvalidExprForBinop)
self.e.pushErr(self.op, LogMsg.InvalidExprForBinary)
}
}

Expand All @@ -4130,7 +4130,7 @@ impl binaryEval {
l, r = r, l
}

d.Model = &BinopExprModel{
d.Model = &BinaryExprModel{
Left: &OperandExprModel{
Kind: l.Kind,
Model: l.Model,
Expand Down Expand Up @@ -4168,7 +4168,7 @@ impl binaryEval {
ret d
}

fn eval(mut self, mut &op: &BinopExpr): &Data {
fn eval(mut self, mut &op: &BinaryExpr): &Data {
if op.Op.Id == TokenId.Eq {
self.e.pushErr(op.Op, LogMsg.AssignInExpr)
self.e.pushSuggestion(LogMsg.UseImperative)
Expand Down
4 changes: 2 additions & 2 deletions std/jule/sema/model.jule
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum ExprModel: type {
&FnIns,
&StructIns,
&OperandExprModel,
&BinopExprModel,
&BinaryExprModel,
&UnaryExprModel,
&StructArgExprModel,
&StructLitExprModel,
Expand Down Expand Up @@ -58,7 +58,7 @@ struct OperandExprModel {
}

// Binary operation expression Model:.
struct BinopExprModel {
struct BinaryExprModel {
Left: &OperandExprModel
Right: &OperandExprModel
Op: &Token
Expand Down

0 comments on commit 71422ed

Please sign in to comment.