Fixed macro system by reintroducing MacTok::Resolved
This commit is contained in:
@@ -109,6 +109,12 @@ fn get_all_extensions<'a>(
|
||||
}
|
||||
try_stream(async |mut cx| {
|
||||
for ext_path in args.extension.iter() {
|
||||
let Some(file_name) = ext_path.file_name() else {
|
||||
return Err(io::Error::new(
|
||||
std::io::ErrorKind::IsADirectory,
|
||||
format!("Extensions are always files, but {ext_path} points at a directory"),
|
||||
));
|
||||
};
|
||||
let init = if cfg!(windows) {
|
||||
if ext_path.with_extension("dll").exists() {
|
||||
ext_dylib(ext_path.with_extension("dll").as_std_path(), ctx.clone()).await.unwrap()
|
||||
@@ -117,12 +123,15 @@ fn get_all_extensions<'a>(
|
||||
} else {
|
||||
return Err(not_found_error(ext_path));
|
||||
}
|
||||
} else if ext_path.with_extension("so").exists() {
|
||||
ext_dylib(ext_path.with_extension("so").as_std_path(), ctx.clone()).await.unwrap()
|
||||
} else if ext_path.exists() {
|
||||
ext_command(Command::new(ext_path.as_os_str()), ctx.clone()).await?
|
||||
} else {
|
||||
return Err(not_found_error(ext_path));
|
||||
let lib_path = ext_path.with_file_name(format!("lib{file_name}.so"));
|
||||
if lib_path.exists() {
|
||||
ext_dylib(lib_path.as_std_path(), ctx.clone()).await.unwrap()
|
||||
} else if ext_path.exists() {
|
||||
ext_command(Command::new(ext_path.as_os_str()), ctx.clone()).await?
|
||||
} else {
|
||||
return Err(not_found_error(ext_path));
|
||||
}
|
||||
};
|
||||
cx.emit(Extension::new(init, ctx.clone()).await?).await;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use crate::Args;
|
||||
use crate::print_mod::print_mod;
|
||||
|
||||
pub async fn repl(args: &Args, extensions: &[Extension], ctx: Ctx) -> Result<(), String> {
|
||||
eprintln!("Orchid REPL. Commands are prefixed with `:`, use `:help` to learn about the REPL.");
|
||||
let mut counter = 0;
|
||||
let mut imports = Vec::new();
|
||||
let usercode_path = sym!(usercode);
|
||||
@@ -34,10 +35,18 @@ pub async fn repl(args: &Args, extensions: &[Extension], ctx: Ctx) -> Result<(),
|
||||
if let Some(cmdline) = prompt.trim().strip_prefix(":") {
|
||||
if cmdline == "help" {
|
||||
println!(
|
||||
"Recognized commands are:\n\
|
||||
- help print this message\n\
|
||||
- modtree display the current module tree"
|
||||
"All lines not prefixed with `:` are interpreted as Orchid code.\n\
|
||||
Orchid lines are executed in distinct modules to avoid namespace clutter.\n\
|
||||
Use `let <name> = <value>` to define a constant\n\
|
||||
All other lines are \n\
|
||||
\n\
|
||||
Recognized commands prefixed with `:` are:\n\
|
||||
- :help print this message\n\
|
||||
- :modtree display the current module tree\n\
|
||||
- :exit close the REPL"
|
||||
)
|
||||
} else if cmdline == "exit" {
|
||||
break Ok(());
|
||||
} else if cmdline == "modtree" {
|
||||
let root_data = root.0.read().await;
|
||||
print_mod(&root_data.root, VPath::new([]), &root_data).await
|
||||
@@ -93,7 +102,10 @@ pub async fn repl(args: &Args, extensions: &[Extension], ctx: Ctx) -> Result<(),
|
||||
xctx.set_gas(Some(1000));
|
||||
match xctx.execute().await {
|
||||
ExecResult::Value(val, _) => {
|
||||
println!("{const_name} = {}", take_first(&val.print(&FmtCtxImpl::default()).await, false))
|
||||
println!(
|
||||
"let {const_name} = {}",
|
||||
take_first(&val.print(&FmtCtxImpl::default()).await, true)
|
||||
)
|
||||
},
|
||||
ExecResult::Err(e, _) => println!("error: {e}"),
|
||||
ExecResult::Gas(_) => println!("Ran out of gas!"),
|
||||
|
||||
Reference in New Issue
Block a user