Skip to content

Commit

Permalink
Merge pull request #82 from lambdaclass/check
Browse files Browse the repository at this point in the history
Add code checking skeleton
  • Loading branch information
unbalancedparentheses authored Feb 2, 2024
2 parents 8d1b35e + b6f3420 commit e8671e5
Show file tree
Hide file tree
Showing 20 changed files with 484 additions and 34 deletions.
17 changes: 13 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"

members = [ "crates/concrete","crates/concrete_ast", "crates/concrete_codegen_mlir", "crates/concrete_driver", "crates/concrete_parser", "crates/concrete_session", "crates/concrete_type_checker"]
members = [ "crates/concrete","crates/concrete_ast", "crates/concrete_codegen_mlir", "crates/concrete_driver", "crates/concrete_parser", "crates/concrete_session", "crates/concrete_check"]

[profile.release]
lto = true
Expand Down
8 changes: 8 additions & 0 deletions crates/concrete_ast/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ops::Range;

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Span {
pub from: usize,
Expand All @@ -10,6 +12,12 @@ impl Span {
}
}

impl From<Span> for Range<usize> {
fn from(val: Span) -> Self {
val.from..val.to
}
}

#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct DocString {
contents: String,
Expand Down
3 changes: 2 additions & 1 deletion crates/concrete_ast/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
common::{DocString, GenericParam, Ident},
common::{DocString, GenericParam, Ident, Span},
statements::Statement,
types::TypeSpec,
};
Expand All @@ -17,6 +17,7 @@ pub struct FunctionDecl {
pub struct FunctionDef {
pub decl: FunctionDecl,
pub body: Vec<Statement>,
pub span: Span,
}

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
Expand Down
3 changes: 2 additions & 1 deletion crates/concrete_ast/src/imports.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::common::Ident;
use crate::common::{Ident, Span};

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct ImportStmt {
pub module: Vec<Ident>,
pub symbols: Vec<Ident>,
pub span: Span,
}
3 changes: 2 additions & 1 deletion crates/concrete_ast/src/modules.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
common::{DocString, Ident},
common::{DocString, Ident, Span},
constants::ConstantDef,
functions::FunctionDef,
imports::ImportStmt,
Expand All @@ -13,6 +13,7 @@ pub struct Module {
pub imports: Vec<ImportStmt>,
pub name: Ident,
pub contents: Vec<ModuleDefItem>,
pub span: Span,
}

#[derive(Clone, Debug, Eq, PartialEq)]
Expand Down
8 changes: 8 additions & 0 deletions crates/concrete_ast/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ impl TypeSpec {
TypeSpec::Array { is_ref, .. } => *is_ref,
}
}

pub fn get_name(&self) -> String {
match self {
TypeSpec::Simple { name, .. } => name.name.clone(),
TypeSpec::Generic { name, .. } => name.name.clone(),
TypeSpec::Array { of_type, .. } => format!("[{}]", of_type.get_name()),
}
}
}

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
Expand Down
13 changes: 13 additions & 0 deletions crates/concrete_check/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "concrete_check"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ariadne = { version = "0.4.0", features = ["auto-color"] }
concrete_ast = { version = "0.1.0", path = "../concrete_ast" }
concrete_session = { version = "0.1.0", path = "../concrete_session" }
itertools = "0.12.0"
thiserror = "1.0.56"
File renamed without changes.
Loading

0 comments on commit e8671e5

Please sign in to comment.