Exemplo 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;
            }

            //Check children types
            if (TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.Int) && TigerType.AreCompatible(RightOperandNode.TigerType, TigerType.Int))
            {
                TigerType = TigerType.Int;
            }
            else if (!TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.Int))
            {
                report.AddError(SemanticErrors.LogicalOperandInvalidType(LeftOperandNode, LeftOperandNode.TigerType));
            }
            else
            {
                report.AddError(SemanticErrors.LogicalOperandInvalidType(RightOperandNode, RightOperandNode.TigerType));
            }
        }
Exemplo n.º 2
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));
            }
        }
Exemplo n.º 3
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;
            }

            //Check children types
            if ((TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.Int) && TigerType.AreCompatible(RightOperandNode.TigerType, TigerType.Int)) ||
                (TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.String) && TigerType.AreCompatible(RightOperandNode.TigerType, TigerType.String)))
            {
                TigerType = TigerType.Int;
            }
            else
            {
                report.AddError(SemanticErrors.InvalidOrderComparison(this, LeftOperandNode.TigerType,
                                                                      RightOperandNode.TigerType));
            }
        }