xo-interpreter: + toplevel env in VSM
This commit is contained in:
parent
57ef654a55
commit
56a1c3bc75
11 changed files with 218 additions and 18 deletions
|
|
@ -21,6 +21,40 @@ namespace xo {
|
|||
symtab_{symtab}
|
||||
{}
|
||||
|
||||
bool
|
||||
GlobalEnv::local_contains_var(const std::string & vname) const
|
||||
{
|
||||
return symtab_->lookup_local(vname).get();
|
||||
}
|
||||
|
||||
void
|
||||
GlobalEnv::establish_var(bp<Variable> var)
|
||||
{
|
||||
// Warning: altering declared type for an already-existing variable
|
||||
// invalidates any type checking that relied on that variable.
|
||||
//
|
||||
// Ignoring this problem for now.
|
||||
//
|
||||
// Actual solution might look like:
|
||||
// - keep track of which functions/defs depend on each global variable.
|
||||
// - invalidate any jit / types for such variables.
|
||||
// - maybe use seqno's to track
|
||||
// - re-check / re-complie
|
||||
// - need to admit invalid states.
|
||||
// suppose have mutually recursive functions f(), g()
|
||||
// want ability to modify type signatures separately
|
||||
//
|
||||
// Alternatives:
|
||||
// - forbid changing type of an already-established variable
|
||||
// Actually: can't even change values if we intend supporting dependent types
|
||||
// - quietly number variables so new definitions shadow old ones but don't
|
||||
// affect previously-encountered expressions
|
||||
|
||||
this->symtab_->require_global(var->name(), var);
|
||||
|
||||
this->slot_map_[var->name()] = gp<Object>();
|
||||
}
|
||||
|
||||
TaggedPtr
|
||||
GlobalEnv::self_tp() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue