Skip to content

Commit

Permalink
implemented int xor float and char xor float
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanegv committed Feb 27, 2024
1 parent 5d8ccab commit 67261fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions interpreter/eclaType/char.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ func (c Char) Xor(other Type) (Type, error) {
} else {
return Bool(true), nil
}
case Float:
if c == Char(0) && other.GetValue() == Float(0) {
return Bool(false), nil
} else if c != Char(0) && other.GetValue() != Float(0) {
return Bool(false), nil
} else {
return Bool(true), nil
}
case Char:
if c == Char(0) && other.GetValue() == Char(0) {
return Bool(false), nil
Expand Down
8 changes: 8 additions & 0 deletions interpreter/eclaType/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,14 @@ func (i Int) Xor(other Type) (Type, error) {
} else {
return Bool(true), nil
}
case Float:
if i == Int(0) && other.GetValue() == Float(0) {
return Bool(false), nil
} else if i != Int(0) && other.GetValue() != Float(0) {
return Bool(false), nil
} else {
return Bool(true), nil
}
case Bool:
if i == Int(0) && other.GetValue() == Bool(false) {
return Bool(false), nil
Expand Down

0 comments on commit 67261fa

Please sign in to comment.