Example #1
0
        public override INode DoResolve(ResolveContext rc)
        {
            Label lb = rc.DefineLabel(LabelType.IF);

            ExitIf         = rc.DefineLabel(lb.Name + "_EXIT");
            Else           = rc.DefineLabel(lb.Name + "_ELSE");
            ParentIf       = rc.EnclosingIf;
            rc.EnclosingIf = this;


            rc.CreateNewState();
            rc.CurrentGlobalScope |= ResolveScopes.If;

            // enter if
            Expression     = (Expression)Expression.DoResolve(rc);
            TrueStatement  = (Statement)TrueStatement.DoResolve(rc);
            FalseStatement = (Statement)FalseStatement.DoResolve(rc);

            if (Expression.IsVoid)
            {
                ResolveContext.Report.Error(3, Location, "cannot evaluate void type in if statement");
            }

            rc.RestoreOldState();
            // exit current if
            rc.EnclosingIf = ParentIf;


            return(base.DoResolve(rc));
        }
Example #2
0
        public override INode DoResolve(ResolveContext rc)
        {
            Expression = (Expression)Expression.DoResolve(rc);

            if (Expression is IntegralExpression)
            {
                (Expression as IntegralExpression).Value = ~(Expression as IntegralExpression).Value;
                return(Expression);
            }

            if (Expression.IsVoid)
            {
                ResolveContext.Report.Error(110, Location, "cannot evaluate void type in one operand");
            }


            return(base.DoResolve(rc));
        }