예제 #1
0
        public override void CheckSemantics(TigerScope scope, Report report)
        {
            ContainingScope = scope;

            //Check children
            Condition.CheckSemantics(scope, report);
            IfBlock.CheckSemantics(scope, report);

            if (!Condition.IsOK && !IfBlock.IsOK)
            {
                return;
            }

            TigerType = TigerType.Void;

            //Check condition type
            if (!TigerType.AreCompatible(TigerType.Int, Condition.TigerType))
            {
                report.AddError(SemanticErrors.InvalidConditionType(Condition, Condition.TigerType));
                TigerType = TigerType.Error;
            }
            if (!TigerType.AreCompatible(TigerType.Void, IfBlock.TigerType))
            {
                report.AddError(SemanticErrors.InvalidIfBodyType(IfBlock));
                TigerType = TigerType.Error;
            }
        }