Ejemplo n.º 1
0
        public override void CheckSemantics(TigerScope scope, Report report)
        {
            ContainingScope = scope;

            //Check children
            LeftOperandNode.CheckSemantics(scope, report);
            RightOperandNode.CheckSemantics(scope, report);
            if (!LeftOperandNode.IsOK || !RightOperandNode.IsOK)
            {
                return;
            }

            TigerType = TigerType.Int;

            //Check children types
            if (!TigerType.AreCompatible(LeftOperandNode.TigerType, RightOperandNode.TigerType) ||
                (TigerType.AreOfSameType(LeftOperandNode.TigerType, TigerType.Nil) && TigerType.AreOfSameType(RightOperandNode.TigerType, TigerType.Nil)))
            {
                report.AddError(SemanticErrors.InvalidIdentityComparison(this, LeftOperandNode.TigerType,
                                                                         RightOperandNode.TigerType));
            }
        }