moved type check code to submodule

This commit is contained in:
pca006132 2021-01-08 12:58:33 +08:00
parent b51168a5ab
commit 04f121403a
11 changed files with 34 additions and 32 deletions

View File

@ -5,13 +5,7 @@ extern crate num_bigint;
extern crate inkwell;
extern crate rustpython_parser;
pub mod expression_inference;
pub mod inference_core;
pub mod statement_check;
mod magic_methods;
pub mod primitives;
pub mod typedef;
pub mod context;
pub mod type_check;
use std::error::Error;
use std::fmt;

View File

@ -1,5 +1,5 @@
use super::super::typedef::*;
use super::TopLevelContext;
use crate::typedef::*;
use std::boxed::Box;
use std::collections::HashMap;

View File

@ -1,4 +1,4 @@
use crate::typedef::*;
use super::super::typedef::*;
use std::collections::HashMap;
use std::rc::Rc;

View File

@ -1,8 +1,8 @@
use crate::context::InferenceContext;
use crate::inference_core::resolve_call;
use crate::magic_methods::*;
use crate::primitives::*;
use crate::typedef::{Type, TypeEnum::*};
use super::context::InferenceContext;
use super::inference_core::resolve_call;
use super::magic_methods::*;
use super::primitives::*;
use super::typedef::{Type, TypeEnum::*};
use rustpython_parser::ast::{
Comparison, Comprehension, ComprehensionKind, Expression, ExpressionType, Operator,
UnaryOperator,
@ -370,9 +370,10 @@ fn infer_list_comprehension<'b: 'a, 'a>(
#[cfg(test)]
mod test {
use super::*;
use crate::context::*;
use crate::typedef::*;
use super::{
super::{context::*, typedef::*},
*,
};
use rustpython_parser::parser::parse_expression;
use std::collections::HashMap;
use std::rc::Rc;

View File

@ -1,5 +1,5 @@
use crate::context::InferenceContext;
use crate::typedef::{TypeEnum::*, *};
use super::context::InferenceContext;
use super::typedef::{TypeEnum::*, *};
use std::collections::HashMap;
fn find_subst(
@ -200,9 +200,10 @@ pub fn resolve_call(
#[cfg(test)]
mod tests {
use super::*;
use crate::context::TopLevelContext;
use crate::primitives::*;
use super::{
super::{context::*, primitives::*},
*,
};
use std::rc::Rc;
fn get_inference_context(ctx: TopLevelContext) -> InferenceContext {

View File

@ -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;

View File

@ -1,5 +1,5 @@
use super::context::*;
use super::typedef::{TypeEnum::*, *};
use crate::context::*;
use std::collections::HashMap;
pub const TUPLE_TYPE: ParamId = ParamId(0);

View File

@ -1,9 +1,9 @@
use crate::context::InferenceContext;
use crate::expression_inference::{infer_expr, infer_simple_binding};
use crate::inference_core::resolve_call;
use crate::magic_methods::binop_assign_name;
use crate::primitives::*;
use crate::typedef::{Type, TypeEnum::*};
use super::context::InferenceContext;
use super::expression_inference::{infer_expr, infer_simple_binding};
use super::inference_core::resolve_call;
use super::magic_methods::binop_assign_name;
use super::primitives::*;
use super::typedef::{Type, TypeEnum::*};
use rustpython_parser::ast::*;
pub fn check_stmts<'b: 'a, 'a>(
@ -20,7 +20,7 @@ pub fn check_stmts<'b: 'a, 'a>(
}
StatementType::If { test, body, orelse } => {
if check_if(ctx, test, body.as_slice(), orelse)? {
return Ok(true)
return Ok(true);
}
}
StatementType::While { test, body, orelse } => {
@ -244,8 +244,7 @@ fn check_for_stmt<'b: 'a, 'a>(
#[cfg(test)]
mod test {
use super::*;
use crate::context::*;
use super::{super::context::*, *};
use indoc::indoc;
use rustpython_parser::parser::parse_program;