Exemple #1
0
        public string AsString()
        {
            BaseIntegerType charType;

            if (BaseIntegerType.CommonCharType.Base != 8)
            {
                charType = BaseIntegerType.CommonCharType;
            }
            else
            {
                charType = new BaseIntegerType(8, false, "_tmp_char");
            }

            List <Integer> chars = new List <Integer>();

            foreach (Object obj in Collection)
            {
                if (obj.Type.Type == TypeReferenceType.Integer)
                {
                    chars.AddRange(obj.IntegerValue.Cast(charType));
                }
                else
                {
                    chars.AddRange($"[{obj.Type.ToString()}]".Select(p => (Integer)p));
                }
            }

            return(new string(chars.Select(p => (char)p).ToArray()));
        }
Exemple #2
0
 public Integer(ulong value, BaseIntegerType type)
 {
     unchecked
     {
         Type  = type;
         Value = value & type.BitMask;
     }
 }
Exemple #3
0
        public List <Integer> Cast(BaseIntegerType type)
        {
            unchecked
            {
                if (Type.Base < type.Base)
                {
                    return new List <Integer>()
                           {
                               new Integer(Value, type)
                           }
                }
                ;

                int count  = Type.Base / type.Base;
                var result = new List <Integer>();
                for (int i = 0; i < count; i++)
                {
                    result.Add(new Integer(Value >> i * type.Base, type));
                }

                return(result);
            }
        }