Update how scope rules work, and update implementation
* Currently, scopes are only allowed to look at their locals and the
globals. Inner functions cannot refer to values in their parent
functions. This will change eventually.
* Scope lookup is split between globals and locals. Locals are defined
in a scope if they are explicitly assigned to.
* i.e. `a = foo` will treat `a` as a local in the current scope if
it appears anywhere in that scope. This does not extend to
setattrs; `a.b = foo` will not trigger `a` into being a local var.
* `Package` objects are no longer returned from the compiler - instead,
a user function is returned.
* Other various changes and renames
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -10,10 +10,16 @@ pub enum Inst {
|
||||
PushConst(ConstHandle),
|
||||
|
||||
/// Looks up and pushes a local value.
|
||||
LoadName(Name),
|
||||
LoadLocal(Name),
|
||||
|
||||
/// Looks up and pushes a global value.
|
||||
LoadGlobal(Name),
|
||||
|
||||
/// Pop a value from the stack, possibly into a local symbol.
|
||||
Pop(Option<Name>),
|
||||
PopLocal(Option<Name>),
|
||||
|
||||
/// Pop a value from the stack, possibly into a global symbol.
|
||||
PopGlobal(Option<Name>),
|
||||
|
||||
/// Pops a symbol value and an object reference.
|
||||
///
|
||||
@@ -119,8 +125,10 @@ impl Inst {
|
||||
match self {
|
||||
Inst::PushSym(_) => "PUSH_SYM",
|
||||
Inst::PushConst(_) => "PUSH_CONST",
|
||||
Inst::LoadName(_) => "LOAD_NAME",
|
||||
Inst::Pop(_) => "POP",
|
||||
Inst::LoadLocal(_) => "LOAD_LOCAL",
|
||||
Inst::LoadGlobal(_) => "LOAD_GLOBAL",
|
||||
Inst::PopLocal(_) => "POP_LOCAL",
|
||||
Inst::PopGlobal(_) => "POP_GLOBAL",
|
||||
Inst::GetAttr(_) => "GET_ATTR",
|
||||
Inst::SetAttr(_) => "SET_ATTR",
|
||||
Inst::Jump(_) => "JUMP",
|
||||
|
||||
Reference in New Issue
Block a user