Пример #1
0
 internal virtual void CopyLocalsToParentForTailCall(LispPackage currentPackage, HashSet <string> invocationArgumentNames)
 {
     foreach (var valuePair in _values)
     {
         if (invocationArgumentNames.Contains(valuePair.Key))
         {
             Parent?.SetValue(LispSymbol.CreateFromString(valuePair.Key).Resolve(currentPackage), valuePair.Value);
         }
     }
 }
Пример #2
0
        protected override LispObject CloneProtected()
        {
            var clone = new LispPackage(Name);

            foreach (var item in _values)
            {
                clone._values.Add(item.Key, item.Value);
            }

            return(clone);
        }
Пример #3
0
        public static LispList PerformMacroReplacements(this IEnumerable <LispObject> body, LispPackage currentPackage, IDictionary <string, LispObject> replacements)
        {
            if (replacements is null)
            {
                throw new ArgumentNullException(nameof(replacements));
            }

            var itemReplacements = body.Select(item => item.PerformMacroReplacements(currentPackage, replacements)).ToList();
            var bodyList         = LispList.FromEnumerable(itemReplacements);
            var result           = new LispList(LispSymbol.CreateFromString("COMMON-LISP:PROGN"), bodyList);

            return(result);
        }
Пример #4
0
 internal LispSourceBindings(LispPackage currentPackage)
 {
     CurrentPackage = currentPackage;
 }