예제 #1
0
 private BigInteger EvaluateExpression(miranaParser.EnumFieldExpContext context)
 {
     if (context.enumFieldExp() == null)
     {
         return(EvaluateExpression(context.enumFieldExp1()));
     }
     else
     {
         BigInteger var1 = EvaluateExpression(context.enumFieldExp());
         BigInteger var2 = EvaluateExpression(context.enumFieldExp1());
         var        op   = context.operatorBitwise1();
         int        p    = 0;
         try {
             p = (int)var2;
         }
         catch (OverflowException) {
             compileUnit.AddError(context, 8, $"Cannot shift left of a value over 60.");
             return(0);
         }
         if (p > 60)
         {
             compileUnit.AddError(context, 8, $"Cannot shift left of a value over 60.");
             return(0);
         }
         if (op !.OpGreater() != null)
         {
             return(var1 << p);
         }
예제 #2
0
        private static bool IsSingleExpression(miranaParser.EnumFieldExpContext context)
        {
            if (context.enumFieldExp() != null)
            {
                return(false);
            }
            var c1 = context.enumFieldExp1();

            if (c1.enumFieldExp1() != null)
            {
                return(false);
            }
            var c2 = c1.enumFieldExp2();

            if (c2.enumFieldExp2() != null)
            {
                return(false);
            }
            var c3 = c2.enumFieldExp4();

            if (c3.enumFieldExp4() != null)
            {
                return(false);
            }
            var c4 = c3.enumFieldExp5().enumFieldExpPrimary();

            return(c4.integerNumber() != null || c4.enumField() != null);
        }