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

460 builtin functions #511

Merged
merged 22 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1f189e2
Add initial sized varargs support, missing validation and codegen
ghaith Jun 23, 2022
55d32cd
Add initial codegen for sized varargs (WIP)
ghaith Jun 30, 2022
6746f71
Implement the code generation for sized varargs
ghaith Jul 1, 2022
4b5b464
Cargo update, moved linker to mun's repo
ghaith Jul 1, 2022
677d954
Implement SEL as a built in MUX variant
ghaith Jul 1, 2022
3cd8134
Merge branch 'master' into 460-builtin-functions
ghaith Jul 4, 2022
d790f9d
Wip
ghaith Jul 5, 2022
96c84ac
Wip builtin resolution
ghaith Jul 6, 2022
78cc65c
Made sure the codegen does not cast generics
ghaith Jul 7, 2022
046f450
Wip
ghaith Jul 7, 2022
d6c0f6d
Refcator the genirics/variadics for size
ghaith Jul 8, 2022
dae33b6
Merge remote-tracking branch 'origin/master' into 460-builtin-functions
ghaith Jul 8, 2022
987cfd5
Make sure generic varargs are annotated with hints
ghaith Jul 11, 2022
3b8d0a0
Cargo fmt and clippy
ghaith Jul 11, 2022
9ff06ef
Remove the transformation code, change the sel command to use the llv…
ghaith Jul 12, 2022
d796dfd
Move the insta code from the rs files into the snaps
ghaith Jul 12, 2022
c737815
Merge remote-tracking branch 'origin/master' into 460-builtin-functions
ghaith Jul 14, 2022
0ba2327
Update the builtin functions to also annotate
ghaith Jul 18, 2022
e42ef9a
Merge remote-tracking branch 'origin/master' into 460-builtin-functions
ghaith Jul 18, 2022
2a82315
Remove the annotations on mux/sel/move
ghaith Jul 18, 2022
1415851
Update the mux to use a switch statement
ghaith Jul 21, 2022
26ef2ab
Merge branch 'master' into 460-builtin-functions
ghaith Jul 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"matklad.rust-analyzer",
"bungcip.better-toml",
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor"
"mutantdino.resourcemonitor",
"rust-lang.rust-analyzer"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand Down
87 changes: 40 additions & 47 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ license = "LGPL-3.0-or-later"
keywords = ["iec61131", "st", "Structued_Text"]
categories = ["development-tools::build-utils"]

[features]
default = []
debug = []

[dependencies]
logos = "0.12.0"
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features= ["llvm13-0"] }
Expand All @@ -20,7 +24,7 @@ glob = "0.3.0"
encoding_rs = "0.8"
encoding_rs_io = "0.1"
codespan-reporting = "0.11.1"
lld_rs = { git = "https://github.com/ghaith/lld-rs", tag = "v130.0.0" }
lld_rs = { git = "https://github.com/mun-lang/lld-rs", branch = "main"}
generational-arena = "0.2.8"
regex = "1"
serde = { version = "1.0", features = ["derive"] }
Expand Down
7 changes: 0 additions & 7 deletions examples/hw.st

This file was deleted.

19 changes: 14 additions & 5 deletions src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright (c) 2020 Ghaith Hachem and Mathias Rieder
use crate::{lexer::IdProvider, typesystem::DataTypeInformation};
use crate::{
lexer::IdProvider,
typesystem::{DataTypeInformation, VOID_TYPE},
};
use serde::{Deserialize, Serialize};
use std::{
fmt::{Debug, Display, Formatter, Result},
Expand Down Expand Up @@ -494,6 +497,7 @@ pub enum DataType {
},
VarArgs {
referenced_type: Option<Box<DataTypeDeclaration>>,
sized: bool, //If the variadic has the sized property
},
GenericType {
name: String,
Expand Down Expand Up @@ -525,7 +529,12 @@ impl DataType {
| DataType::StringType { name, .. }
| DataType::SubRangeType { name, .. } => name.as_ref().map(|x| x.as_str()),
DataType::GenericType { name, .. } => Some(name.as_str()),
DataType::VarArgs { .. } => None,
DataType::VarArgs {
referenced_type, ..
} => referenced_type
.as_ref()
.and_then(|it| DataTypeDeclaration::get_name(it.as_ref()))
.or(Some(VOID_TYPE)),
}
}

Expand Down Expand Up @@ -1239,8 +1248,8 @@ pub fn get_enum_element_name(enum_element: &AstStatement) -> String {

/// flattens expression-lists and MultipliedStatements into a vec of statements.
/// It can also handle nested structures like 2(3(4,5))
pub fn flatten_expression_list(condition: &AstStatement) -> Vec<&AstStatement> {
match condition {
pub fn flatten_expression_list(list: &AstStatement) -> Vec<&AstStatement> {
match list {
AstStatement::ExpressionList { expressions, .. } => expressions
.iter()
.by_ref()
Expand All @@ -1254,7 +1263,7 @@ pub fn flatten_expression_list(condition: &AstStatement) -> Vec<&AstStatement> {
.take(*multiplier as usize)
.flatten()
.collect(),
_ => vec![condition],
_ => vec![list],
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/ast/pre_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ fn replace_generic_type_name(dt: &mut DataTypeDeclaration, generics: &HashMap<St
}
| DataType::PointerType {
referenced_type, ..
}
| DataType::VarArgs {
referenced_type: Some(referenced_type),
..
} => replace_generic_type_name(referenced_type.as_mut(), generics),
_ => {}
},
Expand Down
Loading