コード例 #1
0
 /// <summary>
 /// Get the <see cref="MemorySpace"/> containing the named variable
 /// </summary>
 /// <param name="id">The variable to look for</param>
 /// <returns>The <see cref="MemorySpace"/> containing <paramref name="id"/> or null</returns>
 private MemorySpace GetSpaceWithSymbol(string id)
 {
     // Check if the current scope contains the id (and it is not the global scope)
     if (!ReferenceEquals(_currentSpace, Globals) && _currentSpace.Contains(id))
     {
         return(_currentSpace);
     }
     // Check if the top of the stack contains the id (and it is not the current space)
     if (_stack.Count > 0 && !ReferenceEquals(_stack.Peek(), _currentSpace) && _stack.Peek().Contains(id))
     {
         return(_stack.Peek());
     }
     return(Globals.Contains(id) ? Globals : null);
 }
コード例 #2
0
ファイル: InterpreterState.cs プロジェクト: jowie94/Kermit
 /// <summary>
 /// Get a global variable
 /// </summary>
 /// <param name="name">The name of the variable</param>
 /// <returns>The value of the variable or null if not found</returns>
 public KGlobal GetGlobalVariable(string name)
 {
     return(Globals.Contains(name) ? new KGlobal(name, Globals) : null);
 }