summaryrefslogtreecommitdiff
path: root/src/model/vm.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-23 10:54:25 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-23 12:00:06 +0100
commitb2a3d3f235fb5a23322435b854460f52db772114 (patch)
tree441ded5e4fcc0a702fe877fc6a3e3fedaaacabb5 /src/model/vm.rs
parent65aa27014d090628cfef14b0679d86dd611188b9 (diff)
More general evaluation interface
Diffstat (limited to 'src/model/vm.rs')
-rw-r--r--src/model/vm.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/model/vm.rs b/src/model/vm.rs
index db0bf77c..28885f29 100644
--- a/src/model/vm.rs
+++ b/src/model/vm.rs
@@ -15,7 +15,7 @@ pub struct Vm<'a> {
/// The route of source ids the VM took to reach its current location.
pub route: Tracked<'a, Route>,
/// The current location.
- pub location: Option<SourceId>,
+ pub location: SourceId,
/// The stack of scopes.
pub scopes: Scopes<'a>,
/// A control flow event that is currently happening.
@@ -29,7 +29,7 @@ impl<'a> Vm<'a> {
pub fn new(
world: Tracked<'a, dyn World>,
route: Tracked<'a, Route>,
- location: Option<SourceId>,
+ location: SourceId,
scopes: Scopes<'a>,
) -> Self {
Self {
@@ -45,12 +45,12 @@ impl<'a> Vm<'a> {
/// Resolve a user-entered path to be relative to the compilation
/// environment's root.
pub fn locate(&self, path: &str) -> StrResult<PathBuf> {
- if let Some(id) = self.location {
+ if !self.location.is_detached() {
if let Some(path) = path.strip_prefix('/') {
return Ok(self.world.config().root.join(path).normalize());
}
- if let Some(dir) = self.world.source(id).path().parent() {
+ if let Some(dir) = self.world.source(self.location).path().parent() {
return Ok(dir.join(path).normalize());
}
}