public static Obj ParseSymb(Obj obj) { string str = obj.GetString(); int id = SymbTable.StrToIdx(str); return(SymbObj.Get(id)); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// public static Obj At(bool[] array, int size, long idx) { if (idx < size) { return(SymbObj.Get(array[(int)idx])); } else { throw ErrorHandler.SoftFail(); } }
static public Obj Fetch(Obj target) { if (attachments.ContainsKey(target)) { return(Builder.CreateTaggedObj(SymbObj.JustSymbId, attachments[target])); } else { return(SymbObj.Get(SymbObj.NothingSymbId)); } }
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)); } }
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)); } }
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)); } }
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)); } }
////////////////////////////////////////////////////////////////////////////// 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); }
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); }
override public Obj AsObj() { return(SymbObj.Get(id)); }
public override NeSeqObj Append(bool value) { return(Append(SymbObj.Get(value))); }
public override uint Hashcode() { return(Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), obj.Hashcode())); }
protected override Obj CreateTaggedObj(ushort tagId, Obj obj) { return(ConvertGenericTaggedValue(SymbObj.Get(tagId), obj)); }
public override Obj LookupField(ushort fieldId) { return(Lookup(SymbObj.Get(fieldId))); }
////////////////////////////////////////////////////////////////////////////// public override bool HasField(ushort fieldId) { return(Contains1(SymbObj.Get(fieldId))); }
public override uint Hashcode() { return(Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), IntObj.Hashcode(GetInnerLong()))); }