/// <summary> /// Initializes a new instance of the Environment class. /// This is used to create the global environment. /// When we refer to "parent" we mean the enclosing lexical environment. /// </summary> /// <param name="interp">The interpreter.</param> /// <param name="lexicalParent">The lexical parent environment.</param> public Environment(Interpreter interp, Environment lexicalParent) { this.interp = interp; this.lexicalParent = lexicalParent; this.symbolTable = new SymbolTable(0); if (interp != nullInterp) { interp.IncrementCounter(this.GetType().Name + ":ctor"); } }
/// <summary> /// Open a file for input. /// </summary> /// <param name="filename">The filename of the file to open.</param> /// <param name="interp">The interpreter.</param> /// <returns>The input port, used for reading.</returns> internal static InputPort OpenInputFile(SchemeObject filename, Interpreter interp) { try { return InputPort.New(new StreamReader(filename.ToString(false)), interp); } catch (FileNotFoundException) { return (InputPort)ErrorHandlers.IoError("No such file: " + filename.ToString(true)); } catch (IOException ex) { return (InputPort)ErrorHandlers.IoError("IOException: " + ex.Message); } }
/// <summary> /// Initializes a new instance of the OutputPort class. /// </summary> /// <param name="outp">The TextWriter to write output to.</param> /// <param name="interp">The interpreter.</param> /// <returns>A new output port</returns> public static OutputPort New(TextWriter outp, Interpreter interp) { return new OutputPort(outp, interp); }
/// <summary> /// Initializes a new instance of the OutputPort class. /// </summary> /// <param name="outp">The TextWriter to write output to.</param> /// <param name="interp">The interpreter.</param> private OutputPort(TextWriter outp, Interpreter interp) { this.outp = outp; this.transcript = interp.Transcript; }
/// <summary> /// Initializes a new instance of the Environment class. /// Start out with a set of variable bindings and a lexical parent environment. /// The initial variable bindings are the formal parameters and the corresponding argument values. /// </summary> /// <param name="formals">A list of variable names.</param> /// <param name="vals">The values for these variables.</param> /// <param name="lexicalParent">The lexical parent environment.</param> public Environment(SchemeObject formals, SchemeObject vals, Environment lexicalParent) { this.interp = lexicalParent.Interp; this.lexicalParent = lexicalParent; this.symbolTable = new SymbolTable(formals, vals); }
/// <summary> /// Initializes a new instance of the TranscriptLogger class. /// </summary> /// <param name="interp">The interpreter using the logger.</param> internal TranscriptLogger(Interpreter interp) { this.interp = interp; }