Пример #1
0
        public static Obj ParseSymb(Obj obj)
        {
            string str = obj.GetString();
            int    id  = SymbTable.StrToIdx(str);

            return(SymbObj.Get(id));
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        public static Obj At(bool[] array, int size, long idx)
        {
            if (idx < size)
            {
                return(SymbObj.Get(array[(int)idx]));
            }
            else
            {
                throw ErrorHandler.SoftFail();
            }
        }
Пример #3
0
 static public Obj Fetch(Obj target)
 {
     if (attachments.ContainsKey(target))
     {
         return(Builder.CreateTaggedObj(SymbObj.JustSymbId, attachments[target]));
     }
     else
     {
         return(SymbObj.Get(SymbObj.NothingSymbId));
     }
 }
Пример #4
0
        public static Obj FileRead_P(Obj fname, object env)
        {
            string fnameStr = fname.GetString();

            try {
                byte[] content  = File.ReadAllBytes(fnameStr);
                Obj    bytesObj = Builder.BuildConstIntSeq(content);
                return(new TaggedObj(SymbTable.JustSymbId, bytesObj));
            }
            catch {
                return(SymbObj.Get(SymbTable.NothingSymbId));
            }
        }
Пример #5
0
        public static Obj GetChar_P(object env)
        {
            int ch = Console.Read();

            if (ch != -1)
            {
                return(new TaggedObj(SymbTable.JustSymbId, IntObj.Get(ch)));
            }
            else
            {
                return(SymbObj.Get(SymbTable.NothingSymbId));
            }
        }
Пример #6
0
        public static Obj FileWrite_P(Obj fname, Obj data, object env)
        {
            string fnameStr = fname.GetString();

            byte[] bytes = data.GetByteArray();
            try {
                File.WriteAllBytes(fnameStr, bytes);
                return(SymbObj.Get(SymbTable.TrueSymbId));
            }
            catch {
                return(SymbObj.Get(SymbTable.FalseSymbId));
            }
        }
Пример #7
0
        static public Obj Fetch(Obj target)
        {
            Obj attachment;

            if (attachments.TryGetValue(target, out attachment))
            {
                return(new TaggedObj(SymbTable.JustSymbId, attachment));
            }
            else
            {
                return(SymbObj.Get(SymbTable.NothingSymbId));
            }
        }
Пример #8
0
        //////////////////////////////////////////////////////////////////////////////

        public override uint Hashcode()
        {
            if (hcode == Hashing.NULL_HASHCODE)
            {
                ushort[] fieldIds = GetFieldIds();
                ulong    code     = 0;
                for (int i = 0; i < fieldIds.Length; i++)
                {
                    code += Hashing.Hashcode(SymbObj.Get(fieldIds[i]).Hashcode(), LookupField(fieldIds[i]).Hashcode());
                }
                hcode = Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), Hashing.Hashcode64(code));
                if (hcode == Hashing.NULL_HASHCODE)
                {
                    hcode++;
                }
            }
            return(hcode);
        }
Пример #9
0
        static long ReadSymbol(byte[] text, uint length, long offset, Token token)
        {
            long i = offset;

            while (++i < length)
            {
                byte ch = text[i];
                if (ch == '_')
                {
                    if (++i == length)
                    {
                        return(-i - 1);
                    }
                    ch = text[i];
                    if (!Char.IsLower((char)ch) & !Char.IsDigit((char)ch))
                    {
                        return(-i - 1);
                    }
                }
                else if (!Char.IsLower((char)ch) & !Char.IsDigit((char)ch))
                {
                    break;
                }
            }

            if (token != null)
            {
                long   len   = i - offset;
                char[] chars = new char[len];
                for (int j = 0; j < len; j++)
                {
                    chars[j] = (char)text[offset + j];
                }

                token.offset = offset;
                token.length = len;
                token.type   = TokenType.Symbol;
                token.value  = SymbObj.Get(SymbTable.StrToIdx(new string(chars)));
            }

            return(i);
        }
Пример #10
0
 override public Obj AsObj()
 {
     return(SymbObj.Get(id));
 }
Пример #11
0
 public override NeSeqObj Append(bool value)
 {
     return(Append(SymbObj.Get(value)));
 }
Пример #12
0
 public override uint Hashcode()
 {
     return(Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), obj.Hashcode()));
 }
Пример #13
0
 protected override Obj CreateTaggedObj(ushort tagId, Obj obj)
 {
     return(ConvertGenericTaggedValue(SymbObj.Get(tagId), obj));
 }
Пример #14
0
 public override Obj LookupField(ushort fieldId)
 {
     return(Lookup(SymbObj.Get(fieldId)));
 }
Пример #15
0
        //////////////////////////////////////////////////////////////////////////////

        public override bool HasField(ushort fieldId)
        {
            return(Contains1(SymbObj.Get(fieldId)));
        }
Пример #16
0
 public override uint Hashcode()
 {
     return(Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), IntObj.Hashcode(GetInnerLong())));
 }