public InferTypeOfBinaryExpression ( System.Compiler.TypeNode t1, System.Compiler.TypeNode t2, System.Compiler.BinaryExpression binaryExpression ) : System.Compiler.TypeNode | ||
t1 | System.Compiler.TypeNode | |
t2 | System.Compiler.TypeNode | |
binaryExpression | System.Compiler.BinaryExpression | |
Résultat | System.Compiler.TypeNode |
public override TypeNode InferTypeOfBinaryExpression(TypeNode t1, TypeNode t2, BinaryExpression binaryExpression)
{
//
// For addition or subtraction operations involving a set (as either operand)
// the result will be a set of the same type. Later, in the Checker, we'll
// verify that the combination of operands is valid. Here, we can quickly infer
// the type of the result.
//
switch (binaryExpression.NodeType)
{
case NodeType.Add:
case NodeType.Sub:
if (t1 is Set)
return t1;
else if (t2 is Set)
return t2;
break;
case (NodeType)ZingNodeType.In:
return SystemTypes.Boolean;
default:
break;
}
return base.InferTypeOfBinaryExpression(t1, t2, binaryExpression);
}