private void Bind(TotemAst unboundAst) { Assert.NotNull(unboundAst); _currentScope = _globalScope = unboundAst; _finallyCount.Add(0); // Find all scopes and variables unboundAst.Walk(this); // Bind foreach (var scope in _scopes) { scope.Bind(this); } // Bind the globals unboundAst.Bind(this); // Finish Binding w/ outer most scopes first. for (int i = _scopes.Count - 1; i >= 0; i--) { _scopes[i].FinishBind(this); } // Finish the globals unboundAst.FinishBind(this); // Run flow checker foreach (var scope in _scopes) { //FlowChecker.Check(totemCode); } }
public TotemVariable(string name, VariableKind kind, ScopeStmt scope) { ContractUtils.RequiresNotNull(scope, "totemCode"); _name = name; _kind = kind; _scope = scope; }
public void SetLoc(TotemAst globalParent, IndexSpan span) { _span = span; _parent = globalParent; }
public void SetLoc(TotemAst globalParent, int start, int end) { _span = new IndexSpan(start, end > start ? end - start : start); _parent = globalParent; }
private ScopeStmt VisitScope(ScopeStmt scope) { var newScope = scope.CopyForRewrite(); ScopeStmt prevScope = _curScope; try { _curScope = newScope; newScope.Parent = prevScope; newScope.RewriteBody(this); } finally { _curScope = prevScope; } return newScope; }
public LookupVisitor(TotemAst ast, Expression globalContext) { _globalContext = globalContext; _curScope = ast; }
public override void PostWalk(TotemAst node) { // Do not add the global suite to the list of processed nodes, // the publishing must be done after the class local binding. Debug.Assert(_currentScope == node); _currentScope = _currentScope.Parent; _finallyCount.RemoveAt(_finallyCount.Count - 1); }
private void PopScope() { _scopes.Add(_currentScope); _currentScope = _currentScope.Parent; _finallyCount.RemoveAt(_finallyCount.Count - 1); if (_currentScope is FunctionDefinition) _currentFunc = (FunctionDefinition)_currentScope; }
private void PushScope(ScopeStmt node) { node.Parent = _currentScope; _currentScope = node; _finallyCount.Add(0); if (_currentScope is FunctionDefinition) _currentFunc = (FunctionDefinition)_currentScope; }