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); } } }
protected override LispObject CloneProtected() { var clone = new LispPackage(Name); foreach (var item in _values) { clone._values.Add(item.Key, item.Value); } return(clone); }
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); }
internal LispSourceBindings(LispPackage currentPackage) { CurrentPackage = currentPackage; }