private void AssertIsBool(ParserRuleContext ctx, object result)
 {
     if ((Type)result != typeof(bool))
     {
         throw ctx.Exception("Confition result of IF statement must be boolean.");
     }
 }
 private Type GetOpType(ParserRuleContext ctx, Type t1, Type t2)
 {
     if (t1 == t2)
     {
         return(t1);
     }
     throw ctx.Exception("Cannot do operation between [{0}] and [{1}].", t1.Name, t2.Name);
 }
        private Type GetDeclType(ParserRuleContext context, string typeName)
        {
            switch (typeName)
            {
            case "decimal": return(typeof(decimal));

            case "bool": return(typeof(bool));

            case "string": return(typeof(string));

            case "var": return(null);
            }
            throw context.Exception("Unknown type declare : [{0}]", typeName);
        }
Пример #4
0
 public static OpBuilder GetOpBuilder(Type type, ParserRuleContext ctx, IlBuilder builder)
 {
     if (type == typeof(bool))
     {
         return(new BooleanOpBuilder(ctx, builder));
     }
     else if (type == typeof(string))
     {
         return(new StringOpBuilder(ctx, builder));
     }
     else if (type == typeof(decimal))
     {
         return(new DecimalOpBuilder(ctx, builder));
     }
     throw ctx.Exception("Unspported operation.");
 }
 private bool ValueEquals(object a, object b, ParserRuleContext ctx)
 {
     if (a is bool && b is bool)
     {
         return((bool)a == (bool)b);
     }
     else if (a is decimal && b is decimal)
     {
         return((decimal)a == (decimal)b);
     }
     else if (a is string && b is string)
     {
         return((string)a == (string)b);
     }
     throw ctx.Exception("Cannot do operation between [{0}] and [{1}].", a.GetType().Name, b.GetType().Name);
 }
Пример #6
0
 protected virtual void CheckEq()
 {
     throw Ctx.Exception("Sytex error.");
 }