-
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.
- Loading branch information
1 parent
0b31b1a
commit 93c98f2
Showing
13 changed files
with
86 additions
and
221 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
pub mod resolve; | ||
pub mod resolve; | ||
pub mod resolve_names; | ||
pub mod resolve_type_sizes; | ||
mod resolve_function_contents; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use std::collections::HashMap; | ||
use crate::root::name_resolver::resolve::TypeRef; | ||
use crate::root::name_resolver::resolve_names::{TypeName, UserType}; | ||
use crate::root::parser::parse_function::FunctionToken; | ||
|
||
struct Function { | ||
|
||
} | ||
|
||
pub fn resolve_function_contents(types: HashMap<isize, UserType>, type_names: HashMap<TypeName, isize>, functions: Vec<(isize, FunctionToken)>) -> Vec<Function> { | ||
// 1st pass - Convert let a = | ||
|
||
todo!() | ||
} |
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,53 @@ | ||
use std::collections::HashMap; | ||
use derive_getters::{Dissolve, Getters}; | ||
use crate::root::name_resolver::resolve::TypeRef; | ||
use crate::root::name_resolver::resolve_names::UserType; | ||
use crate::root::parser::parse::Location; | ||
use crate::root::POINTER_SIZE; | ||
|
||
#[derive(Dissolve)] | ||
pub struct UnsizedUserType { | ||
id: isize, | ||
attributes: Vec<(String, TypeRef)>, | ||
location: Location | ||
} | ||
|
||
impl UnsizedUserType { | ||
pub fn new(id: isize, attributes: Vec<(String, TypeRef)>, location: Location) -> UnsizedUserType { | ||
UnsizedUserType { id, attributes, location } | ||
} | ||
} | ||
|
||
pub fn resolve_type_sizes(unsized_type: UnsizedUserType, final_types: &mut HashMap<isize, UserType>, unsized_types: &mut HashMap<isize, UnsizedUserType>, path: &mut Vec<isize>) -> usize { | ||
let (id, attributes, location) = unsized_type.dissolve(); | ||
|
||
if path.contains(&id) { | ||
// TODO: Circular type def error | ||
todo!(); | ||
} | ||
path.push(id); | ||
|
||
let mut size: usize = 0; | ||
let mut processed_attributes: Vec<(usize, String, TypeRef)> = Vec::new(); | ||
|
||
for (attribute_name, attribute_type) in attributes { | ||
let offset = size; | ||
|
||
if *attribute_type.indirection() != 0 { | ||
size += POINTER_SIZE; | ||
} | ||
else if let Some(sized_type) = final_types.get(&attribute_type.type_id()) { | ||
size += sized_type.size(); | ||
} | ||
else { | ||
let unsized_type = unsized_types.remove(&attribute_type.type_id()).unwrap(); | ||
size += resolve_type_sizes(unsized_type, final_types, unsized_types, path); | ||
} | ||
|
||
processed_attributes.push((offset, attribute_name, attribute_type)); | ||
} | ||
|
||
final_types.insert(id, UserType::new(id, size, processed_attributes, location)); | ||
|
||
size | ||
} |
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
Oops, something went wrong.