Beispiel #1
0
        public LispResolvedSymbol ResolveSymbol(LispUnresolvedSymbol symbol)
        {
            // first try to resolve against one of the inherited packages
            LispResolvedSymbol resolvedSymbol = null;

            foreach (var package in _inheritedPackages)
            {
                var inheritedValue = package.GetValue(symbol.LocalName);
                if (inheritedValue != null)
                {
                    // TODO: fix calculation of `isPublic`
                    resolvedSymbol = new LispResolvedSymbol(package.Name, symbol.LocalName, isPublic: true);
                    break;
                }
            }

            // otherwise resolve to this package
            // TODO: fix calculation of `isPublic`
            if (resolvedSymbol == null)
            {
                resolvedSymbol = new LispResolvedSymbol(Name, symbol.LocalName, isPublic: true);
            }

            resolvedSymbol.Parent         = symbol.Parent;
            resolvedSymbol.SourceLocation = symbol.SourceLocation;
            return(resolvedSymbol);
        }
Beispiel #2
0
        public override LispObject GetValue(string name)
        {
            var symbol = new LispResolvedSymbol(Name, name, isPublic: true);

            SetValue(name, symbol);
            return(base.GetValue(name));
        }
Beispiel #3
0
        public virtual LispObject GetValue(LispResolvedSymbol symbol)
        {
            if (_values.TryGetValue(symbol.Value, out var value))
            {
                return(value);
            }

            return(Parent?.GetValue(symbol));
        }
Beispiel #4
0
        public bool TryGetBoundValue(LispResolvedSymbol symbol, out LispObject value)
        {
            if (_parsedBindings.TryGetValue(symbol.Value, out value))
            {
                return(true);
            }

            return(false);
        }
Beispiel #5
0
 public virtual void DeleteValue(LispResolvedSymbol symbol)
 {
     _values.Remove(symbol.Value);
 }
Beispiel #6
0
 public TObject GetValue <TObject>(LispResolvedSymbol symbol) where TObject : LispObject
 {
     return((TObject)GetValue(symbol));
 }
Beispiel #7
0
 public virtual void SetValue(LispResolvedSymbol symbol, LispObject value)
 {
     _values[symbol.Value] = value;
     Root.OnValueSet(symbol, value, this);
 }
Beispiel #8
0
        internal void SetValueInParentScope(LispResolvedSymbol symbol, LispObject value)
        {
            var target = Parent ?? this;

            target.SetValue(symbol, value);
        }
Beispiel #9
0
 protected LispStackFrame(LispResolvedSymbol functionSymbol, LispStackFrame parent)
 {
     FunctionSymbol = functionSymbol;
     Parent         = parent;
     Depth          = (Parent?.Depth ?? LispRootStackFrame.RootStackDepth) + 1;
 }
Beispiel #10
0
 public LispValueSetEventArgs(LispResolvedSymbol symbol, LispObject value, LispStackFrame stackFrame)
 {
     Symbol     = symbol;
     Value      = value;
     StackFrame = stackFrame;
 }