Browse Source
compiler: compare booleans
Implement == and != for booleans.
pull/48/head
Ayke van Laethem
6 years ago
No known key found for this signature in database
GPG Key ID: E97FF5335DFDFDED
1 changed files with
10 additions and
0 deletions
-
compiler/compiler.go
|
|
@ -2823,6 +2823,16 @@ func (c *Compiler) parseBinOp(frame *Frame, binop *ssa.BinOp) (llvm.Value, error |
|
|
|
default: |
|
|
|
return llvm.Value{}, errors.New("todo: binop on float: " + binop.Op.String()) |
|
|
|
} |
|
|
|
} else if typ.Info()&types.IsBoolean != 0 { |
|
|
|
// Operations on booleans
|
|
|
|
switch binop.Op { |
|
|
|
case token.EQL: // ==
|
|
|
|
return c.builder.CreateICmp(llvm.IntEQ, x, y, ""), nil |
|
|
|
case token.NEQ: // !=
|
|
|
|
return c.builder.CreateICmp(llvm.IntNE, x, y, ""), nil |
|
|
|
default: |
|
|
|
return llvm.Value{}, errors.New("todo: binop on boolean: " + binop.Op.String()) |
|
|
|
} |
|
|
|
} else if typ.Kind() == types.UnsafePointer { |
|
|
|
// Operations on pointers
|
|
|
|
switch binop.Op { |
|
|
|