Esempio n. 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);
        }
Esempio n. 2
0
        public override LispObject GetValue(string name)
        {
            var symbol = new LispResolvedSymbol(Name, name, isPublic: true);

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

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

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

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