Ejemplo n.º 1
0
 public UnifiedElement VisitPrimitiveExpression(
     PrimitiveExpression prim, object data)
 {
     if (prim.Value == null)
     {
         return(UnifiedNullLiteral.Create());
     }
     if (prim.Value is bool)
     {
         return(UnifiedBooleanLiteral.Create((bool)prim.Value));
     }
     if (prim.Value is Int32)
     {
         return(UnifiedIntegerLiteral.CreateInt32((Int32)prim.Value));
     }
     if (prim.Value is UInt32)
     {
         return(UnifiedIntegerLiteral.CreateUInt32((UInt32)prim.Value));
     }
     if (prim.Value is Int64)
     {
         return(UnifiedIntegerLiteral.CreateInt64((Int64)prim.Value));
     }
     if (prim.Value is UInt64)
     {
         return(UnifiedIntegerLiteral.CreateUInt64((UInt64)prim.Value));
     }
     if (prim.Value is Single)
     {
         return(UnifiedFractionLiteral.Create(
                    (Single)prim.Value, UnifiedFractionLiteralKind.Single));
     }
     if (prim.Value is double)
     {
         return(UnifiedFractionLiteral.Create(
                    (double)prim.Value, UnifiedFractionLiteralKind.Double));
     }
     if (prim.Value is char)
     {
         return(UnifiedCharLiteral.Create(((char)prim.Value).ToString()));
     }
     if (prim.Value is string)
     {
         return(UnifiedStringLiteral.Create(prim.LiteralValue));
     }
     throw new NotImplementedException(
               "value type is " + prim.Value.GetType());
 }
 public static UnifiedBooleanLiteral CreateFalse(XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "false");
     return(UnifiedBooleanLiteral.Create(false));
 }
Ejemplo n.º 3
0
 public static UnifiedBooleanLiteral ToLiteral(this bool literal)
 {
     return(UnifiedBooleanLiteral.Create(literal));
 }