mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
Finished up to and including chapter 16
This commit is contained in:
parent
647a095a05
commit
b86985deaf
24 changed files with 1051 additions and 198 deletions
|
|
@ -1,14 +1,15 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use std::io::{stdin, stdout, Read, Write};
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::error::RuntimeError;
|
||||
|
||||
use super::lox_std::init_std;
|
||||
use super::Value;
|
||||
|
||||
pub struct Runtime {
|
||||
globals: HashMap<String, Value>,
|
||||
globals: FxHashMap<String, Value>,
|
||||
|
||||
in_stream: Box<dyn std::io::BufRead>,
|
||||
out_stream: Box<dyn std::io::Write>,
|
||||
|
|
@ -18,7 +19,7 @@ impl Runtime {
|
|||
pub fn new(in_stream: Box<dyn std::io::Read>, out_stream: Box<dyn std::io::Write>) -> Self {
|
||||
let in_stream = Box::new(std::io::BufReader::new(in_stream));
|
||||
let mut runtime = Runtime {
|
||||
globals: HashMap::new(),
|
||||
globals: FxHashMap::default(),
|
||||
in_stream,
|
||||
out_stream,
|
||||
};
|
||||
|
|
@ -28,7 +29,7 @@ impl Runtime {
|
|||
runtime
|
||||
}
|
||||
|
||||
pub fn globals(&self) -> &HashMap<String, Value> {
|
||||
pub fn globals(&self) -> &FxHashMap<String, Value> {
|
||||
&self.globals
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue