forked from M-Labs/nac3
nac3standalone: cleanup
This commit is contained in:
parent
1eac111d4c
commit
a308d24caa
@ -30,39 +30,6 @@ use nac3parser::{
|
||||
mod basic_symbol_resolver;
|
||||
use basic_symbol_resolver::*;
|
||||
|
||||
fn main() {
|
||||
let file_name = env::args().nth(1).unwrap();
|
||||
let threads: u32 = env::args().nth(2).map(|s| str::parse(&s).unwrap()).unwrap_or(1);
|
||||
|
||||
Target::initialize_all(&InitializationConfig::default());
|
||||
|
||||
let program = match fs::read_to_string(file_name.clone()) {
|
||||
Ok(program) => program,
|
||||
Err(err) => {
|
||||
println!("Cannot open input file: {}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let primitive: PrimitiveStore = TopLevelComposer::make_primitives().0;
|
||||
let (mut composer, builtins_def, builtins_ty) =
|
||||
TopLevelComposer::new(vec![], Default::default());
|
||||
|
||||
let internal_resolver: Arc<ResolverInternal> = ResolverInternal {
|
||||
id_to_type: builtins_ty.into(),
|
||||
id_to_def: builtins_def.into(),
|
||||
class_names: Default::default(),
|
||||
module_globals: Default::default(),
|
||||
str_store: Default::default(),
|
||||
}
|
||||
.into();
|
||||
let resolver =
|
||||
Arc::new(Resolver(internal_resolver.clone())) as Arc<dyn SymbolResolver + Send + Sync>;
|
||||
|
||||
let parser_result = parser::parse_program(&program, file_name.into()).unwrap();
|
||||
|
||||
for stmt in parser_result.into_iter() {
|
||||
if let StmtKind::Assign { targets, value, .. } = &stmt.node {
|
||||
fn handle_typevar_definition(
|
||||
var: &Expr,
|
||||
resolver: &(dyn SymbolResolver + Send + Sync),
|
||||
@ -187,6 +154,39 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let file_name = env::args().nth(1).unwrap();
|
||||
let threads: u32 = env::args().nth(2).map(|s| str::parse(&s).unwrap()).unwrap_or(1);
|
||||
|
||||
Target::initialize_all(&InitializationConfig::default());
|
||||
|
||||
let program = match fs::read_to_string(file_name.clone()) {
|
||||
Ok(program) => program,
|
||||
Err(err) => {
|
||||
println!("Cannot open input file: {}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let primitive: PrimitiveStore = TopLevelComposer::make_primitives().0;
|
||||
let (mut composer, builtins_def, builtins_ty) =
|
||||
TopLevelComposer::new(vec![], Default::default());
|
||||
|
||||
let internal_resolver: Arc<ResolverInternal> = ResolverInternal {
|
||||
id_to_type: builtins_ty.into(),
|
||||
id_to_def: builtins_def.into(),
|
||||
class_names: Default::default(),
|
||||
module_globals: Default::default(),
|
||||
str_store: Default::default(),
|
||||
}.into();
|
||||
let resolver =
|
||||
Arc::new(Resolver(internal_resolver.clone())) as Arc<dyn SymbolResolver + Send + Sync>;
|
||||
|
||||
let parser_result = parser::parse_program(&program, file_name.into()).unwrap();
|
||||
|
||||
for stmt in parser_result.into_iter() {
|
||||
match &stmt.node {
|
||||
StmtKind::Assign { targets, value, .. } => {
|
||||
let def_list = composer.extract_def_list();
|
||||
let unifier = &mut composer.unifier;
|
||||
let primitives = &composer.primitives_ty;
|
||||
@ -202,26 +202,20 @@ fn main() {
|
||||
eprintln!("{}", err);
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
},
|
||||
// allow (and ignore) "from __future__ import annotations"
|
||||
if matches!(
|
||||
&stmt.node,
|
||||
StmtKind::ImportFrom { module, names, .. }
|
||||
if module == &Some("__future__".into()) && names.len() == 1 && names[0].name == "annotations".into()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if module == &Some("__future__".into()) && names.len() == 1 && names[0].name == "annotations".into() => (),
|
||||
_ => {
|
||||
let (name, def_id, ty) =
|
||||
composer.register_top_level(stmt, Some(resolver.clone()), "__main__".into()).unwrap();
|
||||
|
||||
internal_resolver.add_id_def(name, def_id);
|
||||
if let Some(ty) = ty {
|
||||
internal_resolver.add_id_type(name, ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let signature = FunSignature { args: vec![], ret: primitive.int32, vars: HashMap::new() };
|
||||
let mut store = ConcreteTypeStore::new();
|
||||
|
Loading…
Reference in New Issue
Block a user