summaryrefslogtreecommitdiff
path: root/oryxc/src/compiler.rs
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2026-03-04 21:28:21 +0100
committerThomas Voss <mail@thomasvoss.com> 2026-03-04 21:28:21 +0100
commit1e279d416bf8e87e2f1d35a455bd5738bf19d9da (patch)
treed0a882ebafd0d36d513d63e06b9b1a8b7bd41115 /oryxc/src/compiler.rs
parent8dc2a3e0f9a5d6db1e97195397eaa2edc00771f7 (diff)
Spawn resolve jobs
Diffstat (limited to 'oryxc/src/compiler.rs')
-rw-r--r--oryxc/src/compiler.rs37
1 files changed, 29 insertions, 8 deletions
diff --git a/oryxc/src/compiler.rs b/oryxc/src/compiler.rs
index 6438f06..c30dbce 100644
--- a/oryxc/src/compiler.rs
+++ b/oryxc/src/compiler.rs
@@ -71,9 +71,19 @@ impl FileData {
#[allow(dead_code)]
pub enum Job {
- Lex { file: FileId, fdata: Arc<FileData> },
- Parse { file: FileId, fdata: Arc<FileData> },
- ResolveSymbols { file: FileId, fdata: Arc<FileData> },
+ Lex {
+ file: FileId,
+ fdata: Arc<FileData>,
+ },
+ Parse {
+ file: FileId,
+ fdata: Arc<FileData>,
+ },
+ ResolveDef {
+ file: FileId,
+ fdata: Arc<FileData>,
+ node: NodeId,
+ },
}
pub struct CompilerState {
@@ -97,6 +107,7 @@ impl CompilerState {
/// Push a job onto a worker's local queue and wake all threads.
fn push_job(&self, queue: &Worker<Job>, job: Job) {
+ self.njobs.fetch_add(1, Ordering::Relaxed);
queue.push(job);
self.wake_all();
}
@@ -200,7 +211,6 @@ fn worker_loop(
}
fdata.tokens.set(tokens).unwrap();
- state.njobs.fetch_add(1, Ordering::Relaxed);
state.push_job(&queue, Job::Parse { file, fdata });
},
Job::Parse { file, fdata } => {
@@ -221,11 +231,22 @@ fn worker_loop(
fdata.ast.set(ast).unwrap();
fdata.extra_data.set(extra_data).unwrap();
- state.njobs.fetch_add(1, Ordering::Relaxed);
- state.push_job(&queue, Job::ResolveSymbols { file, fdata });
+
+ let ast = fdata.ast.get().unwrap();
+ let extra_data = fdata.extra_data.get().unwrap();
+ let SubNodes(i, nstmts) = ast.sub()[ast.len() - 1];
+
+ for j in 0..nstmts {
+ let node = NodeId(extra_data[(i + j) as usize]);
+ let fdata = fdata.clone();
+ state.push_job(
+ &queue,
+ Job::ResolveDef { file, fdata, node },
+ );
+ }
},
- Job::ResolveSymbols { file: _, fdata: _ } => {
- err!("not implemented");
+ Job::ResolveDef { file, fdata, node } => {
+ eprintln!("Resolving def at node index {node:?}");
},
}