Skip to content

Commit

Permalink
chore: some code cleanup && add test case for async/await usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed Oct 23, 2024
1 parent 4740c6e commit 084eb11
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 141 deletions.
4 changes: 2 additions & 2 deletions planglib/core/coro.pi
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub fn new_coro(f: ||=>void) Coroutine {
return Coroutine{ctx:ctx, stack:p, f:f};
}

fn create_mutex() *mutex::Mutex {
let m :*mutex::Mutex ;
fn create_mutex() *mutex::MutexHandle {
let m :*mutex::MutexHandle ;
let mm = &m;
mutex::create_mutex(mm);
return *mm;
Expand Down
3 changes: 1 addition & 2 deletions src/ast/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::node::program::cycle_deps_recover;
use super::node::program::ModWrapper;
use super::node::program::ASSET_PATH;
#[cfg(feature = "llvm")]
Expand Down Expand Up @@ -151,7 +150,7 @@ pub fn compile_dry<'db>(db: &'db dyn Db, docs: MemDocsInput) -> Result<ModWrappe

/// compile_dry_file parses the file inside parser_entry into AST,
/// and then emit the llvm IR code represented by Mod according to the entry file AST.
#[salsa::tracked(recovery_fn=cycle_deps_recover)]
#[salsa::tracked]
pub fn compile_dry_file<'db>(
db: &'db dyn Db,
parser_entry: FileCompileInput<'db>,
Expand Down
78 changes: 78 additions & 0 deletions src/ast/expects/test_diag.pi.expect
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,45 @@
},
},
},
PLDiag {
raw: PLDiagRaw {
code: Err(
ONLY_TASK_CAN_BE_AWAIT,
),
help: None,
labels: [
PLLabel {
file: u!(""),
txt: None,
range: Range {
start: Pos {
line: 164,
column: 11,
offset: 1731,
},
end: Pos {
line: 164,
column: 23,
offset: 1743,
},
},
},
],
source: None,
range: Range {
start: Pos {
line: 164,
column: 5,
offset: 1725,
},
end: Pos {
line: 164,
column: 23,
offset: 1743,
},
},
},
},
PLDiag {
raw: PLDiagRaw {
code: Err(
Expand All @@ -1230,6 +1269,45 @@
},
},
},
PLDiag {
raw: PLDiagRaw {
code: Err(
ONLY_AWAIT_IN_ASYNC_FN,
),
help: None,
labels: [
PLLabel {
file: u!(""),
txt: None,
range: Range {
start: Pos {
line: 164,
column: 11,
offset: 1731,
},
end: Pos {
line: 164,
column: 23,
offset: 1743,
},
},
},
],
source: None,
range: Range {
start: Pos {
line: 164,
column: 5,
offset: 1725,
},
end: Pos {
line: 164,
column: 23,
offset: 1743,
},
},
},
},
PLDiag {
raw: PLDiagRaw {
code: Warn(
Expand Down
5 changes: 1 addition & 4 deletions src/ast/node/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ lazy_static::lazy_static! {
};
}

mod cycle;
pub use cycle::*;

fn import_symbol(
s: Ustr,
x: &GlobalType,
Expand Down Expand Up @@ -450,7 +447,7 @@ impl<'db> Program<'db> {
/// `emit` function analyzes all submodules used by the current program,
/// resolves all symbols from submodules into the current one,
/// and compiles the current module with all sub-modules into LLVM IR or does some LSP works
#[salsa::tracked(recovery_fn=cycle_deps_recover_emit)]
#[salsa::tracked]
pub fn emit(self, db: &'db dyn Db) -> ModWrapper<'db> {
#[cfg(not(target_arch = "wasm32"))]
let (job, pb) = if self.params(db).action(db) == ActionType::Compile {
Expand Down
132 changes: 0 additions & 132 deletions src/ast/node/program/cycle.rs

This file was deleted.

2 changes: 1 addition & 1 deletion test/lsp_diag/test_diag.pi
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn test_f_diag2(,) {
}

fn test_f_diag3(a, b:i64) void {

await test_f_diag2();
return;
}

0 comments on commit 084eb11

Please sign in to comment.