aboutsummaryrefslogtreecommitdiff
path: root/macros/src/syntax/check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/syntax/check.rs')
-rw-r--r--macros/src/syntax/check.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/macros/src/syntax/check.rs b/macros/src/syntax/check.rs
new file mode 100644
index 00000000..989d4180
--- /dev/null
+++ b/macros/src/syntax/check.rs
@@ -0,0 +1,66 @@
+use std::collections::HashSet;
+
+use syn::parse;
+
+use crate::syntax::ast::App;
+
+pub fn app(app: &App) -> parse::Result<()> {
+ // Check that all referenced resources have been declared
+ // Check that resources are NOT `Exclusive`-ly shared
+ let mut owners = HashSet::new();
+ for (_, name, access) in app.shared_resource_accesses() {
+ if app.shared_resources.get(name).is_none() {
+ return Err(parse::Error::new(
+ name.span(),
+ "this shared resource has NOT been declared",
+ ));
+ }
+
+ if access.is_exclusive() {
+ owners.insert(name);
+ }
+ }
+
+ for name in app.local_resource_accesses() {
+ if app.local_resources.get(name).is_none() {
+ return Err(parse::Error::new(
+ name.span(),
+ "this local resource has NOT been declared",
+ ));
+ }
+ }
+
+ // Check that no resource has both types of access (`Exclusive` & `Shared`)
+ let exclusive_accesses = app
+ .shared_resource_accesses()
+ .filter_map(|(priority, name, access)| {
+ if priority.is_some() && access.is_exclusive() {
+ Some(name)
+ } else {
+ None
+ }
+ })
+ .collect::<HashSet<_>>();
+ for (_, name, access) in app.shared_resource_accesses() {
+ if access.is_shared() && exclusive_accesses.contains(name) {
+ return Err(parse::Error::new(
+ name.span(),
+ "this implementation doesn't support shared (`&-`) - exclusive (`&mut-`) locks; use `x` instead of `&x`",
+ ));
+ }
+ }
+
+ // check that dispatchers are not used as hardware tasks
+ for task in app.hardware_tasks.values() {
+ let binds = &task.args.binds;
+
+ if app.args.dispatchers.contains_key(binds) {
+ return Err(parse::Error::new(
+ binds.span(),
+ "dispatcher interrupts can't be used as hardware tasks",
+ ));
+ }
+ }
+
+ Ok(())
+}
rade-may-17 Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/bench/websocket-server/chat-server.deno.mjs (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-17Add JSC.WeakGravatar Jarred Sumner 2-0/+293
2023-10-15more microtasksGravatar Jarred Sumner 1-11/+5
2023-10-15It's starting to workGravatar Jarred Sumner 6-49/+89
2023-10-15Things can happenGravatar Jarred Sumner 9-53/+150
2023-10-15FurtherGravatar Jarred Sumner 1-20/+30
2023-10-15The startup message sends successfullyGravatar Jarred Sumner 4-96/+130
2023-10-15it compiledGravatar Jarred Sumner 2-158/+238
2023-10-15okay we are starting to try itGravatar Jarred Sumner 4-9/+43
2023-10-15Okay most of the code is writtenGravatar Jarred Sumner 3-29/+398
2023-10-14MoreGravatar Jarred Sumner 7-66/+504
2023-10-14wipGravatar Jarred Sumner 8-16/+1194
2023-10-14More progressGravatar Jarred Sumner 4-36/+405
2023-10-13wipGravatar Jarred Sumner 8-48/+308