use std::collections::HashMap; use super::typedef::{SharedUnifier, Type}; use crossbeam::queue::SegQueue; use crossbeam::sync::ShardedLock; use rustpython_parser::ast::Stmt; pub struct DefinitionId(usize); pub enum TopLevelDef { Class { // object ID used for TypeEnum object_id: usize, // type variables bounded to the class. type_vars: Vec, // class fields and method signature. fields: Vec<(String, Type)>, // class methods, pointing to the corresponding function definition. methods: Vec<(String, DefinitionId)>, // ancestor classes, including itself. ancestors: Vec, }, Function { signature: Type, /// Function instance to symbol mapping /// Key: string representation of type variable values, sorted by variable ID in ascending /// order, including type variables associated with the class. /// Value: function symbol name. instance_to_symbol: HashMap, /// Function instances to annotated AST mapping /// Key: string representation of type variable values, sorted by variable ID in ascending /// order, including type variables associated with the class. Excluding rigid type /// variables. /// Value: AST annotated with types together with a unification table index. Could contain /// rigid type variables that would be substituted when the function is instantiated. instance_to_stmt: HashMap, usize)>, }, } pub struct CodeGenTask { pub subst: HashMap, pub symbol_name: String, pub body: Stmt, pub unifier: SharedUnifier, } pub struct TopLevelContext { pub definitions: Vec>, pub unifiers: Vec, pub codegen_queue: SegQueue, }