protected AnalysisWalker(ExpressionEval eval) { Eval = eval; ImportHandler = new ImportHandler(this); FromImportHandler = new FromImportHandler(this); AssignmentHandler = new AssignmentHandler(this); LoopHandler = new LoopHandler(this); ConditionalHandler = new ConditionalHandler(this); WithHandler = new WithHandler(this); TryExceptHandler = new TryExceptHandler(this); NonLocalHandler = new NonLocalHandler(this); }
private async Task ProcessClassBody(CancellationToken cancellationToken = default) { // Class is handled in a specific order rather than in the order of // the statement appearance. This is because we need all members // properly declared and added to the class type so when we process // methods, the class variables are all declared and constructors // are evaluated. // Process bases. foreach (var b in _class.Bases.Select(b => b.GetPythonType <IPythonClassType>()).ExcludeDefault()) { await SymbolTable.EvaluateAsync(b.ClassDefinition, cancellationToken); } // Process imports foreach (var s in GetStatements <FromImportStatement>(_classDef)) { await FromImportHandler.HandleFromImportAsync(s, cancellationToken); } foreach (var s in GetStatements <ImportStatement>(_classDef)) { await ImportHandler.HandleImportAsync(s, cancellationToken); } UpdateClassMembers(); // Process assignments so we get class variables declared. foreach (var s in GetStatements <AssignmentStatement>(_classDef)) { await AssignmentHandler.HandleAssignmentAsync(s, cancellationToken); } foreach (var s in GetStatements <ExpressionStatement>(_classDef)) { await AssignmentHandler.HandleAnnotatedExpressionAsync(s.Expression as ExpressionWithAnnotation, null, cancellationToken); } UpdateClassMembers(); // Ensure constructors are processed so class members are initialized. await EvaluateConstructorsAsync(_classDef, cancellationToken); UpdateClassMembers(); // Process remaining methods. await SymbolTable.EvaluateScopeAsync(_classDef, cancellationToken); UpdateClassMembers(); }
public override Task <bool> WalkAsync(FromImportStatement node, CancellationToken cancellationToken = default) => FromImportHandler.HandleFromImportAsync(node, cancellationToken);