compiler: refactor BinaryExpr handling

Reuse code between if conditions and expression context.
This commit is contained in:
Evgenii Stratonikov 2020-08-23 14:52:37 +03:00
parent 4d04c56efb
commit 51f3baf68e
2 changed files with 85 additions and 46 deletions

View file

@ -31,6 +31,10 @@ func isByte(typ types.Type) bool {
return isBasicTypeOfKind(typ, types.Uint8, types.Int8)
}
func isBool(typ types.Type) bool {
return isBasicTypeOfKind(typ, types.Bool, types.UntypedBool)
}
func isNumber(typ types.Type) bool {
t, ok := typ.Underlying().(*types.Basic)
return ok && t.Info()&types.IsNumeric != 0