forked from M-Labs/nac3
moved type check code to submodule
This commit is contained in:
parent
b51168a5ab
commit
04f121403a
|
@ -5,13 +5,7 @@ extern crate num_bigint;
|
||||||
extern crate inkwell;
|
extern crate inkwell;
|
||||||
extern crate rustpython_parser;
|
extern crate rustpython_parser;
|
||||||
|
|
||||||
pub mod expression_inference;
|
pub mod type_check;
|
||||||
pub mod inference_core;
|
|
||||||
pub mod statement_check;
|
|
||||||
mod magic_methods;
|
|
||||||
pub mod primitives;
|
|
||||||
pub mod typedef;
|
|
||||||
pub mod context;
|
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
use super::super::typedef::*;
|
||||||
use super::TopLevelContext;
|
use super::TopLevelContext;
|
||||||
use crate::typedef::*;
|
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::typedef::*;
|
use super::super::typedef::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::context::InferenceContext;
|
use super::context::InferenceContext;
|
||||||
use crate::inference_core::resolve_call;
|
use super::inference_core::resolve_call;
|
||||||
use crate::magic_methods::*;
|
use super::magic_methods::*;
|
||||||
use crate::primitives::*;
|
use super::primitives::*;
|
||||||
use crate::typedef::{Type, TypeEnum::*};
|
use super::typedef::{Type, TypeEnum::*};
|
||||||
use rustpython_parser::ast::{
|
use rustpython_parser::ast::{
|
||||||
Comparison, Comprehension, ComprehensionKind, Expression, ExpressionType, Operator,
|
Comparison, Comprehension, ComprehensionKind, Expression, ExpressionType, Operator,
|
||||||
UnaryOperator,
|
UnaryOperator,
|
||||||
|
@ -370,9 +370,10 @@ fn infer_list_comprehension<'b: 'a, 'a>(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::{
|
||||||
use crate::context::*;
|
super::{context::*, typedef::*},
|
||||||
use crate::typedef::*;
|
*,
|
||||||
|
};
|
||||||
use rustpython_parser::parser::parse_expression;
|
use rustpython_parser::parser::parse_expression;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::context::InferenceContext;
|
use super::context::InferenceContext;
|
||||||
use crate::typedef::{TypeEnum::*, *};
|
use super::typedef::{TypeEnum::*, *};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
fn find_subst(
|
fn find_subst(
|
||||||
|
@ -200,9 +200,10 @@ pub fn resolve_call(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::{
|
||||||
use crate::context::TopLevelContext;
|
super::{context::*, primitives::*},
|
||||||
use crate::primitives::*;
|
*,
|
||||||
|
};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
fn get_inference_context(ctx: TopLevelContext) -> InferenceContext {
|
fn get_inference_context(ctx: TopLevelContext) -> InferenceContext {
|
|
@ -0,0 +1,7 @@
|
||||||
|
pub mod context;
|
||||||
|
pub mod expression_inference;
|
||||||
|
pub mod inference_core;
|
||||||
|
mod magic_methods;
|
||||||
|
pub mod primitives;
|
||||||
|
pub mod statement_check;
|
||||||
|
pub mod typedef;
|
|
@ -1,5 +1,5 @@
|
||||||
|
use super::context::*;
|
||||||
use super::typedef::{TypeEnum::*, *};
|
use super::typedef::{TypeEnum::*, *};
|
||||||
use crate::context::*;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub const TUPLE_TYPE: ParamId = ParamId(0);
|
pub const TUPLE_TYPE: ParamId = ParamId(0);
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::context::InferenceContext;
|
use super::context::InferenceContext;
|
||||||
use crate::expression_inference::{infer_expr, infer_simple_binding};
|
use super::expression_inference::{infer_expr, infer_simple_binding};
|
||||||
use crate::inference_core::resolve_call;
|
use super::inference_core::resolve_call;
|
||||||
use crate::magic_methods::binop_assign_name;
|
use super::magic_methods::binop_assign_name;
|
||||||
use crate::primitives::*;
|
use super::primitives::*;
|
||||||
use crate::typedef::{Type, TypeEnum::*};
|
use super::typedef::{Type, TypeEnum::*};
|
||||||
use rustpython_parser::ast::*;
|
use rustpython_parser::ast::*;
|
||||||
|
|
||||||
pub fn check_stmts<'b: 'a, 'a>(
|
pub fn check_stmts<'b: 'a, 'a>(
|
||||||
|
@ -20,7 +20,7 @@ pub fn check_stmts<'b: 'a, 'a>(
|
||||||
}
|
}
|
||||||
StatementType::If { test, body, orelse } => {
|
StatementType::If { test, body, orelse } => {
|
||||||
if check_if(ctx, test, body.as_slice(), orelse)? {
|
if check_if(ctx, test, body.as_slice(), orelse)? {
|
||||||
return Ok(true)
|
return Ok(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StatementType::While { test, body, orelse } => {
|
StatementType::While { test, body, orelse } => {
|
||||||
|
@ -244,8 +244,7 @@ fn check_for_stmt<'b: 'a, 'a>(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::{super::context::*, *};
|
||||||
use crate::context::*;
|
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use rustpython_parser::parser::parse_program;
|
use rustpython_parser::parser::parse_program;
|
||||||
|
|
Loading…
Reference in New Issue