forked from PLC-lang/rusty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor ast representation of qualified/array/ptr references (PLC-la…
…ng#951) * first implementation of member and access * improved reference parsing * fix control statements and tests * fix statement_parser_tests * fix type-definition tests (enums) * fix misc_parser tests * fix parse-error tests * working on parenthesized expressions * parsing works * we can parse everything again * improved parsing and resolving * improved handling of cast-expressions * improve codegen * fixed R-value generation of direct-access * assigning to direct access fixed * string literals * all tests working - yay * cleanup and simplifications * ADR * renamed AstStatement::Reference to AstStatement::Identifier * added validation test * review improvements
- Loading branch information
Showing
163 changed files
with
6,733 additions
and
3,432 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,38 +1,26 @@ | ||
use ast::ast::{AstStatement, SourceRange}; | ||
use ast::ast::{AstFactory, AstStatement, SourceRange}; | ||
|
||
use crate::model::{block::Block, fbd::NodeIndex}; | ||
|
||
use super::ParseSession; | ||
|
||
impl Block { | ||
pub(crate) fn transform(&self, session: &ParseSession, index: &NodeIndex) -> AstStatement { | ||
let operator = Box::new(AstStatement::Reference { | ||
name: self.type_name.clone(), | ||
location: SourceRange::undefined(), | ||
id: session.next_id(), | ||
}); | ||
let parameters = self | ||
.variables | ||
.iter() | ||
.filter_map(|var| { | ||
// try to transform the element this block variable points to | ||
var.transform(session, index) | ||
}) | ||
.collect(); | ||
|
||
let parameters = if !self.variables.is_empty() { | ||
Box::new(Some(AstStatement::ExpressionList { | ||
expressions: self | ||
.variables | ||
.iter() | ||
.filter_map(|var| { | ||
// try to transform the element this block variable points to | ||
var.transform(session, index) | ||
}) | ||
.collect(), | ||
id: session.next_id(), | ||
})) | ||
} else { | ||
Box::new(None) | ||
}; | ||
|
||
AstStatement::CallStatement { | ||
operator, | ||
AstFactory::create_call_to( | ||
self.type_name.clone(), | ||
parameters, | ||
location: SourceRange::undefined(), | ||
id: session.next_id(), | ||
} | ||
session.next_id(), | ||
session.next_id(), | ||
&SourceRange::undefined(), | ||
) | ||
} | ||
} |
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.