aboutsummaryrefslogtreecommitdiff
path: root/vm.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-12 16:54:04 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-12 17:03:06 -0500
commitf6c8a4954230737321e6eeedd07b7a356b8bee36 (patch)
treeb4fbc88c990523ca37a48769c960d3daf32a5076 /vm.bqn
parente5fb1e1e7b5a3a1d32abf7da1a0d07d4ad6e4cdd (diff)
Handle cross-program namespace access in vm.bqn
Diffstat (limited to 'vm.bqn')
-rw-r--r--vm.bqn13
1 files changed, 7 insertions, 6 deletions
diff --git a/vm.bqn b/vm.bqn
index c6a876f0..052ef1a2 100644
--- a/vm.bqn
+++ b/vm.bqn
@@ -1,4 +1,4 @@
-MakeVar ← { 𝕊 name:
+MakeVar ← { program 𝕊 name:
v←@
Get ⇐ !∘"Runtime: Variable referenced before definition"
SetU ⇐ !∘"↩: Variable modified before definition"
@@ -12,18 +12,18 @@ MakeVar ← { 𝕊 name:
Get↩SetU↩SetN↩!∘"Internal error: Variable used after clear"
r
}
- GetF ⇐ {𝕩.Field name} # TODO no env.program access
+ GetF ⇐ {program 𝕩.Field name}
}
MakeEnv ← { 𝕊p‿v‿n‿e:
ns ← v-≠n # Number of special names
- vars ⇐ MakeVar¨ (ns⥊¯1) ∾ n
parent ⇐ p
program ⇐ p.program
+ vars ⇐ program⊸MakeVar¨ (ns⥊¯1) ∾ n
MakeNS ⇐ {𝕤
v ← @ ⊣´¨ n ⊔ ns↓vars # Lookup table
Field ⇐ {𝕨𝕊i:
- ! program ≡ 𝕨 # TODO cross-program handling
- i ⊑ v
+ cross ← 𝕨 { 𝕨1⊘≡𝕩 ? ⊢ ; ⊑ 𝕩.names ⊐ ⊏⟜𝕨.names } program
+ (Cross i) ⊑ v
}
}
}
@@ -174,10 +174,11 @@ RunBC ← { bc‿pos‿env:
Inner Outer {parent˙ 𝕏 ⊢}¨ run
}
}¨ blockInfo
-
+
program ← {
consts⇐consts
blocks⇐blocks
+ names⇐0⊑2⊑token
}
(⊑blocks){𝔽} {program⇐program}