-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored and cleaned up code for representing resolved ASTs
- Loading branch information
1 parent
e8c6bce
commit 858fe60
Showing
52 changed files
with
911 additions
and
768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,6 +322,7 @@ pub fn resolve<'a>( | |
None | ||
} | ||
}), | ||
is_generic: false, | ||
}); | ||
|
||
ctx.jobs.push_back(FuncJob::Regular( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use super::{Stmt, StmtKind, Type, TypeKind}; | ||
use crate::source_files::Source; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Block { | ||
pub stmts: Vec<Stmt>, | ||
} | ||
|
||
impl Block { | ||
pub fn new(stmts: Vec<Stmt>) -> Self { | ||
Self { stmts } | ||
} | ||
|
||
pub fn get_result_type(&self, source: Source) -> Type { | ||
if let Some(stmt) = self.stmts.last() { | ||
match &stmt.kind { | ||
StmtKind::Return(..) => None, | ||
StmtKind::Expr(expr) => Some(expr.resolved_type.clone()), | ||
StmtKind::Declaration(..) => None, | ||
StmtKind::Assignment(..) => None, | ||
} | ||
} else { | ||
None | ||
} | ||
.unwrap_or(TypeKind::Void.at(source)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::{ast::EnumMember, resolved::Type, source_files::Source}; | ||
use indexmap::IndexMap; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AnonymousEnum { | ||
pub resolved_type: Box<Type>, | ||
pub source: Source, | ||
pub members: IndexMap<String, EnumMember>, | ||
} | ||
|
||
impl PartialEq for AnonymousEnum { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.resolved_type.eq(&other.resolved_type) && self.members.eq(&other.members) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use crate::resolved::Type; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct FixedArray { | ||
pub size: u64, | ||
pub inner: Type, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use crate::resolved::{Parameter, Type}; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct FunctionPointer { | ||
pub parameters: Vec<Parameter>, | ||
pub return_type: Box<Type>, | ||
pub is_cstyle_variadic: bool, | ||
} |
Oops, something went wrong.