Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

354 duplicate functions should be a problem #622

Merged
merged 10 commits into from
Nov 4, 2022
Binary file added examples/program_with_expressions
Binary file not shown.
1 change: 1 addition & 0 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ pub struct Implementation {
pub pou_type: PouType,
pub statements: Vec<AstStatement>,
pub location: SourceRange,
pub name_location: SourceRange,
pub overriding: bool,
pub generic: bool,
pub access: Option<AccessModifier>,
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/generators/data_type_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn generate_data_types<'ink>(
let types = generator
.index
.get_types()
.iter()
.elements()
.filter(|(_, it)| !it.get_type_information().is_generic(generator.index))
.map(|(a, b)| (a.as_str(), b))
.collect::<Vec<(&str, &DataType)>>();
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/generators/pou_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn generate_implementation_stubs<'ink>(
) -> Result<LlvmTypedIndex<'ink>, Diagnostic> {
let mut llvm_index = LlvmTypedIndex::default();
let pou_generator = PouGenerator::new(llvm, index, annotations, types_index);
for (name, implementation) in index.get_implementations() {
for (name, implementation) in index.get_implementations().elements() {
if !implementation.is_generic() {
let curr_f = pou_generator.generate_implementation_stub(implementation, module)?;
llvm_index.associate_implementation(name, curr_f)?;
Expand All @@ -76,7 +76,7 @@ pub fn generate_global_constants_for_pou_members<'ink>(
llvm_index: &LlvmTypedIndex<'ink>,
) -> Result<LlvmTypedIndex<'ink>, Diagnostic> {
let mut local_llvm_index = LlvmTypedIndex::default();
for (_, implementation) in index.get_implementations() {
for implementation in index.get_implementations().values() {
let type_name = implementation.get_type_name();
let pou_members = index.get_container_members(type_name);
let variables = pou_members
Expand Down
12 changes: 9 additions & 3 deletions src/codegen/generators/variable_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ pub fn generate_global_variables<'ctx, 'b>(
}

//all declared global variables
let globals = global_index.get_globals().iter().map(to_k_v);
let globals = global_index.get_globals().elements().map(to_k_v);
//all initializers
let initializers = global_index.get_global_initializers().iter().map(to_k_v);
let initializers = global_index
.get_global_initializers()
.elements()
.map(to_k_v);
//all enum-elements
let enums = global_index.get_global_qualified_enums().iter().map(to_k_v);
let enums = global_index
.get_global_qualified_enums()
.elements()
.map(to_k_v);
//all program instances
let programs = global_index
.get_pous()
Expand Down
5 changes: 5 additions & 0 deletions src/codegen/tests/code_gen_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,12 @@ fn variable_with_same_name_as_data_type() {
insta::assert_snapshot!(result);
}

/// THIS TEST IS MISLEADING!!!
/// THERE IS A CONFLICT BETWEEN TIME.TIME (the VAR)
/// AND TIME.TIME (the return variable) WHICH
/// CANNOT BE HANDLED PROPERLY. VALIDATION SHOULD FAIL!
#[test]
#[ignore = "worked in the past, should fail!"]
fn variable_with_same_name_as_function() {
let result = codegen(
"
Expand Down
Loading