Skip to content

Commit

Permalink
fix: make ci happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed Aug 28, 2024
1 parent f85f257 commit 70c6e0e
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lldb.displayFormat": "auto",
"lldb.showDisassembly": "auto",
"lldb.dereferencePointers": true,
"lldb.consoleMode": "commands"
"lldb.consoleMode": "commands",
// "rust-analyzer.check.targets": [
// "wasm32-unknown-unknown",
// ],
Expand Down
2 changes: 1 addition & 1 deletion immix
Submodule immix updated 1 files
+1 −1 src/consts.rs
2 changes: 1 addition & 1 deletion src/ast/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ pub fn pl_link(llvmmod: Module, oxbjs: Vec<PathBuf>, out: String, op: Options) {

#[cfg(not(feature = "llvm"))]
#[salsa::tracked]
pub fn compile(db: &'db dyn Db, docs: MemDocsInput, out: String, op: Options) {
pub fn compile(db: &dyn Db, docs: MemDocsInput, out: String, op: Options) {
unimplemented!()
}

Expand Down
2 changes: 2 additions & 0 deletions src/ast/compiler/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ pub enum ActionType {
SignatureHelp,
#[cfg(test)]
Completion,
#[cfg(target_arch = "wasm32")]
SemanticTokensFull,
}
2 changes: 1 addition & 1 deletion src/lsp/mem_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl MemDocsInput {
}

impl MemDocs {
#[cfg(test)]
#[cfg(any(target_arch = "wasm32", test))]
pub fn change(&self, db: &mut dyn Db, range: lsp_types::Range, uri: String, text: String) {
use salsa::Setter;
let (doc, txt) = self.change_txt(db, range, &uri, text);
Expand Down
45 changes: 28 additions & 17 deletions src/lsp/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use std::{
borrow::Borrow,
cell::RefCell,
fmt::format,
sync::{Arc, Mutex},
};

use include_dir::{include_dir, Dir};
use lazy_static::lazy_static;
use lsp_types::{
notification::DidChangeTextDocument, CompletionParams, Diagnostic, DidChangeTextDocumentParams,
GotoDefinitionParams, Position, SemanticTokens, SemanticTokensDelta, Url,
Diagnostic, DidChangeTextDocumentParams, Position, SemanticTokens, SemanticTokensDelta, Url,
};
use rustc_hash::FxHashMap;
use salsa::Setter;
use wasm_bindgen::prelude::wasm_bindgen;

use crate::{
Expand All @@ -22,9 +20,8 @@ use crate::{
compiler::{compile_dry, ActionType},
range::Pos,
},
db::{self, Database},
db::Database,
lsp::semantic_tokens::diff_tokens,
Db,
};

use super::{
Expand Down Expand Up @@ -101,17 +98,18 @@ pub unsafe fn on_change_doc(req: &str) -> String {
docin.set_file(db).to(f);

docin.set_action(db).to(ActionType::Diagnostic);
let re = compile_dry(db, docin);
let _ = compile_dry(db, docin);
// log::trace!("mod {:#?}", re.plmod(db));
// completions = compile_dry::accumulated::<Completions>(db, docin);
let diags = compile_dry::accumulated::<Diagnostics>(db, docin);
let mut m = FxHashMap::<String, Vec<Diagnostic>>::default();
for (p, diags) in &diags {
for d in &diags {
let (p, diags) = &d.0;
diags.iter().for_each(|x| x.get_diagnostic(p, &mut m));
}
let comps = compile_dry::accumulated::<Completions>(db, docin);
if comps.len() > 0 {
COMPLETIONS.inner.replace(comps[0].clone());
COMPLETIONS.inner.replace(comps[0].0.clone());
} else {
COMPLETIONS.inner.replace(vec![]);
}
Expand Down Expand Up @@ -197,12 +195,13 @@ pub fn set_init_content(content: &str) -> String {
docin.set_file(db).to(LSP_DEMO_URI.to_string());

docin.set_action(db).to(ActionType::Diagnostic);
let re = compile_dry(db, docin);
let _ = compile_dry(db, docin);
// log::trace!("mod {:#?}", re.plmod(db));
// completions = compile_dry::accumulated::<Completions>(db, docin);
let diags = compile_dry::accumulated::<Diagnostics>(db, docin);
let mut m = FxHashMap::<String, Vec<Diagnostic>>::default();
for (p, diags) in &diags {
for d in &diags {
let (p, diags) = &d.0;
diags.iter().for_each(|x| x.get_diagnostic(p, &mut m));
}
log::trace!("diags: {:#?}", diags);
Expand Down Expand Up @@ -236,7 +235,10 @@ pub fn get_semantic_tokens() -> String {
docin.set_params(db).to(Some((Default::default(), None)));
compile_dry(db, docin);
// let docs = DOCIN.docs(db);
let mut newtokens = compile_dry::accumulated::<PLSemanticTokens>(db, docin);
let mut newtokens = compile_dry::accumulated::<PLSemanticTokens>(db, docin)
.drain(..)
.map(|x| x.0)
.collect::<Vec<_>>();
if newtokens.is_empty() {
newtokens.push(SemanticTokens::default());
}
Expand All @@ -260,7 +262,10 @@ pub fn get_semantic_tokens_full() -> String {
docin.set_params(db).to(Some((Default::default(), None)));
compile_dry(db, docin);
// let docs = DOCIN.docs(db);
let mut newtokens = compile_dry::accumulated::<PLSemanticTokens>(db, docin);
let mut newtokens = compile_dry::accumulated::<PLSemanticTokens>(db, docin)
.drain(..)
.map(|x| x.0)
.collect::<Vec<_>>();
if newtokens.is_empty() {
newtokens.push(SemanticTokens::default());
}
Expand Down Expand Up @@ -290,7 +295,10 @@ pub fn get_inlay_hints() -> String {
let docin = *DOCIN;
let binding = &DB.inner;
let db = &mut *binding.borrow_mut();
let mut hints = compile_dry::accumulated::<Hints>(db, docin);
let mut hints = compile_dry::accumulated::<Hints>(db, docin)
.drain(..)
.map(|x| x.0)
.collect::<Vec<_>>();
if hints.is_empty() {
hints.push(vec![]);
}
Expand All @@ -304,7 +312,7 @@ pub fn get_doc_symbol() -> String {
let db = &mut *binding.borrow_mut();
let doc_symbols = compile_dry::accumulated::<DocSymbols>(db, docin);
let symbol = &doc_symbols[0];
return serde_json::to_value(symbol).unwrap().to_string();
return serde_json::to_value(&symbol.0).unwrap().to_string();
}

#[wasm_bindgen]
Expand All @@ -325,7 +333,7 @@ pub fn go_to_def(req: &str) -> String {
.unwrap()
.to_string();
}
let def = &defs[0];
let def = &defs[0].0;
return serde_json::to_value(def).unwrap().to_string();
}

Expand All @@ -341,7 +349,10 @@ pub fn get_refs(req: &str) -> String {
docin.set_action(db).to(ActionType::FindReferences);
docin.set_params(db).to(Some((pos, None)));
compile_dry(db, docin);
let refs = compile_dry::accumulated::<PLReferences>(db, docin);
let refs = compile_dry::accumulated::<PLReferences>(db, docin)
.drain(..)
.map(|x| x.0)
.collect::<Vec<_>>();
let mut rf = vec![];
for r in refs {
for r in r.clone().iter() {
Expand Down
9 changes: 0 additions & 9 deletions vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ fn printi64ln(i: i64) {
println!("{}", i);
}

/// see https://lang.pivotstudio.cn/docs/systemlib/vm.html#jit-invalid-memory-access-issue
#[cfg(feature = "jit")]
pub fn reg() {
gc::reg();
libcwrap::reg();
mutex::reg();
time::reg();
}

#[is_runtime]
fn pl_panic() {
println!("pivot lang panic occured!");
Expand Down
5 changes: 0 additions & 5 deletions vm/src/libcwrap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ extern crate winapi;
use internal_macro::is_runtime;

struct LibC {}
#[cfg(feature = "jit")]
pub fn reg() {
add_symbol_consts();
add_symbol_impl_libc();
}

#[cfg(not(target_os = "windows"))]
#[no_mangle]
Expand Down
9 changes: 0 additions & 9 deletions vm/src/mutex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ use std::{

use internal_macro::is_runtime;

/// see https://lang.pivotstudio.cn/docs/systemlib/vm.html#jit-invalid-memory-access-issue
#[cfg(feature = "jit")]
pub fn reg() {
add_symbol_create_mutex();
add_symbol_lock_mutex();
add_symbol_unlock_mutex();
add_symbol_drop_mutex();
}

struct MutexContainer {
mutex: Mutex<()>,
guard: Cell<Option<MutexGuard<'static, ()>>>,
Expand Down
5 changes: 0 additions & 5 deletions vm/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@ fn pl_clock_gettime(sec: *mut i64, nano: *mut u32) {
*nano = t.subsec_nanos();
}
}

#[cfg(feature = "jit")]
pub fn reg() {
add_symbol_unixtime();
}

0 comments on commit 70c6e0e

Please sign in to comment.