summaryrefslogtreecommitdiff
path: root/src/eval/value.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-05-28 12:44:44 +0200
committerLaurenz <laurmaedje@gmail.com>2021-05-28 12:46:43 +0200
commit0bfee5b7772338fd39bbf708d3e31ea7bcec859b (patch)
tree5f76c7d0529d6c089e8e3383356692dfce09cffb /src/eval/value.rs
parenteabf28f08187bd9a10bbadbbaf9617e2bc1949aa (diff)
Refactored loading and cache architecture
Diffstat (limited to 'src/eval/value.rs')
-rw-r--r--src/eval/value.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs
index 0d87c28f..d10d734a 100644
--- a/src/eval/value.rs
+++ b/src/eval/value.rs
@@ -1,15 +1,15 @@
use std::any::Any;
use std::cmp::Ordering;
-use std::collections::BTreeMap;
+use std::collections::{BTreeMap, HashMap};
use std::fmt::{self, Debug, Display, Formatter};
use std::ops::Deref;
use std::rc::Rc;
-use super::{EvalContext, NodeMap};
+use super::EvalContext;
use crate::color::{Color, RgbaColor};
use crate::exec::ExecContext;
use crate::geom::{Angle, Length, Linear, Relative};
-use crate::syntax::{Span, Spanned, Tree};
+use crate::syntax::{Node, Span, Spanned, Tree};
/// A computational value.
#[derive(Debug, Clone, PartialEq)]
@@ -163,6 +163,14 @@ impl PartialEq for TemplateNode {
}
}
+/// A map from nodes to the values they evaluated to.
+///
+/// The raw pointers point into the nodes contained in some [`Tree`]. Since the
+/// lifetime is erased, the tree could go out of scope while the hash map still
+/// lives. Although this could lead to lookup panics, it is not unsafe since the
+/// pointers are never dereferenced.
+pub type NodeMap = HashMap<*const Node, Value>;
+
/// A reference-counted dynamic template node that can implement custom
/// behaviour.
#[derive(Clone)]