Logical or/and
This commit is contained in:
@@ -725,13 +725,13 @@ public class QBEGenerator
|
||||
|
||||
var outputName = TmpName();
|
||||
|
||||
var instruction = BinaryInstructionFor(binaryExpression.Operator, binaryExpression.Left.Type);
|
||||
var instruction = EmitBinaryInstructionForOperator(binaryExpression.Operator, binaryExpression.Left.Type);
|
||||
|
||||
_writer.Indented($"{outputName} {QBEAssign(binaryExpression.Left.Type)} {instruction} {left}, {right}");
|
||||
return outputName;
|
||||
}
|
||||
|
||||
private string BinaryInstructionFor(BinaryOperator op, TypeNode type)
|
||||
private static string EmitBinaryInstructionForOperator(BinaryOperator op, TypeNode type)
|
||||
{
|
||||
return op switch
|
||||
{
|
||||
@@ -881,6 +881,9 @@ public class QBEGenerator
|
||||
},
|
||||
_ => throw new NotSupportedException($"Greater than or equal comparison not supported for type '{type}'")
|
||||
},
|
||||
// todo(nub31): Implement short circuiting
|
||||
BinaryOperator.LogicalAnd => "and",
|
||||
BinaryOperator.LogicalOr => "or",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(op))
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user